Browsing the archives for the date tag.

Format The Date Command In Bash

Examples

Formatting the date output in bash is simple:

date + "%Y-%m-%d";

An example of assigning to a variable and using:

now=`date + "%Y-%m-%d"`;
cp /etc/hosts ~/hosts_${now};

For more information, see the manual.

No Comments