Hi.

I beg to differ.

 1: its quicker to type "fstr HTML '*.php'"

 2: less (and more) kill the highlighting done by grep

 3: grep has to (internally) call the other processes to to the same I am 
already doing with pipes

 4: (overly pedantic): can do more with find grep can ever do and I can decide 
the order of my pipes and WHAT I want to do.


Jobst




On Mon, Nov 17, 2008 at 03:49:22PM +1100, Amos Shapira ([EMAIL PROTECTED]) 
wrote:
> 2008/11/17 Jobst Schmalenbach <[EMAIL PROTECTED]>:
> >
> > Put this into your .bashrc file:
> >
> > function fstr()
> > {
> >    OPTIND=1
> >    local case=" "
> >    local usage="fstr: find string in files.\nUsage: fstr [-i] \"pattern\" 
> > [\"filename pattern\"] "
> >    while getopts :it opt
> ...
> >  find . -type f -name "${2:-*}" -print0 | xargs -0 grep -sn ${case} "$1" 
> > 2>&- | sed "s/$1/${SMSO}\0${RMSO}/gI" | more
> 
> It's a nice excercise in bash scripting but quiet redundant with
> today's GNU grep:
> -R/-r/--recursive will replace the "find"
> --include=pattern will replace find's "-name ..." (though many times I
> use "--exclude \*.svn-base" to skip SVN files)
> --colour will highlight the results
> 
> Less' -R/--RAW-CONTROl-CHARS will help page through the highlighted output.
> 
> So in the end you can achieve the same result with something like:
> 
> grep -r --colour pattern directory/ | less -R
> 
> --Amos
> -- 
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

-- 
Never share a foxhole with anyone braver than yourself.

  | |0| |   Jobst Schmalenbach, [EMAIL PROTECTED], General Manager
  | | |0|   Barrett Consulting Group P/L & The Meditation Room P/L
  |0|0|0|   +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to