|
|
| No such thing as a small change | |
| PerlMonks |
Re: Delete all but the most recent backup fileby Kenosis (Deacon) |
| on Jan 24, 2013 at 05:54 UTC ( #1015079=note: print w/ replies, xml ) | Need Help?? |
|
If I'm understanding you correctly, perhaps the following will be helpful:
Output (the files that would be deleted):
If you populate @fileNames with the file names in the directory where the backups live, it will grep them only allowing backup-patterned files through. Then, using a Schwartzian transform, it sorts the backup file names in decending order and shifts off the first element (most recent backup file name) from @sortedFileNames. As it is now, the file names in @sortedFileNames are printed, but the unlink line can be uncommented, so all but the most recent backup files are deleted. ** Please thoroughly test and verify this on a copy of the backup directory before going live with it. **
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||