grep annoyance!
Alex LeDonne
plug-devel@lists.PLUG.phoenix.az.us
Fri Apr 15 13:24:02 2005
> > I don't know if there is an option for grep ... it would be nice
> ... but
> > you can use find's -exec feature in conjunction with grep like
> this:
> >
> >
> > find . -iname "*.c" -exec grep include {} \;
> >
> > It will search below the current directory for any file ending in
> .c or
> > .C and grep anything it finds for the string "include".
>
> What I dislike about that method is that it doesn't include the
> filename
> of where it found the text. I tend to use:
>
> find . -name "*.c" | xargs grep include
>
> --Ted
To use "pure" find and still get filenames:
find . -iname "*.c" -exec grep include /dev/null {} \;
This way grep has 2 file arguments each time through, so it displays
the filename of the match. And grep against /dev/null doesn't add much
time to the process.
-A
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/