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

With gnu tools, at least, xargs has a "-0" option to go hand in hand with gnu find's "-print0" option which obviates the spaces problem.

xargs is "better" in that it spawns 1 new process for however many things are found. -exec spawns 1 new process for EVERY thing found.

So:

    find . -name '*.log' -exec rm {} \;
spawns an rm for every log file.

    find . -name '*.log' -print0 | xargs -0 rm
spawns 1 rm for MANY log files. (Yes, I know zsh can do stuff like this too.)

xargs also has options to limit command line length or # of items if you want to limit that. find -exec is about the same then as find ... | xargs -n1



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

Search: