#!/bin/bash if test $# -lt 2 then echo "usage: `basename $0` [...]" \ " [<--> [...]]" 1>&2 exit 1 fi str="$1" && shift declare -a dir i=0 while test "x$1" != "x" do test "x$1" == "x--" && { shift; break; } test -d "$1" || { echo "`basename $0`: $1: no such directory" 1>&2 exit 1 } dir[$i]="$1" && shift i=$((i+1)) done j=0 while test $j -lt $i do d="${dir[$j]}" case $d in -*) d="./$d";; esac find "$d" -type f -print0 | xargs -0 grep "$@" -- "$str" j=$((j+1)) done exit 0