Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/rc/gr

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


#!/bin/rc
# gr - recursive grep(1)

fn usage {
	echo >[1=2] usage: gr [grep options] pattern [file...]
	exit usage
}

fn findfiles {
	du -as $* |awk '{if ($2 != ".") print $2}'
}

opts=()
while(~ $1 -*){
	opts=($opts $1)
	shift
}

if(~ $#* 0)
	usage

pattern=$1; shift
grep $opts -e $pattern `{findfiles $*}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.