Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/root/rc/bin/g

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

rfork e
flags=-n
re=()
files=/dev/null
f=1
p=()
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} $files
case *
	grep $flags $re $files
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].