This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Broken since 1.3.10, or earlier

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. --

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]