2005-01-11 20:58:13 +00:00
|
|
|
#!/usr/local/plan9/bin/rc
|
2005-01-14 05:55:09 +00:00
|
|
|
|
|
|
|
. 9.rc
|
|
|
|
|
2005-01-04 22:11:58 +00:00
|
|
|
# Usage: lookman key ...
|
|
|
|
# prints out the names of all manual pages containing all the given keywords
|
2005-01-11 17:49:03 +00:00
|
|
|
index=$PLAN9/man/lookman.index
|
2005-01-04 22:11:58 +00:00
|
|
|
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){
|
2006-04-06 15:58:01 +00:00
|
|
|
echo usage: lookman key ... >[1=2]
|
2005-01-04 22:11:58 +00:00
|
|
|
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
|
|
|
|
}
|
2005-01-11 17:49:03 +00:00
|
|
|
sort $t1 | sed 's;/.*/man/man[0-9]*/;;
|
2005-01-04 22:11:58 +00:00
|
|
|
s;(.*)\.(.*);man \2 \1 # \1(\2);'
|
|
|
|
rm -f $t1 $t2
|
|
|
|
exit 0
|