#!/bin/bash if [[ ("$1" = "") || ("$2" = "") ]] then echo "usage : grep.all dir pattern" exit 1 fi echo "grep in $1 for $2" FILES=$(find $1 -type f -print) for file in $FILES do RESULT=$(grep $2 $file) if [ ! "$RESULT" = "" ] then echo "$file : $RESULT" fi done