What is the easiest way to append the date (year, month, day) to a filename?
Well depends on how/why you're doing it. If you're writing a script I guess you can call the date program and append the ouput to the file. I guess backup-programs are a common scenario. It can look something like this:
tar -czf backup_$(date +%y%m%d).tar.gz DIR/ECT/ORY/
Would create a file named:
backup_060403.tar.gz
You can invoke any 'command' the same way:
$(command)
/Richard
You may follow this thread, as well to add date at the end of the file name
Thank you for the suggestion. What I want to do is take a file and copy it to have the date appended in it. For instance. anyfile.zip will be copied to anyfile.zip060403. I tried to do the following:
cp anyfile.zip anyfile.zip+`date +%y%m%d`
but the + sign became part of the filename.
why the '+' sign ???
cp anyfile.zip anyfile.zip`date +%y%m%d`
Just dont have the 'plus' sign when you copy..
cp filename filename`date +%Y%m%d`
Goodluck