
Episode 16 find command
Hi Chad. Nice show - good topics.
I have a few pedantic notes about the find command. It is not functionally equivalent to the rm command which it was supposed to replace. That is to say, in some cases it will do the same thing, but in other cases not. The most important difference is that find will descend into sub-directories. I feel that it's important to tell people this, else they might end up removing a lot more files than they expect.
Also, the -name '*' part is not necessary. although it's fine if the user wants to specify some other pattern, like -name '*.gz'
For this reason, I would recommend an improved command:
find . -maxdepth 1 -type f -print0 | xargs -0 rm
One final pedantic note - you said that using the find command executes rm for each file. This is not quite true. xargs groups files so that each rm invocation gets some sub-set of the full list of files... few enough to not trigger the argument list length problem, but long enough to reduce the number of rm invocations. This is a good thing because each rm invocation uses systems resources. You could use the -n 1 option to xargs to specify that each rm invocation should be passed exactly one file, but this would be less efficient.
Cheers, Matthew

Thanks for the Corrections
Thanks for the Corrections Matthew, I will make sure to mention them next episode! I am quite fallable when it comes to the find command, as I do not use it often, so I appreciate the rundown.
Chad