This is the mail archive of the
mailing list for the Cygwin project.
Re: Broken since 1.3.10, or earlier
On Tue, Jul 16, 2002 at 06:31:53PM -0500, Dan Higgins wrote:
> If I want to recursively find all files that contain some text, I use, for
> find . -name '*.java' | while read l; do grep 'Copyright' "$l" && echo "$l";
> 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.
firstname.lastname@example.org -- http://www.helixdigital.com
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html