Deleting all image files with "small" keyword

Cameron Simpson cs at zip.com.au
Sun Apr 11 08:08:27 UTC 2010


On 11Apr2010 07:54, Joachim Backes <joachim.backes at rhrk.uni-kl.de> wrote:
| On 04/11/2010 01:04 AM, Leonard Adjei wrote:
| >using
| >  sudo find AUDIO/  -name \*Small\*.jpg -exec rm  {} \;
| >worked fine for me.
| >
| >Thanks
| 
| this will run the rm command separately for *each found* "small".jpg file.
| 
| Probably faster:
| 
| find AUDIO/  -name \*Small\*.jpg|xargs rm
| 
| This starts rm only once, but depends on the maximum command length
| allowed for your shell.

And depends on not having too weird filenames. Xargs is rather flakey that
way. The usual "nasty filename" fix for find/xargs is to use -print0 with
find and the -0 option to xargs.

BTW, the max command length is usually an artifact of the OS' exec()
system call, not the shell itself - the shell will just malloc enough
room for the command length and then pass it to exec(), which will
refuse if it is too long.

Also, the whole point of xargs is to _circumvent_ the command exec()
limit; it will run "rm" multiple times if necessary to avoid the command
line limit.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Just because Unix is a multiuser system doesn't mean I want to share it with
anybody!        - Paul Tomblin, in rec.aviation.military


More information about the users mailing list