Delete files older than X number of days

The Find Utilitiy

Recent versions of "find" include a feature to delete the files that are found. This can be dangerous so always test when you know you have good backups.

A simple example to locate files older than three days and delete them without using pipes.

find /directory/* -mtime +3 -delete

You can replace the 3 with what ever you like. Read more about this and other features in the manual.

Tags: