I'm working on a bash script that backs up a configuration file before copying over a new file.
Here's what my snippet looks like:
mv ~/myStuff.conf ~/myStuff.conf.bak cp ~/new/myStuff.conf ~/myStuff.conf
Every time this script is run, I'd like there the backup to have a unix timestamp in the filename. I tried this
DATEVAR=date +%s mv ~/myStuff.conf ~/myStuff.conf.$DATEVAR.bak
But this doesn't work, since the date function doesn't execute and bash sees it as a string, and the resulting file ends up being
Any ideas on how to get the results of the date function into a variable?