delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/16/20:12:58

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <alcocer AT helixdigital DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Broken since 1.3.10, or earlier
Message-ID: <20020716171119.A12289@ns.helixdigital.com>
References: <ACEIKCIGAEOGOHGPJPIACEBLCDAA DOT DanHiggins AT austin DOT rr DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.2.5.1i
In-Reply-To: <ACEIKCIGAEOGOHGPJPIACEBLCDAA.DanHiggins@austin.rr.com>; 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019