#!/bin/sh # # $Id: findstr 356 2011-09-24 23:25:47Z svnuser $ # # $Log: findstr,v $ # Revision 1.2 1998/10/19 04:17:50 merlin # updated paths to look in # # Revision 1.1 1998/05/24 05:23:38 merlin # First version checked in CVS # # IFS=" "; export IFS USAGE="$0 [-i (ignore case)] regex" IGNORE= if [ $# -gt 0 ]; then if [ $# = 1 ]; then PAT=$1 else if [ $# = 2 -a $1 = -i ]; then IGNORE=-i PAT=$2 else echo $USAGE exit 1 fi fi else echo $USAGE exit 1 fi find /etc /usr /var -name "*" -type f -print>/tmp/tmpfnd.$$ cat /tmp/tmpfnd.$$|while read i do if [ X`echo $i|egrep 'gz$'` = X ]; then if [ X`echo $i|egrep 'bz$'` = X ]; then egrep $IGNORE -3 "$PAT" $i>/tmp/gpf.$$ else bzcat $i|egrep $IGNORE -3 "$PAT">/tmp/gpf.$$ fi else zcat $i|egrep $IGNORE -3 "$PAT">/tmp/gpf.$$ fi if [ -s /tmp/gpf.$$ ]; then echo $i echo -------------------- cat /tmp/gpf.$$ echo echo fi done rm /tmp/tmpfnd.$$ /tmp/gpf.$$