[Novalug] Linux tip: Use -delete with GNU find command
Maxwell Spangler
maxpublic07 at maxwellspangler.com
Sun Mar 11 14:52:51 EDT 2007
For [too many] years, I've been doing this:
find directory_name -size 0 -print -exec rm {} \;
In order to scan a particular directory for things like empty files and delete
them.
While doing this a minute ago I found that the GNU find command has a -delete
option to remove the file and return an error code if not removed properly.
This is nicer on my eyes than the older style shown above and doesn't require
another fork to call rm to do the same task. On systems with a significant
number of users/processes, not forking for every little thing is a very good
policy.
I learned 'find' many years ago without GNU find and wish I'd known about this
sooner, so I'm sharing today..
--
-- ----------------------------------------------------------------------------
Maxwell Spangler
Chapel Hill, North Carolina
More information about the Novalug
mailing list