Answer to chapter 4 question 3
As in problem 4.1, you should use man to find out
more information on date . In this case, however, you
need specific information on date , so the command you
use is
$ man date
The manual page for date is likely to be big, but
this is not a problem. Remember that the manual page is divided
into sections. First of all, notice that under section
SYNOPSIS the possible format for arguments to
date is given:
SYNOPSIS
date [-u] [+format]
This indicates that date may have up to two arguments, both of
which are optional (to show this, they are enclosed in square
brackets). The second one is preceded by a + symbol,
and if you read further down, in the DESCRIPTION
section it describes what format can contain. This
is a string (so enclose it in quotes) which includes field
descriptors to specify exactly what the output of
date should look like. The field descriptors which are
relevant are: %r (12-hour clock time), %A
(weekday name), %d (day of week), %B
(month name) and %Y (year). The argument you would
give to date would therefore be:
+"%r on %A %d %B %Y"
so that the command you would type would be
date +"%r on %A %d %B %Y"
Note that, although the POSIX standard specifies only two
arguments to date -- some systems may in addition
allow others.
|