For example, I want to display current date and time as the following format:
yyyymmddhhmmss
How do I do that? It seems like most date format comes with -
, /
, :
, etc.
ベストアンサー1
Here you go:
date +%Y%m%d%H%M%S
As man date
says near the top, you can use the date
command like this:
date [OPTION]... [+FORMAT]
That is, you can give it a format parameter, starting with a +
. You can probably guess the meaning of the formatting symbols I used:
%Y
is for year%m
is for month%d
is for day- ... and so on
You can find this, and other formatting symbols in man date
.