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

Ross Thomas boscorama at fastmail.us
Fri Jan 14 17:09:44 PST 2005


On Fri, 14 Jan 2005 16:42:19 -0800, "Todd Cary"
<todd at aristesoftware.com> said:
> I want to seach for the expression within all files contained within
> /etc.
> 
> find /etc -type -f
> 
> That will give me all files.
> 
> fgrep "interbase.so" [files]
> 
> Will search within files, but I do not know how to feed the output of 
> "find" into "fgrep".

xargs is your friend, thusly:
    find /etc/ -type f | xargs grep "interbase.so"

Also, if you are on Linux or using the gnu versions of find & xargs,
use the '0' options (that's a zero) so that files with strange chars
in their names work.  Like this:
   find /etc -type f -print0 | xargs -0 grep "interbase.so"

HTH.

Ross.




More information about the talk mailing list