4 ms·
Please, tell me you're jocking: on your platform you cannot afford a pipe but you can launch node.js? by the way: "-print0 | xars -0" is really idiomatic, you
by _ZeD_ 14y ago
Please, tell me you're jocking: on your platform you cannot afford a pipe but you can launch node.js?
by the way: "-print0 | xars -0" is really idiomatic, you know? Lucky you didn't have a single filename with spaces to handle...
- tptacek 14y agoI don't know what this even means. I'd already be running v8 runtimes. They're unavoidable. But there's no need to fork and exec (many times over) just to sweep a filesystem tree for files matching patterns. It's the shell, by the way, that cares about "spaces in filenames". Not dicking around with shell metacharacters is just one of the many wins you get by not shelling out to accomplish basic programming tasks.
- aidenn0 14y agoI get what you're saying for the "already in a REPL" thing, but as far as fork/exec overhead, xargs does a single fork/exec for every thousand or so files you search; the overhead is tiny compared to everything else.
- dvdkhlng 14y agoNot even that, but xargs can also be made to run N processes in parallel ('xargs -P N'), making a find|xargs sed pipe perform much better than anything you could easily invent on your own. Note that 'xargs -P' behaves very similar to 'make -j' and is often useful as a simple work-unit scheduler.
- mrb 14y ago"find -print0 | xargs -0" handles spaces in filenames perfectly correctly.
- andreasvc 14y agoThat's his point.