From owner-freebsd-questions@FreeBSD.ORG Sun Jun 8 23:07:16 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 3AA061065671 for ; Sun, 8 Jun 2008 23:07:16 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from ayn.mi.celestial.com (hayek.celestial.com [192.136.111.12]) by mx1.freebsd.org (Postfix) with ESMTP id DA1DA8FC19 for ; Sun, 8 Jun 2008 23:07:15 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from localhost (localhost [127.0.0.1]) by ayn.mi.celestial.com (Postfix) with ESMTP id E3EB568610B54; Sun, 8 Jun 2008 16:07:12 -0700 (PDT) X-Virus-Scanned: amavisd-new at mi.celestial.com Received: from ayn.mi.celestial.com ([127.0.0.1]) by localhost (ayn.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id DkYOu+2lqD9f; Sun, 8 Jun 2008 16:07:12 -0700 (PDT) Received: by ayn.mi.celestial.com (Postfix, from userid 203) id C1E556800E985; Sun, 8 Jun 2008 16:07:12 -0700 (PDT) Date: Sun, 8 Jun 2008 16:07:12 -0700 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20080608230712.GA24307@ayn.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <484C3CC4.7050107@webrz.net> <20080608221328.U9955@wojtek.tensor.gdynia.pl> <20080608225023.GD54922@ma.sigsys.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080608225023.GD54922@ma.sigsys.de> User-Agent: Mutt/1.5.11 OpenPKG/2.5 Subject: Re: Grep Guru X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@celestial.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jun 2008 23:07:16 -0000 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 The issue here is that grep execs grep for each file found while xargs batches the files. This is of particular importance if one wants to see the file names in the output. In relation to this, if one wants to be sure that grep always generates the file name, insure that it always gets at least two files as arguments: find . -type f -print0 | xargs -0 grep pattern /dev/null FWIW, I have learned about gnu-grep's -r option reading this thread, which I had not noticed previously. I guess that just goes to show that old habits die hard :-). Bill -- INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax: (206) 232-9186 Good luck to all you optimists out there who think Microsoft can deliver 35 million lines of quality code on which you can operate your business. -- John C. Dvorak