#!/bin/sh
# rgrep: recursive grep
# Sorry, i can't remember the author of this script taken from some How-to
# v. 1.0.0 Modified to work under Bad Penguin by AGX
# v. 1.0.2 Modified by AGX to support default parameter
if [ $# = 1 ]; then
  G_DIR="."
  G_PATTERN=$1
  G_SWITCH="-H"
elif [ $# = 2 ]; then
  G_DIR=$2
  G_PATTERN=$1
  G_SWITCH="-H" 
elif [ $# = 1 ]; then
  G_DIR=$3
  G_PATTERN=$2
  G_SWITCH=$1 
else
  echo "Usage: rgrep --switches 'pattern' 'directory'" 
  exit 1
fi
# do it !
find $G_DIR -name "*" -exec grep $G_SWITCH $G_PATTERN {} \; 2> /dev/null
