Computing.Net > Forums > Unix > Delete old files using Korn shell

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete old files using Korn shell

Reply to Message Icon

Name: Kandiah M Ravindran
Date: November 9, 2002 at 04:46:02 Pacific
OS: LNUX
CPU/Ram: not known
Comment:

I need a script for the following criteria.

I need to delete files older than the date I am passing in the arguments.

E.g: Here are the file names in the directory
fname20021030.bak
fname20021029.bak
fname20021028.bak
fname20021027.bak

delete1 fname 20021029
The program should delete all the files those are older than 20021029
It should leave 2 files in the above example.

Thanks
Kandiah



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: November 9, 2002 at 14:33:33 Pacific
Reply:

touch -t 20021029 compare
find . ! -newer compare -exec rm {} \;

if you need this packaged as a script you pass a parameter to, write back.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Delete old files using Korn shell

Deleting old files using ftp script www.computing.net/answers/unix/deleting-old-files-using-ftp-script/4257.html

Calling a .bat file using Korn scri www.computing.net/answers/unix/calling-a-bat-file-using-korn-scri/8291.html

Script to delete old files www.computing.net/answers/unix/script-to-delete-old-files/4094.html