Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: Look! An xargs!! (Re: recursive grep) Message-ID: <1122@virtech.UUCP> Date: 3 Sep 89 15:23:30 GMT References: <666@lakart.UUCP> <1641@cbnewsl.ATT.COM> <7774@cbmvax.UUCP> <4026@buengc.BU.EDU> Organization: Virtual Technologies Inc Lines: 32 In article <4026@buengc.BU.EDU>, bph@buengc.BU.EDU (Blair P. Houghton) writes: > Okay, kids. Shell script 101 is now in session. > > Try this, after putting it in a file and turning on the execute flag. > > while read arrrrg > do > $* $arrrrg > done > The reason why xargs was suggested was so the following type of operation could be executed without fork/execing a grep for every file. find . [args] -print -exec grep [RE] {} ";" Xargs will use the following structure AND process as many files as it can in a single iteration: find . [args] -print | xargs grep [RE] So your solution would be somewhat less effecient than using the find to exec the grep itself, since you would require a pipe, a shell, and then the fork/exec FOR every file. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+