[Scottish] Best way to find text within files recursively?

Graeme Mathieson scottish at mailman.lug.org.uk
Sun Jan 19 23:28:01 2003


On Sun, Jan 19, 2003 at 11:19:08PM -0000, Michael Cameron wrote:
> >
> >find . -type f -print0 |xargs -0 grep 'foo'
> >
> I'd go for:
> 
> find . -type f -exec grep 'foo' {} /dev/null \;

See, that has two consequences.  grep is spawned once for every find
match (which, if you're running it on something slow and old is an
issue).  Also, since grep is only spawned with one filename, it will not
(iirc) issue the names of matching files in addition to the matching
line itself.  Of course, if that's a desired feature, you're sorted, but
in the original spec, I suspect it wasn't...
-- 
Right now, there are scr1pt k1dd13s plotting to DDoS my network, my co-lo
server is not responding  to pings and  the people that I IRC with may be
involved in both.  I'm  sysadmin Graeme Mathieson and this is the longest
day of my life.                       http://www.wossname.org.uk/~mathie/