: ########################################################################## # Title : vgrep - edit files containing search string # Author : Heiner Steven # Date : 1994-11-18 # Requires : egrep, vi # Category : File Utilities # SCCS-Id. : @(#) vgrep 1.2 03/12/19 ########################################################################## # Description # ########################################################################## PN=`basename "$0"` # Program name VER='1.2' : ${GREP:=egrep} # must list file names with -l : ${EDITOR:=vi} # must search pattern with +/pattern usage () { echo >&2 "$PN - edit files containing search string, $VER (stv '94) usage: $PN [$GREP arguments ...] search_string file [file ...]" exit 1 } Args= # Collect arguments for grep while [ $# -gt 0 ] do case "$1" in --) shift; break;; -h) usage;; -*) Args="$Args $1";; *) break;; # Search string esac shift done [ $# -lt 2 ] && usage Files=`$GREP -l $Args "$@"` # first argument is search string [ $? -eq 0 -a -n "$Files" ] && exec $EDITOR -c "/$1" $Files exit 0