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