GalerieBlogUnity3D ExamplesKontaktSitemapFullsitemap

recusive grep in files

sometimes I need to grep for NEEDLE in all files.

Here is the short script:


#!/bin/sh
# implements: 
# grep -r -n -H -B 1 -A 1 NEEDLE --exclude="*.svn*" --exclude=EXCLUDEPATTERN .

NAME=`basename $0`
function usage() {
    echo $NAME NEEDLE [EXCLUDEPATTERN]
}

if [ $2 ]; then
    grep -r -n -H -B 1 -A 1 $1 --exclude="*.svn*" --exclude=$2 .
elif [ $1 ]; then
    grep -r -n -H -B 1 -A 1 $1 --exclude="*.svn*" .
else
    usage
fi

Kommentare (1)  Permalink

Kommentare

Patrice @ 05.12.2008 16:40 UTC
You hould use http://petdance.com/ack/ instead. :-)
Keine (weiteren) neuen Kommentare erlaubt.