Newsgroups: comp.unix.questions Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Subject: Re: grep Message-ID: <1991Apr15.175038.8660@athena.mit.edu> Keywords: grep, recursive Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology References: <1991Apr14.214414.9815@hellgate.utah.edu> <1991Apr15.042100.11727@aplcen.apl.jhu.edu> Date: Mon, 15 Apr 91 17:50:38 GMT Lines: 26 In article <1991Apr15.042100.11727@aplcen.apl.jhu.edu>, akbloom@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710