grep

Jonathan I. Kamens jik at athena.mit.edu
Tue Apr 16 03:50:38 AEST 1991


In article <1991Apr15.042100.11727 at aplcen.apl.jhu.edu>, akbloom at aplcen.apl.jhu.edu (Keith Bloom) writes:
|> find . -name '*' -print | xargs grep pattern

  1) The "-name '*'" is unnecessary.  If you're checking for any name, you
don't need to check the name at all.

  2) This will try to search directories and special files as well, something
that he probably doesn't want to do.  Replace "-name '*'" with "-type f".

|> If you have a huge directory tree with thousands of files in it, this
|> may not work.

  Why not?  The whole purpose of xargs is to take lots of arguments on
standard input and run the desired program on as many as possible in each
pass, running the program multiple times if necessary to get all of the
arguments processed.

|> find . -name '*' -print -exec grep pattern {} \;

  Once again, replace "-name '*'" with "-type f".

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list