Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/lookman-dot/lookman.orig

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


#!/bin/rc
# Usage: lookman key ...
#	prints out the names of all manual pages containing all the given keywords
index=/sys/lib/man/lookman/index
t1=/tmp/look1.$pid
t2=/tmp/look2.$pid
fn sigexit sigint sighup sigterm{
	rm -f $t1 $t2
	exit 1
}
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'}	# fold case, delete funny chars
if(~ $#* 0){
	echo Usage: lookman key ... >/fd/2
	exit 1
}
look $1 $index|sed 's/.*	//'|sort -u >$t1
shift
for(i in $*){
	look $i $index|sed 's/.*	//'|sort -u|
		awk 'BEGIN {
			while (getline < "'$t1'" > 0) table[$0] = 1;
			}
			{ if (table[$0]) print }
			' > $t2
	mv $t2 $t1
}
sort $t1 | sed 's;/sys/man/;;
	s;(.*)/(.*);man \1 \2 # \2(\1);'
rm -f $t1 $t2
exit 0

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.