: ########################################################################## # Shellscript: vgrep - edit files containing search string # Version : 0.1 (beta) # Author : Heiner Steven (heiner.steven@odn.de) # Date : 11/18/94 # Category : File Utilities # SCCS-Id. : $Id: vgrep,v 1.1.1.1 1999/06/15 19:29:05 heiner Exp $ ########################################################################## # Description # ########################################################################## PN=`basename $0` # program name VER='0.1 (beta)' : ${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