#!/bin/bash
#    Roughly equivalent to the Emacs grep-find command
#    The only real difference is leaving off the -e argument to grep.
#    That allows multiple options to be specified on the command line.
#
#    If the first option is -s, pipe the result through sort

if [[ "" = "'$@'" ]]; then
   echo "Usage: grep-find grep-option... pattern"
   exit 1
elif [[ "$1" = "-s" ]]; then
    shift
    find . -type f -exec grep -nH "$@" {} + | sort
    exit
fi
find . -type f -exec grep -nH "$@" {} +
