Distributed Networks Home
DBWebApplications eWebProgrammer
prev prev
  Course navigation
    Useful date command options
The Unix date command displays the date and the time of day. The standard output of the date command looks like this:
$ date
Sat Sep 25 14:38:35 PDT 1999
The date command lets you use options to display pieces of the date and time information in a selected format. If you want to display only the day of the month, you would use this command:
$ date +%e
25
Start the format specification with a plus sign. Follow this with one or more percent-sign-marked letters, which indicate which piece of the date you want. The %e represents the day of the month. %b represents the 3-letter abbreviation for the month:
$ date +%b
Sep
To display the month and the day of the month, use the command below.
$ date +%b-%e
Sep-25
The dash in this command is literal. You can insert characters between the percent-sign-marked pieces of the date and they will be displayed literally in your output:
Test out these date command options by logging into your UNIX account and typing them in at the shell prompt.
  Course navigation