Quick question about the command find.
Marc Farnum Rendino
mvgfr1 at gmail.com
Fri Jun 4 14:06:48 UTC 2010
any find that deletes (or uses -exec) is potentially dangerous; you've been
that said, try this:
find /path –mtime +15 -print0 | xargs -0-n 1 rm
using "-print0" avoids problems with "strange" characters in pathnames.
using "-n 1" causes it to execute with a single pathname at a time; less
efficient though safer.
btw: removing a directory based on its the mod date is maybe not what you
want - said directory may very well have files within it, that are *newer*
than 15 days.
so i've deliberately left an "error" in the above; it'll attempt to apply
the "rm" to dirs and give you errors; you can then use those messages to
review those dirs and decide if you do want to delete them.
if you *really* want to delete dirs too, in one step:
find /path –mtime +15 -print0 | xargs -0 rm -r
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ubuntu-users