plan9port/bin/g

38 lines
440 B
Text
Raw Normal View History

#!/bin/sh
2004-03-25 23:03:22 +00:00
inflags=yes
flags=""
while [ $# != 0 -a $inflags = yes ]
do
case "$1" in
-*)
flags="$flags $1"
shift
;;
-)
inflags=no
shift
;;
*)
inflags=no
;;
esac
done
2004-03-25 23:03:22 +00:00
case $# in
0)
echo 1>&2 'usage: g [flags] pattern [files]'
2004-03-25 23:03:22 +00:00
exit 1
;;
1)
pattern="$1"
files=`/bin/ls *.[bcChm] *.cc *.py *.tex *.ms *.java 2>/dev/null`
;;
*)
pattern="$1"
shift
files="$@"
esac
2004-03-25 23:03:22 +00:00
exec grep -n $flags -- "$pattern" $files /dev/null