Could someone answer how many processes are created in each case for the commands below as I dont understand it :
The following three commands have roughly the same effect:
rm $(find . -type f -name '*.o')find . -type f -name '*.o' | xargs rmfind . -type f -name '*.o' -exec rm {} \;
rm, the other forfind.find, another forxargs, and one or morerm.xargswill read standard input, and if it reads more lines than can be passed as parameters to a program (There is a maximum value namedARG_MAX).findand another one for each file ending in.oforrm.In my opinion, option 2 is the best, because it handles the maximum parameter limit correctly and doesn’t spawn too many processes. However, I prefer to use it like this (with GNU find and xargs):
This terminates each filename with a
\0instead of a newline, since filenames in UNIX can legally contain newlines. This also handles spaces in filenames (much more common) correctly.