Monday, December 04, 2006

UNIX: delete files older then X days old

This can be useful when making a rolling backup script

find /directory -type f -mtime +12 | xargs rm

/directory: your directory name that the files are under (rename appropriately)
-type f: only delete files (not subdirectories)
+12: older than 12 days old

2 comments:

  1. thanks buddy this really helped me out. . if you put -type d it'll list the directories.. . awesome!!!

    Andy D.
    http://www.FranklinFaces.com

    ReplyDelete