CzarAlex
July 23rd, 2007, 04:58 AM
I'd like some BASH scripting help.
I have a bash script that backs up a file weekly for me and puts a formatted date in the file name.
Example:
moo20070701.tar.gz
moo20070708.tar.gz
moo20070715.tar.gz
moo20070722.tar.gz
Id like to keep the last 4 weeks of backups (meaning 4 files) Could someone assist me in writing a script that will keep only the 4 most recent backups and drop the oldest one?
For example, when the script is run next week, moo20070729.tar.gz will be made and I'd like the oldest of the files, in this case, moo20070701.tar.gz to be removed.
How can I do this?
I have a bash script that backs up a file weekly for me and puts a formatted date in the file name.
Example:
moo20070701.tar.gz
moo20070708.tar.gz
moo20070715.tar.gz
moo20070722.tar.gz
Id like to keep the last 4 weeks of backups (meaning 4 files) Could someone assist me in writing a script that will keep only the 4 most recent backups and drop the oldest one?
For example, when the script is run next week, moo20070729.tar.gz will be made and I'd like the oldest of the files, in this case, moo20070701.tar.gz to be removed.
How can I do this?