recursive grep
David Elliott
dce at Solbourne.COM
Wed Aug 23 08:47:26 AEST 1989
In article <13710 at polyslo.CalPoly.EDU> steve at polyslo.CalPoly.EDU (Steve DeJarnett) writes:
>In article <122979 at sun.Eng.Sun.COM> williamt at sun.UUCP (William A. Turnbow) writes:
>>Here is a short quicky (I hope). I am trying to do the following:
>>
>>find . -type d -exec grep string {}/* \;
>
> If you're trying to grep for a string in every file in or below the
>current directory, why not do this:
>
> find . -type f -exec grep string {} \;
A closer solution is
find . -type f -exec grep string {} /dev/null \;
This will force grep to print the filename. Even better is
find . -type f -print | xargs grep string /dev/null
if you have xargs. xargs will run
grep string /dev/null {filenames}
for sets of file names read from stdin. The result is far fewer
forks and execs of grep, so you get the results much quicker.
> I suspect that find "sees" the /* after the braces, and presumes
>that you mustn't really want it to expand the filename there. I've never
>known find to need a space between the braces, but, then, that certainly
>doesn't mean that it never would expect that. :-)
Actually, find just looks specifically for {} as an argument. I've
always thought find should expand {} in any part of an argument, but
that's probably because I wanted it to do that when I first started
using it.
--
David Elliott dce at Solbourne.COM
...!{uunet,boulder,nbires,sun}!stan!dce
"I had a dream that my kids had been reparented." - Tom LaStrange
More information about the Comp.unix.wizards
mailing list