18 Feb
2006
18 Feb
'06
02:59
Shriramana Sharma wrote:
I need to use the mv command to create the backup of a file. Currently I am using:
mv message ../message-old
But potentially the message-old file already exists. So the mv command gives me a --backup option, but none of these options is to append the filename with the current date.
Is there a way I can append the current date to a filename in a mv command?
You can include the current date & time in a file name, if you wish. For example, you might try mv message message.`date +%m%d%H%M%Y.%S` will move message to message.20060217. You can even include the time or use other formats. man date for details