Grep Guru
Ian Smith
smithi at nimnet.asn.au
Wed Jun 11 14:11:03 UTC 2008
On Mon, 9 Jun 2008, Giorgos Keramidas wrote:
> On Tue, 10 Jun 2008 01:44:36 +1000 (EST), Ian Smith <smithi at nimnet.asn.au> wrote:
> >On Sun, 8 Jun 2008 16:07:12 -0700 Bill Campbell <freebsd at celestial.com> 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
> >
> > Thanks for this kick; I'd missed or misunderstood using {} \+
> >
> >> The issue here is that grep execs grep for each file found while
> >> xargs batches the files.
> >
> > If find(1) is to be believed, so does -exec utility [argument ...] {} +
>
> Yes, sure. I think Bill was just being extra-conservative[1] and he
> explicitly chose to quote `+' with a backslash to avoid spurious
> interpreration by the shell. I also type `\+' out of habbit most
> of the time.
It doesn't hurt. My tests used \+ too, though after seeing yours I
tried with just '+' which works in tcsh anyway, unlike unescaped ';'
(It was Raphael actually, though I was replying to Bill's)
> [1] BSD users tend to be this way, but that's a good thing, right? :)
Right! Of course for balance we have a 'left!' of out-there developers,
forever pushing envelopes, generating need for updates .. but we'd best
leave the stability vs progress politics to its playground on stable@ :)
cheers, Ian
More information about the freebsd-questions
mailing list