From owner-freebsd-questions Sat Jul 13 13:21:57 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA09064 for questions-outgoing; Sat, 13 Jul 1996 13:21:57 -0700 (PDT) Received: from tenet.CS.Berkeley.EDU (root@tenet.CS.Berkeley.EDU [128.32.33.109]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id NAA09058 for ; Sat, 13 Jul 1996 13:21:54 -0700 (PDT) Received: from conviction.CS.Berkeley.EDU (conviction.CS.Berkeley.EDU [128.32.33.103]) by tenet.CS.Berkeley.EDU (8.6.11/8.6.6) with ESMTP id NAA26833; Sat, 13 Jul 1996 13:21:54 -0700 Received: from conviction.CS.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by conviction.CS.Berkeley.EDU (8.6.11/1.3-tenet) with ESMTP id NAA16168; Sat, 13 Jul 1996 13:21:51 -0700 Message-Id: <199607132021.NAA16168@conviction.CS.Berkeley.EDU> X-Mailer: exmh version 1.6.7 5/3/96 To: tcg@ime.net cc: FreeBSD-Questions , bmah@cs.berkeley.edu Subject: Re: Recursive grep. In-reply-to: Your message of "Sat, 13 Jul 1996 14:47:11 EDT." <31E7EF2F.4258@ime.net> From: bmah@cs.berkeley.edu (Bruce A. Mah) Reply-to: bmah@cs.berkeley.edu X-Face: g~c`.{#4q0"(V*b#g[i~rXgm*w;:nMfz%_RZLma)UgGN&=j`5vXoU^@n5v4:OO)c["!w)nD/!!~e4Sj7LiT'6*wZ83454H""lb{CC%T37O!!'S$S&D}sem7I[A 2V%N&+ Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="===_0_Sat_Jul_13_13:19:49_PDT_1996" Date: Sat, 13 Jul 1996 13:21:51 -0700 Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk This is a multipart MIME message. --===_0_Sat_Jul_13_13:19:49_PDT_1996 Content-Type: text/plain; charset=us-ascii Gary Chrysler writes: > Could someone please show me an example using grep to search > through files in a tree. ie: recursivly. > > I've read the grep man page, No luck, Tried piping various things > into grep without success! Gary-- I've used the following script for awhile. Ugly as sin, but it gets the job done (run it at the top of the tree you want to recursive grep through). Hope this helps... Bruce. --===_0_Sat_Jul_13_13:19:49_PDT_1996 Content-Type: application/x-script Content-Description: rgrep #!/bin/csh -f # $Id: rgrep,v 1.1 1992/07/04 18:34:15 bmah Exp bmah $ # # $Header: /db/users/bmah/bin/RCS/rgrep,v 1.1 1992/07/04 18:34:15 bmah Exp bmah $ # # rgrep # Bruce A. Mah (bmah@tenet.berkeley.edu) # # Recursive grep. # # $Log: rgrep,v $ # Revision 1.1 1992/07/04 18:34:15 bmah # rgrep won't try to grep directories now. # # Revision 1.0 1992/07/02 19:10:04 bmah # Initial revision # # if ($#argv == 2) then set noglob find . \! -type d -name $2 -exec grep $1 {} /dev/null ";" unset noglob else if ($#argv == 1) then set noglob find . \! -type d -exec grep $1 {} /dev/null ";" unset noglob else echo "usage: rgrep {target}" echo " rgrep {target} {filespec}" endif --===_0_Sat_Jul_13_13:19:49_PDT_1996--