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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove files based on time stamp

Status
Not open for further replies.

sabev

Programmer
Sep 27, 2002
47
US
How might I remove files based on how old they are? Say delete files older than a day?

I am guessing I can use the find command and pass the file to a rm command -

find -name "filename" -time??? | xargs rm

Thanks
 
For files older than a day, you can do:

find /<path> -mtime +1 -exec rm {} \;

the -mtime indicates files which haven't been modified for the specified number of days. It's always a good idea to replace the exec with a -print before executing this in anger, just o confirm that you'll be doing what you want and not deleting other important files. HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top