Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!deccrl!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!nikhefh!a20 From: a20@nikhefh.nikhef.nl (Marten Terpstra) Newsgroups: comp.unix.questions Subject: Re: grep Keywords: grep, recursive Message-ID: <1207@nikhefh.nikhef.nl> Date: 15 Apr 91 12:46:19 GMT References: <1991Apr14.214414.9815@hellgate.utah.edu> Sender: terpstra@nikhef.nl (Marten Terpstra) Reply-To: a20@nikhefh.nikhef.nl (Marten Terpstra) Organization: Nikhef-H, Amsterdam (the Netherlands). Lines: 34 mmoore%hellgate.utah.edu@cs.utah.edu (Michael Moore) writes: > Does anyone know if there is an easy way to recursively search for a >pattern down the entire file tree of a directory? A recursive version of grep has been discussed several times on the net. One of the solutions, and quite workable for me, is the following shell script : -- Start of script -- #! /bin/sh # Recgrep : a version of grep which recursively searches every directory and # file starting in the current directory. # # Usage: recgrep pattern if (test $# -lt 1) then echo "Usage: recgrep pattern" else find . -type f -exec grep $1 {} /dev/null \; fi -- End of script -- This will start in your current directory and recursively walk down all other dirs looking for you pattern. I know there are many other variations, that may work even better, but this one works just fine for me. -Marten -- Marten Terpstra National Institute for Nuclear Internet : terpstra@nikhef.nl and High Energy Physics Oldie-net: {....}mcsun!nikhefh!terpstra (NIKHEF-H), PO Box 41882, 1009 DB Phone : +31 20 592 5102 Amsterdam, The Netherlands