03-19-2009
12,
0
Join Date: Mar 2009
Last Activity: 14 April 2009, 11:54 AM EDT
Posts: 12
Thanks Given: 0
Thanked 0 Times in 0 Posts
Need a script to delete previous versions of files
Hi.
I need a script (either bash or perl) that can delete previous versions of files.
For instance, from our continuous build process I get directories such as
build5_dev_1.21
build5_dev_1.22
build5_dev_1.23
build5_dev_1.24
I need a script that I can run every night (using "at" command) that deletes all but the last 1 or 2, such that when the script runs tonight, if the limit is 2, I end up with only the following two directories.
build5_dev_1.23
build5_dev_1.24
if a new build is created during the day the directory ill be named
build5_dev_1.25
and after the script runs I will have directories
build5_dev_1.24
build5_dev_1.25
left.
Ideally I only need to save the "latest" build (the one with the highest "1.xx" number), but i would like the option to save "n" builds, so that I can always have the last 2 or even 3 around if I want.
I am not well versed in script building, my main job is software development, and maintaining the builds is a side task that I write scripts for when i get tired of doing the repetitive tasks by hand. As a consequence I do the scripting so seldom that I have to re-learn alot each time I start a new script. that's why I'm asking for any pointers anyone would be willing to give.
thanks !
Joe Simon