Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!att!cbnewsl!ams From: ams@cbnewsl.ATT.COM (andrew.m.shaw) Newsgroups: comp.unix.wizards Subject: Re: recursive grep Message-ID: <1641@cbnewsl.ATT.COM> Date: 26 Aug 89 21:05:27 GMT References: <666@lakart.UUCP> Reply-To: ams@cbnewsl.ATT.COM (andrew.m.shaw,580,) Organization: AT&T Bell Laboratories Lines: 30 In article <666@lakart.UUCP> dg@lakart.UUCP (David Goodenough) writes: >steve@polyslo.CalPoly.EDU (Steve DeJarnett) sez: >> 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 {} \; > >Simple. The first does one exec per directory, the second does one exec per >file. I agree with Mr. Turnbow that it is extremely obnoxious behaviour >on the part of find. The only way I can see to do it is to do some real >funky work with awk, maybe: > > find . -type d -print | awk '{ print "grep string " $0 "/*" }' | sh > >But then I use awk for most everything, no matter how ugly :-) Since my previous posting may have gotten lost, I resend that I recommend the following: find . -type f -print | xargs fgrep string Neat and clean. Andrew Shaw