Date: Fri, 8 Mar 2002 22:01:43 -0500 (EST) From: Peter Leftwich <Hostmaster@Video2Video.Com> To: mpd <mpd6334@cs.rit.edu> Cc: Barry Byrne <barry.byrne@wbtsystems.com>, FreeBSD Questions <FreeBSD-Questions@FreeBSD.Org> Subject: Re: grep.... recursive searching Message-ID: <20020308215110.H68770-100000@earl-grey.cloud9.net> In-Reply-To: <20020307105721.A46199@rochester.rr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020308215110.H68770-100000>