[NTLUG:Discuss] Yet Another Scripting Request

Patrick R. Michaud pmichaud at pobox.com
Thu Aug 28 19:41:13 CDT 2008


On Thu, Aug 28, 2008 at 04:46:08PM -0500, Daniel Hauck wrote:
> Objective:
> 
> Write a script that will read through a directory and subdirectories and 
> identify all files older than X days (let's just say 5 days if it helps) 
> and delete them.

Answer:

   find <dir> -type f -mtime +5 -exec rm {} \;

If you want to print the files as they're being deleted:

   find <dir> -type f -mtime +5 -print -exec rm {} \;

Pm



More information about the Discuss mailing list