Well I'm not a perl fanatic, but I prefer to type less if possible.  On my
machine I can't tell the difference in run time between mfind and a find
command.

mfind -v '<string>'
is much simpler than

find <top-directory-name> -type f -exec grep '<string>' {} \; -print

or

find . -type f  | xargs grep '<string>'

The advantage of the perl script is the output can be further refined by piping
to grep.

For example:

mfind -v class | grep -n public

Will locate and print out
    filename, linenumber and string for every occurrance of   class AND public
on the same line.
    and won't look through files that aren't of type TEXT.



That's what I used before I learned perl.
regs,
-jrp

"W.H. Dekker" wrote:

> Ralph Clark wrote:
>
> > Honestly! You perl fanatics would write a perl script to do
> > anything. There is no need for this really, it can be done with
> > standard unix commands. Just pick one of the following:
> >
> > To print out all the matching lines themselves:
> >
> > 1) find <top-directory-name> -type f -exec grep '<string>' {} \;
> >
> > To print out the names of all the files which contained a matching string:
> >
> > 2) find <top-directory-name> -type f -exec grep -q '<string>' {} \; -print
> > or
> > 3) find <top-directory-name> -type f -exec grep -l '<string>' {} \;
> >
> > To print out both (with the file's name appearing _after_ each list
> > of matching strings)
> >
> > 4) find <top-directory-name> -type f -exec grep '<string>' {} \; -print
> >
> > I do this all the time. It might be interesting to compare memory
> > usage, CPU utilisation and execution time of these methods vs. the
> > above perl script.
>
> OK. First of all: find -f sees ELF binaries, .dvi- files etcetera,
> which you don't want to scan with grep-like programs. They can mess up
> your screen.
>
> Then:
> 1) does not show filenames at all,
> 2) and 3) work fine (except for the binaries) if you just want the filenames
> 4) shows the filenames at the end, which is not what you want because
>    the output if difficult to parse.  Even worse: you get the name on a
>    separate line, and only after the last matching line.
>
> Finally: speed and memory usage:
>
> Your command 4): elap 1.104 user 0.600 syst 0.500 CPU 99.65
> My script:       elap 0.296 user 0.260 syst 0.030 CPU 97.82
>
> Yes, you are slower, because you start a process for every file you
> find. Which is also why you use more memory.
>
> Its your turn!! I hope you'll also become a Perl fanatic, sometime.
> --
> Hartelijke groet, Wybo Dekker
> ___________________Servalys Analytical Chemistry Services__________________
> [EMAIL PROTECTED] | Deilsedijk 60                 | tel +31-345-652164
> www.hobby.nl/~servalys | 4158 CH Deil, The Netherlands | fax +31-345-652383
> -
> To get out of this list, please send email to [EMAIL PROTECTED] with
> this text in its body: unsubscribe suse-linux-e
> Check out the SuSE-FAQ at http://www.suse.com/Support/Doku/FAQ/ and the
> archiv at http://www.suse.com/Mailinglists/suse-linux-e/index.html

-
To get out of this list, please send email to [EMAIL PROTECTED] with
this text in its body: unsubscribe suse-linux-e
Check out the SuSE-FAQ at http://www.suse.com/Support/Doku/FAQ/ and the
archiv at http://www.suse.com/Mailinglists/suse-linux-e/index.html

Reply via email to