#!/bin/sh # # $Id: findcustc 356 2011-09-24 23:25:47Z svnuser $ # # $Log: findcustc,v $ # Revision 1.1 1998/05/24 05:23:37 merlin # First version checked in CVS # # IFS=" "; export IFS USAGE="$0 [-i (ignore case)] base_dir_to_search_from regex" IGNORE= if [ $# -gt 1 ]; then if [ $# = 2 ]; then DIR=$1 PAT=$2 else if [ $# = 3 -a $1 = -i ]; then IGNORE=-i DIR=$2 PAT=$3 else echo $USAGE exit 1 fi fi else echo $USAGE exit 1 fi #find $DIR -type f -follow -print>/tmp/tmpxfnd.$$ find $DIR -name \*.[ch] -type f -print >/tmp/tmpxfnd.$$ cat /tmp/tmpxfnd.$$|while read i do if [ X`echo $i|egrep 'gz$'` = X ] then egrep $IGNORE -3 "$PAT" $i>/tmp/gp.$$ else zcat $i|egrep $IGNORE -3 "$PAT">/tmp/gp.$$ fi if [ -s /tmp/gp.$$ ] then echo $i echo -------------------- cat /tmp/gp.$$ echo echo fi done rm /tmp/tmpxfnd.$$ /tmp/gp.$$