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
    do
        case "$opt" in
        i) case="-i " ;;
        *) echo "$usage"; return;;
        esac
    done
    shift $(( $OPTIND - 1 ))
    if [ "$#" -lt 1 ]; then
        echo "$usage"
        return;
    fi
    local SMSO=$(tput smso)
    local RMSO=$(tput rmso)
    find . -type f -name "${2:-*}" -print0 | xargs -0 grep -sn ${case} "$1" 
2>&- | sed "s/$1/${SMSO}\0${RMSO}/gI" | more
}

... comes with the lot, even highlighting.

;-)


Jobst













On Fri, Nov 14, 2008 at 07:14:22PM +1100, [EMAIL PROTECTED] ([EMAIL PROTECTED]) 
wrote:
> Is there a command that finds a file containing a certain word?
> 
> find and apropos don't. They work on filenames only.
> 
> Using Hardy H.
> 
> Any suggestions gratefully etc.
> 
> Bill Bennett
> -- 
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

-- 
When you lose, don't lose the lesson.

  | |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