[NTLUG:Discuss] Yet Another Scripting Request
Eric Schnoebelen
eric at cirr.com
Thu Aug 28 16:53:42 CDT 2008
Daniel Hauck writes:
- 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.
[..]
- I think to begin with, a "find /path/to/root/directory" will generate a
- convenient recursive list of files to act on. But after that, how do I
- query and compare file dates against the present date and stuff like
- that? Or perhaps thereis even a better way to make it dig through
- subdirectories than feeding it the output of "find"?
``man find''
Look for -mtime, -atime, -type, and -print or -delete.
find <top level directory> -type f -mtime +5 -print0 | xargs -0 rm -f
--
Eric Schnoebelen eric at cirr.com http://www.cirr.com
I can't remember if I'm the good twin or the evil one.
More information about the Discuss
mailing list