View Full Version : shell date scripting?

05-24-2011, 03:18 PM

i run a simple command line to make backups of sites on my server and move them to another directly which gets backed up to an external drive.

my command;

tar -zcvf /home/sites/backups/MySite`date '+-%d-%m-%y'`.tar.gz /home/sites/MySite/

now what I need to do is remove backups older then 5 days. i see that in the shell I can do a date sub like this;

date -d "5 days ago"

but how can I format the result of this to be the same as the format above? ( %d-%m-%y )?
I can't seem to combine the new functions.

any help would be great!

05-24-2011, 03:35 PM
scratch that, I've got it;

my test command

touch test`date '+-%d-%m-%y' -d '+5 days ago'`.txt