Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 16 Jul 2002 17:11:19 -0700 From: Dario Alcocer To: cygwin AT cygwin DOT com Subject: Re: Broken since 1.3.10, or earlier Message-ID: <20020716171119.A12289@ns.helixdigital.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from DanHiggins@austin.rr.com on Tue, Jul 16, 2002 at 06:31:53PM -0500 On Tue, Jul 16, 2002 at 06:31:53PM -0500, Dan Higgins wrote: > Greetings, > > If I want to recursively find all files that contain some text, I use, for > example: > > find . -name '*.java' | while read l; do grep 'Copyright' "$l" && echo "$l"; > done > > The output from this pipeline is inconsistent. Mostly I see bogus pathnames > that should not be there, or missing pathnames that should be there, or > duplicate lines from the grep, that sometimes even wind up overlapped by the > command prompt upon completion. > > 1. Don't suggest another syntax, unless it can handle paths with > spaces in it. Well, the following will handle spaces just fine: $ find . -name '*.java' -print0 | xargs -0 grep -l 'Copyright' This will actually be faster, since it will greatly minimize the number of fork/exec pairs (your command line does a grep for *each* file, whereas the find / xargs pipeline will do a *single* grep for a bunch of files.) BTW, this isn't really a Cygwin-specific question, rather a somewhat common Unix question. -- Dario Alcocer -- Sr. Software Developer, Helix Digital Inc. alcocer AT helixdigital DOT com -- http://www.helixdigital.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/