Date: Thu, 12 Jun 2008 00:10:25 +1000 (EST) From: Ian Smith <smithi@nimnet.asn.au> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: Bill Campbell <freebsd@celestial.com>, freebsd-questions@freebsd.org, Raphael Becker <rabe@uugrn.org> Subject: Re: Grep Guru Message-ID: <Pine.BSF.3.96.1080611232032.18537E-100000@gaia.nimnet.asn.au> In-Reply-To: <87y75efmvg.fsf@kobe.laptop>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 9 Jun 2008, Giorgos Keramidas wrote: > On Tue, 10 Jun 2008 01:44:36 +1000 (EST), Ian Smith <smithi@nimnet.asn.au> wrote: > >On Sun, 8 Jun 2008 16:07:12 -0700 Bill Campbell <freebsd@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.1080611232032.18537E-100000>