Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

find -exec is almost always faster and more secure than xargs.


It is my understanding that -exec is almost always slower, since it generally needs to invoke whatever program you are using many many times more.


Whereas 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.


I'd like to hear some justification, cites, or examples for either of these assertions.


I 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-x... http://www.gnu.org/software/findutils/manual/html_node/find_...


Does find have an equivalent for xargs "-P max" flag?


You 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: