Possible Duplicate:
How do I delete files greater than a certain date on linux
How to delete all files in current directory and it`s sub directories older than one year?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityPossible Duplicate:
How do I delete files greater than a certain date on linux
How to delete all files in current directory and it`s sub directories older than one year?
find /the/dir/to/start/in -type f -mtime +365 -ls -exec rm -f -- {} \;
find … -exec rm -f {} +
will be a little faster (and it's portable except to ancient systems).
– Gilles 'SO- stop being evil'
Sep 24 '10 at 21:17
--
in case the first file name begins with a -
(although you can guarantee it won't happen if the directory passed to find
doesn't begin with a -
).
– Gilles 'SO- stop being evil'
Sep 24 '10 at 21:22
If you are removing lots of files this is typically a lot faster than "-exec" or piping to "xargs":
find . -type f -mtime +365 | perl -lne unlink
man find
. Boom. – mkoistinen Sep 24 '10 at 19:08