[96464] in RedHat Linux List
Re: Newbie: Searching sub directories for text
daemon@ATHENA.MIT.EDU (Thomas Ribbrock \(Design/DEG\))
Tue Oct 27 08:34:04 1998
Date: Tue, 27 Oct 1998 13:33:25 +0000
From: "Thomas Ribbrock \(Design/DEG\)" <argathin@INAME.COM>
To: redhat-list@redhat.com
Mail-Followup-To: redhat-list@redhat.com
In-Reply-To: <3.0.5.32.19981027131343.007e9eb0@fmol.5sigcmd.army.mil>; from Anthony E. Greene on Tue, Oct 27, 1998 at 01:13:43PM +0100
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
Anthony E. Greene writes:
>
> It seems to me that just using rgrep (as mentioned in another post) would
> be simpler and faster than running find and executing grep each time a
> mathcing file is found.
dsun178:userfriendly 37> rgrep
rgrep: Command not found.
dsun178:userfriendly 38>
Ok, I admit it - it's a Sun Sparc Solaris system. But rgrep is less common
than the find/grep combination (at least to my knowledge), so it's nice to
know about that combination as well.
BTW: Does anybody know where rgrep can be found (preferably as tar.gz)? Is
it just another GNU tools?
Until now, I was using this:
#!/bin/sh
# gref - Recursively greps down a directory tree.
# If no path is specified, default is working directory.
#
# NOTE: Some shells require the variables in the "if"
# statements be quoted.
mask=\\*
if [ "$#" = "1" ]
then
dir=.
else
if [ "$#" = "2" ]
then
dir=$2
else
if [ "$#" = "3" ]
then
dir=$2
mask=$3
else
echo "Usage: `basename $0` pattern [path [mask]]"
exit 1
fi
fi
fi
eval find $dir -name $mask -print | xargs egrep -n "$1" 2>/dev/null
Basically find/grep plus some extra comfort... ;-)
Thomas
--
"Look, ma, no obsolete quotes!"
Thomas Ribbrock | http://www.bigfoot.com/~kaytan | ICQ#: 15839919
"You have to live on the edge of reality - to make your dreams come true!"
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.