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

> find does print to stdout by default. Perhaps -print was

> added later to distinguish the default mode from -print0,

> which is common when pairing with xargs.

  find ... -print0 | xargs -0 $cmd 
is essential if you don't want all sorts of terrible things happening because a filename happens to contain a space or some sort of shell metachar.

See http://en.wikipedia.org/wiki/Xargs#The_separator_problem for the details.

Personally, I use

  find ... -exec $cmd '{}' \; # calls $cmd once for each match

  find ... -exec $cmd '{}' + # calls $cmd with as matches as possible - minimising number of invocations of $cmd.
I think this is either reasonably new, or not entirely standard, since I've used versions that don't have it.

  -ok $cmd \;
is also pretty neat - same as exec, but asks for confirmation first.


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

Search: