45 lines · 568 B · Text
RawDownload
#!/bin/rc rfork eflags=-nre=()files=/dev/nullf=1p=()if(~ $#filepat 0)	filepat = '(body|\.[Cbchlmsy])$' fn collect{	find $* | grep $filepat} fn collect1{	ls | grep $filepat} for(i){	if(~ $f 1 && ~ $i -*)		flags = ($flags $i)	if not if (~ $#re 0){		f = 0		re = $i	}	if not{		p = ($p $i)		if(test -d $i)			files = ($files `{collect $i})		if not			files = ($files $i)	}}if(~ $#re 0){	echo usage: g '[flags]' pattern ... >[1=2]	exit usage}modre>[2=]switch($#p){case 0	grep $flags $re `{collect1} $filescase *	grep $flags $re $files}