Differences between revisions 2 and 3
Revision 2 as of 2005-03-31 20:44:52
Size: 745
Editor: t-indiv10-220
Comment:
Revision 3 as of 2008-10-03 20:18:32
Size: 745
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

cd to the path you want, then...

find . -mtime +14 -print0 | xargs -0 rm -f

This would find all files that hadn't been accessed in more than 14 days, then feed the filename list to xargs, which clumps 'em and lets rm go at it. Quick explaination: "find -print0" will null terminate the file names, "xargs -0" will search for the null character to get the end of file's name.This is typically more efficient than having the find itself do the task. Note that you could also skip the second part of the pipe and generate a list of which files match simply with:

find . -atime +14 -print

and see what you get. If you want to use creation time or modification time, rather than access time, use -ctime or -mtime instead.

JunHu: JunHu/Memo/RemoveOldFiles (last edited 2008-10-03 20:18:32 by localhost)