[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep -R "include" *.c --- not working
From: |
Bob Proulx |
Subject: |
Re: grep -R "include" *.c --- not working |
Date: |
Mon, 4 Oct 2004 10:17:13 -0600 |
User-agent: |
Mutt/1.3.28i |
Stepan Kasal wrote:
> since you already use two GNU-specific features (-r and -0 in xargs), you
> could as well adopt another one:
>
> find . -name '*.c' -print0 | xargs -r0 grep -H include
> or
> find . -name '*.c' -print0 | xargs -r0 grep --with-filename include
Yes, I think your way here is best. Since I am using the short -r
option the short -H follows naturally. You have converted me.
I am always wanting to say the following. This will work way back on
virtually any system. This is old classic way of doing it.
find . -name '*.c' -print | xargs grep 'some_pattern' /dev/null
That works fine for the unix user who would never create files with
spaces or newlines in them. But so many people are learning it coming
from other systems where crazy things like that are normal that I just
feel compelled to use -print0 to avoid those problems. The -print0 is
the Right Thing to do and solves all of those problems nicely.
> The solution with /dev/null is a kludge.
I personally find it clever. But I would rather see the option in a
standard to be used by all. Oh well. GNU is not unix, after all. It
is better.
Bob