The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script preserving last 2 versions of files synergy_texas Shell Programming and Scripting 6 10-29-2008 12:58 PM
Mac OS X 10.4: Optional Installs may install previous versions of certain application iBot OS X Support RSS 0 09-27-2008 07:12 AM
script to delete files looza Shell Programming and Scripting 3 07-11-2008 10:56 AM
script to delete files vats Shell Programming and Scripting 12 09-01-2007 05:27 AM
Need to delete previous line after successful seearch pbsrinivas Shell Programming and Scripting 7 10-31-2006 11:55 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-19-2009
jbsimon000 jbsimon000 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 12
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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0