scripts I use on plan 9
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

31 lines
517 B

#!/bin/rc
rfork e
nl='
'
flags=()
recurse=()
while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
if(~ $1 '-n')
recurse=-n1
if not
flags=($flags $1);
shift
}
if(~ $1 --)
shift
switch($#*){
case 0
echo 'usage: wg [flags] pattern [files]' >[1=2]
exit usage
case 1
pattern=$1
fullnames='mkfile$'
suffixes='\.([bcChlmsy]|md|gmi)$'
files=`$nl{walk -f $recurse | grep -e $fullnames -e $suffixes >[2]/dev/null}
case *
pattern=$1
shift
files=`$nl{walk -f $recurse -- $*}
}
grep -ni $flags -- $pattern $files /dev/null