On Sun, 8 Jun 2008 16:07:12 -0700, Bill Campbell <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 09, 2008, Raphael Becker wrote:
>>On Sun, Jun 08, 2008 at 10:15:50PM +0200, Wojciech Puchar wrote:
>>> find . -type f -print0|xargs -0 grep <grepoptions> <text to search>
>>
>>There's no more need for find | xargs
>>
>>Try:
>>
>>find . -type -f -exec grep <grepoptions> <text to search> {} \+
>>
>>-exec foo {} \+ behaves like xargs foo
>>-exec foo {} \; exec foo for every file
>
> The issue here is that grep execs grep for each file found while
> xargs batches the files.

The \+ trick behaves like xargs, so this shouldn't be an issue :)

> This is of particular importance if one wants to see the file
> names in the output.

You can ensure the same even if xargs picks up a single file to grep
with

    xargs -0 grep pattern /dev/null

This will cost an open() / read() pair for each batch of files, but it
ensures that grep will always see at least two file names, and it should
print the filename of any matching files.

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to