From owner-freebsd-questions@FreeBSD.ORG Wed Jun 11 14:11:03 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C6BB106567E for ; Wed, 11 Jun 2008 14:11:03 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from gaia.nimnet.asn.au (nimbin.lnk.telstra.net [139.130.45.143]) by mx1.freebsd.org (Postfix) with ESMTP id CB6038FC21 for ; Wed, 11 Jun 2008 14:11:00 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (smithi@localhost) by gaia.nimnet.asn.au (8.8.8/8.8.8R1.5) with SMTP id AAA06769; Thu, 12 Jun 2008 00:10:27 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Thu, 12 Jun 2008 00:10:25 +1000 (EST) From: Ian Smith To: Giorgos Keramidas In-Reply-To: <87y75efmvg.fsf@kobe.laptop> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Bill Campbell , freebsd-questions@freebsd.org, Raphael Becker Subject: Re: Grep Guru X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jun 2008 14:11:03 -0000 On Mon, 9 Jun 2008, Giorgos Keramidas wrote: > On Tue, 10 Jun 2008 01:44:36 +1000 (EST), Ian Smith wrote: > >On Sun, 8 Jun 2008 16:07:12 -0700 Bill Campbell 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 > >>> > >>> There's no more need for find | xargs > >>> > >>> Try: > >>> > >>> find . -type -f -exec grep {} \+ > >>> > >>> -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