On 05/13/2010 12:47 PM, m.roth@5-cent.us wrote:
Gordon wrote:
Find it harder: find /etc/ -type f -print0 | xargs -0 grep "ip rule"
Or, since modern find's default to -print,
Yes, they do, but I have no idea what that has to do with your suggestion to use -exec. If you had suggested eliminating the use of -print as redundant, your suggestion would be merely inefficient rather than a non sequitur.
you could do find /etc -type f -exec grep -l "ip rule" {} ;
You could, but that would run "grep" once for each file where xargs will run grep the minimum number of times. Using xargs is substantially faster.
Having said that, I see that find has an option of which I was previously unaware. If you use the '+' character instead of the ';', it will behave more or less the same way that xargs does:
find /etc/ -type f -exec grep "ip rule" {} +