Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/srch/srch.rc

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


#!/bin/rc

rfork ne

mask=''

9fs idx
idx=/n/idx
base=/sys/src

while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
	switch($1){
	case -[FfPcvgldsx]
		mask=$mask^$1
	case *
		echo 'usage: srch [-FfPcvgldsx] <pattern>'
		exit 'usage'
	}
	shift
}

if(~ $1 --)
	shift

if (! ~ $mask '')
	mask='^['^`{echo $mask | sed 's/-//g'}^'] [0-9]+ [0-9]+ .*'

grep $mask^$* $idx/symbs.idx |
	while(txt=`{read}){
		type=$txt(1)
		fnum=$txt(2)
		line=$txt(3)
		file=`{grep '^'^$fnum^' ' $idx/files.idx}
		match=`{echo $txt | sed 's/^[A-Za-z] [0-9]+ [0-9]+ //'}
		echo $type $base/$file(2)^:$line $match
	}

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.