Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ncar!boulder!stan!dce From: dce@Solbourne.COM (David Elliott) Newsgroups: comp.unix.wizards Subject: Re: recursive grep Message-ID: <2055@marvin.Solbourne.COM> Date: 22 Aug 89 22:47:26 GMT References: <122979@sun.Eng.Sun.COM> <13710@polyslo.CalPoly.EDU> Reply-To: dce@Solbourne.com (David Elliott) Organization: Solbourne Computer Inc., Longmont, Colorado Lines: 41 In article <13710@polyslo.CalPoly.EDU> steve@polyslo.CalPoly.EDU (Steve DeJarnett) writes: >In article <122979@sun.Eng.Sun.COM> williamt@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@Solbourne.COM ...!{uunet,boulder,nbires,sun}!stan!dce "I had a dream that my kids had been reparented." - Tom LaStrange