[NBLUG/talk] Searching for an expression within all files

Ross Thomas boscorama at fastmail.us
Mon Jan 17 11:29:16 PST 2005


Hi Todd,

On Mon, 17 Jan 2005 10:56:56 -0800, "Todd Cary"
<todd at aristesoftware.com> said:
> 
> I came across this command and I am not sure of the diferences:
> 
> # grep -r interbase.so /etc/*

For all intents and purposes under Linux, or with GNU grep, none.
However, find does give you more control over what you search,
e..g. only .c or .h files:
     find . -name '*.[ch]' -print0  | xargs grep "some var name"

Out of habit I use the find version as I work on many *nix systems
some of which don't have the '-r' option for grep.  :-(

It's also the case that recursion within a command is more of an
exception than a rule, so use of the find/xargs pairing tends to
occur much more often for me.  Trying to remember whether a
command has integrated recursion on a particular system/OS is
just not something I try to do.

I'll get off my soap-box now.  :-)

Ross.




More information about the talk mailing list