Well, you can’t really get a date with this command but it is a very useful command to know for administrative tasks as well as for automatic documentation through scripting.
However, the date command’s options often baffles a lot of people (well, in my administering SuSE Linux class anyway) especially when they read about the formatting using the % symbol on the man pages.
Let me briefly extract what the man pages say;
NAME
date – print or set the system date and timeSYNOPSIS
date [OPTION] … [+FORMAT]
date [-u|—utc|—universal] [MMDDhhmm[[CC]YY][.ss]]DESCRIPTION
… blah blah …FORMAT controls the output. The only valid option
for the second form specifies Coordinated
Universal Time. Interpreted sequences are:%% a literal %
…
%F full date; same as %Y-%m-%d
I have seen many different attempts at trying to understand how to use the %F, e.g.
# date %F
or
# date –F
However, it is actually quite clear but somehow it is not the usual UNIX/LINUX command option format. To get the date in the format 2009-04-17 (today’s date), you simply do
# date +%F
2009-04-17
It becomes obvious after you read the man page again.




No comments yet.