3 ms·
find -exec is almost always faster and more secure than xargs.
by planckscnst 15y ago
find -exec is almost always faster and more secure than xargs.
- e1ven 15y agoWhereas I almost always use for i in `find . -name foo`; do mv $i $i-new; done That's very straightforward, and gets the job done without much weirdness.
- burgerbrain 15y agoIt is my understanding that -exec is almost always slower, since it generally needs to invoke whatever program you are using many many times more.
- fluidcruft 15y agoDoes find have an equivalent for xargs "-P max" flag?
- tange 15y agoYou can emulate it with sem: find . -exec sem --id my_find -j3 sleep 4\; echo {} \; See more about sem: http://www.gnu.org/software/parallel/sem.html http://www.gnu.org/software/parallel/sem.html
- michaelcampbell 15y agoI'd like to hear some justification, cites, or examples for either of these assertions.
- planckscnst 15y agoI was mis-remembering the "faster" part. It is slower unless you have a version that supports the "-exec {} +" option. However, for security and robustness, see this: http://stackoverflow.com/questions/896808/find-exec-cmd-vs-xargs http://stackoverflow.com/questions/896808/find-exec-cmd-vs-x... http://www.gnu.org/software/findutils/manual/html_node/find_html/Security-Considerations-for-xargs.html http://www.gnu.org/software/findutils/manual/html_node/find_...