#!/bin/bash if [[ $1 = -h || $1 = --help ]] then cat - >&2 < 2: findgrep [] 3: findgrep Per default, find is called for the current directory and grep is called with options '-qi' EOF exit 0 fi if [[ $# -ge 2 ]] then if [[ $1 = -* ]] then # synopsis 3 directory=. grep_opts="" else # synopsis 2 directory="$1" shift if [[ $1 != -* ]] then grep_opts="-qi" fi fi else # synopsis 1 directory=. grep_opts="-qi" fi find ${directory} -type f -a -exec grep $grep_opts "$@" {} \; -print