<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Article 3334 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:3334
Newsgroups: comp.lang.perl
Path: feenix.metronet.com!news.ecn.bgu.edu!wupost!spool.mu.edu!sgiblab!adagio.panasonic.com!chorus.mei!oskgate0.mei!wnoc-kyo!sh.wide!wnoc-tyo-news!sranha!sranhd!sran230!utashiro
From: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
Subject: Re: Directory Grep??
References: &lt;1993Jun10.143017.25932@rtsg.mot.com&gt;
Organization: Software Research Associates, Inc., Japan
Date: Fri, 11 Jun 1993 02:06:22 GMT
Message-ID: &lt;C8Fpuo.A47@sran230.sra.co.jp&gt;
Lines: 70

In article &lt;1993Jun10.143017.25932@rtsg.mot.com&gt;
	ellis@rtsg.mot.com (John T Ellis) writes:
&gt;&gt; Has anyone implemented a directory grep in perl?  My ideal
&gt;&gt; view of the tool includes -
&gt;&gt; 
&gt;&gt; 	- Ability to handle multiple (controlled by an option ie. -l)
&gt;&gt; 	  levels of directories
&gt;&gt; 
&gt;&gt; 	- Ability to handle multiple (controlled by an option ie. -s)
&gt;&gt; 	  levels of symbolic links
&gt;&gt; 
&gt;&gt; 	- Ability to exclude certain directories from being searched
&gt;&gt; 	  (-i ??)
&gt;&gt; 
&gt;&gt; 	- Ability to accept wildcards in the file specification
&gt;&gt; 
&gt;&gt; 	- Ability to designate starting directory (-d ??)
&gt;&gt; 
&gt;&gt; Therefore, to do a directory search for the word 'perl' starting in /usr/lib,
&gt;&gt; descending 3 sub-directory levels, allowing only 2 levels of symbolic links,
&gt;&gt; and not searching the any directory named 'tmp' you would do the following:
&gt;&gt; 
&gt;&gt; 	dgrep -l 3 -s 2 -i 'tmp' -d /usr/lib perl*
&gt;&gt; 
&gt;&gt; Does something like this (or any other variation thereof) exist?

My mg supports some of them.  Here is directory related
options list.

usage: mg [ -options ] pattern [ file... ]
	...
	-R          search recursively
	-P pattern  specify search file in wildcard (w/-R)
	-V pattern  specify exception file in wildcard (w/-R)
	-F          follow symbolic link of directory (w/-R)
	...

You can use it like this.

	mg -RV tmp perl /usr/lib

This morning, I added an option to specify descending
directory level in one minute and it seems to work pretty
well.  So I included it as a feature but the interface may
change in the near future.  Currently, you can use it like
this.

	mg -RV tmp -D3 perl /usr/lib

There is no option to handle levels of symbolic link.
Option -F specifies follow directory symlink or not, but
symlink for a file is always followed.

MG is available from

	srawgw.sra.co.jp:pub/lang/perl/sra-scripts

I'm thinking to post again it here because it has been
improved much after last posting.  Does anybody want it?

;# EXAMPLES:
;#	% mg 'control message protocol' rfc*.txt.Z	# line across search
;#	% mg -nRTP '*.[sch]' 'struct vnode' /sys	# recursive search
;#	% mg -o sockaddr /usr/include/sys/socket.h	# paragraph mode
;#	% mg -Bc0,1 '@(#)' /lib/libc.a			# binary mode
;#	% mg -iTB copyright /bin/*			# auto bin/text mode
;#	% tset -IQS | mg -ec0 '(so|se)=[^:]+'		# matched part only
;#	% echo $path | mg -Q mh				# highlighting

--utashiro


</pre></body></html>