4
In question [ Find and delete all the directories named "test" in linux ] on this site, the best answer talks about using these two commands:
find . -name test -type d -print0|xargs -0 rm -r --
find . -name test -type d -exec rm -r {} +
because they will call rm with a list of directory instead of invoking it many times individually.
Since I cannot comment there due to low reputation, I ask here in a new question:
Is there any limit on the number of files that can be passed to rm using these techniques (aside from realistic system resource bounds)?
From the shell, a command like 'rm *' can exceed the shell's maximum command-line length, but do limits like that apply to this usage of find + or via a pipe to xargs?
Using the + in find's -exec will cause it to pass a list rather than invoke rm for each file. It seems to pass ~128k of filenames at a time, so it apparently has similar logic to xargs. Thank you for pointing out that option to xargs! – simpleuser – 2014-04-02T22:45:24.937
Thank you for clarifying. I always use find with the
-exec rm {} \;
option. – mtak – 2014-04-02T22:46:35.597I did too, and it's slow when deleting thousands of files, so I want to start using the + but was worried about it. Your answer about xargs made me think to write a test.pl to use instead of calling 'rm', which reported the number of args and their length -- so I could verify it behaved intelligently like xargs. – simpleuser – 2014-04-02T22:51:19.067