21zoo Labs - Assorted Stuff

Bash Shell - Append Date to Filename

Posted — Nov 14, 2017

Append the current date to a filename in Bash shell:

$ fname="/var/log/output-$(date +"%Y-%m-%d").log"
$ echo $fname
/var/log/output-2017-11-14.log
$