#!/bin/sh
# vipat

# Edit argument files $2 ..., that contain pattern $1

if test $# -le 1
then
   echo "Usage: $0 pattern file ..."
else
   pattern=$1;  shift                   # Save original $1
   while [ $# -gt 0 ]                   # New $1 is first filename
   do
      grep "$pattern" $1 > /dev/null
      if [ $? -eq 0 ] ; then            # If grep found pattern in this file
	 vi $1                          # then vi the file
      fi
      shift
   done
fi
