From owner-freebsd-questions Fri Mar 8 20: 6: 8 2002 Delivered-To: freebsd-questions@freebsd.org Received: from roc-66-66-72-6.rochester.rr.com (roc-66-66-72-6.rochester.rr.com [66.66.72.6]) by hub.freebsd.org (Postfix) with ESMTP id 57F9037B404 for ; Fri, 8 Mar 2002 20:06:01 -0800 (PST) Received: by roc-66-66-72-6.rochester.rr.com (Postfix, from userid 1000) id 66F38901A22; Fri, 8 Mar 2002 23:05:19 -0500 (EST) Date: Fri, 8 Mar 2002 23:05:19 -0500 From: mpd To: Peter Leftwich Cc: questions@freebsd.org Subject: Re: grep.... recursive searching Message-ID: <20020308230519.A4253@rochester.rr.com> References: <20020307105721.A46199@rochester.rr.com> <20020308215110.H68770-100000@earl-grey.cloud9.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020308215110.H68770-100000@earl-grey.cloud9.net>; from Hostmaster@Video2Video.Com on Fri, Mar 08, 2002 at 10:01:43PM -0500 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 Fri, Mar 08, 2002 at 10:01:43PM -0500, Peter Leftwich wrote: > 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.) That's exactly what I don't want to do. It's already been done, so there's no need to re-invent the wheel. Code re-use == the bomb. > > 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. Er, yeah. I've been scripting for years... > > 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 Why not just an alias rather than a full blown script? > > > It's written in perl, but I can't find a copy anywhere right now. Will keep looking. > > 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. I followed up to the list a few days ago, but I didn't have the thread context in the reply. The rgrep I was searching for is installed as part of the jed port. > > -- > Peter Leftwich mike -- ___________________________________________________________ Little Girl: "MAY I GROW 3005 PLANTS??" Pokey the Penguin: "NO" - from "3005 PLANTS" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message