Nice. Also:
>If you do get them from find, you run things on them in precisely the same way you run things on any other list of files: a for loop.
for file in $(find ...); do
rm $file
done
If you know the number of files (and hence total command line length) will not be too high (i.e. not exceed the maximum length of a Unix command-line [1]), and that the filenames will not contain spaces or other problem-causing characters, you can shorten that to:
rm $(find ...) # or rm -i $(find ...) for interactive deletion.
This will only run rm once, instead of once for each file.
If either or both of the above conditions are not met, your 2nd or 3rd snippets are preferable.
[1] IIRC, there is a constant defined for that maximum, somewhere in standard C library's header files (maybe something like BUFMAX). I've read that early versions of Unix commands used to crash in some way (core dump or seg fault) if the length was exceeded, and seen that a few times myself. Also may have read that it was quite short initially, like 512 or 1024 bytes. People might have done something to fix that, apart from xargs, later.
Update: I googled for this phrase:
maximum length of unix command line
and looked at the first few hits; found some info:
xargs --show-limits
can give info about the maximum length, which POSIX calls ARGMAX, not BUFMAX as I said above.
and a sample output of xargs --show-limits is:
Your environment variables take up 2446 bytes
POSIX upper limit on argument length (this system): 2092658
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2090212
Size of command buffer we are actually using: 131072
There is no limit per argument, but a total for the whole command line length. In my system (Fedora 15/zsh) its closer to 2Mb. (line 4).
(from http://stackoverflow.com/questions/6846263/maximum-length-of... )
One of the hits also says that
getconf ARGMAX
shows the value, on POSIX-conformant systems.