Current Date on Shell

Posted in Linux on August 1, 2016 by Adrian Wyssmann ‐ 1 min read

To display the current date on the shell you use the date command

[adrian@archlinux]$ date
Fri Jan 1 08:08:10 UTC 2016

So this format may not fit your need, therefore you would adjust the format by the +FORMAT parameter as described in the help

date +FORMAT

As an example do display the date in format yyyymmddhhmm you would type

[adrian@archlinux]$ date +%Y%m%d%H%M

which will display

201601010808

If you want to use the outcome of the command as value for further commands, just enclose them in `

[adrian@archlinux]$ script console_`date +%Y%m%d%H%M`.txt
Script started, file is console_201601010808.txt