Command “date” is used to display the date of the system.
To see the current date type the command “ date” on the terminal as shown in below
1 | $ date [ press enter on terminal] |
output
1 | Friday Jan 19 12:15:44 IST 2018 |
The above command will display current day, date, month, year and time as shown above.
Option:
date command can also be used with format specified .
Each format is preceded by + symbol and followed by % operator and format described as a single character.
We want to see only current month use format +%m. as shown below.
1 | $ date +%m [ press enter] |
output
1 | 01 |
output is month 01
We want to see only currant month name use format +%h. as show below.
1 | $ date +%h [ press enter] |
output
1 | January |
output is month January
We can also combine both command as:
1 | $ date +”%m %h” [ press enter] |
output
1 | 01 January |
output is month 01 is January
Other options of date command
[table id=2 /]