From owner-freebsd-questions Fri Mar 8 19: 2: 8 2002 Delivered-To: freebsd-questions@freebsd.org Received: from russian-caravan.cloud9.net (russian-caravan.cloud9.net [168.100.1.4]) by hub.freebsd.org (Postfix) with ESMTP id F1A1E37B400 for ; Fri, 8 Mar 2002 19:02:04 -0800 (PST) Received: from earl-grey.cloud9.net (earl-grey.cloud9.net [168.100.1.1]) by russian-caravan.cloud9.net (Postfix) with ESMTP id 9E87528B35; Fri, 8 Mar 2002 22:01:43 -0500 (EST) Date: Fri, 8 Mar 2002 22:01:43 -0500 (EST) From: Peter Leftwich X-X-Sender: To: mpd Cc: Barry Byrne , FreeBSD Questions Subject: Re: grep.... recursive searching In-Reply-To: <20020307105721.A46199@rochester.rr.com> Message-ID: <20020308215110.H68770-100000@earl-grey.cloud9.net> Organization: Video2Video Services - http://Www.Video2Video.Com MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 7 Mar 2002, mpd wrote: > On Thu, Mar 07, 2002 at 02:21:25PM +0000, Barry Byrne wrote: > > Mike: I think what you wish to to is use find to located certain files recursively and then grep these files for a specific pattern. If so, try something like: > > find /START/OF/PATH -name "FINDPATTERN" -exec grep "GREPPATTERN" {} \; > I know about this, but it's too much typing. I'm looking for functionality more like rgrep that comes with RH. Has anyone tried this on FreeBSD? This is the one thing I miss from using Linux. Hi mike, and thanks list (I've been using grep something *, grep something */*, and so on, for years and now feel like Dorothy of Oz!) You could write a very simple shell-script called rgrep.sh and then alias a command (depending on what shell you use in Unix) called rgrep. (Or just chmod 755 rgrep.sh and put it in a directory that is in your PATH.) Shell scripts begin with a single line like this: #!/bin/sh You can use if/else, case, and various test statements in shell scripts, and substitute (this may be tcsh-dependent) "$1" meaning "the thing typed on the command line after the command," in this example, rgrep expressionhere so $1 gets substituted for expressionhere. Shell scripting is useful -- I find -- to simplify very long commands that require you to escape certain punctuation and spaces by using the "force" *grins* OWKA "\" as in: $ grep -i an\ example\ using\ spaces ~/myfile.txt > It's written in perl, but I can't find a copy anywhere right now. Will keep looking. > > Cheers, > > Barry > mike If it is written in perl, then just make sure perl is installed on your system (find out by typing which perl, or just the word perl), and if so you are in luck to use the old script, provided it doesn't have any "exec" calls that clash with whichever shell you use or are using. -- Peter Leftwich President & Founder Video2Video Services Box 13692, La Jolla, CA, 92039 USA +1-413-403-9555 > > > I'm more curious of a way to make it recurse through all the directories, but only try to match on certain files. Is this even possible with this version of grep? The fm (of rtfm fame) isn't giving me any epiphanies. -mike > -- > ___________________________________________________________ > > "POKEY MAY I BUY A FIVE FOOT TALL CRIME FIGHTING ROBOT???" > - Little Girl from "REQUEST DENIED THEN GRANTED" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message