Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell script to delete old files

Status
Not open for further replies.

umeman

Technical User
Oct 2, 2001
59
US
Admins,

I needs a korn shell script to delete files from
a particular directory that is older that 1 day,

If anyone has a scripts or any ideas on how to do this
please forward your thoughts

Thanks
-u-
 
Use the find command to locate all files older than one day and then remove them

cd /dir
find . -ctime +1 | xargs rm

Remember when writing any script which removes files, test it thoroughly on dummy files / directories before running it on important files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top