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

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>