tlookman - plan9port - [fork] Plan 9 from user space
(HTM) git clone git://src.adamsgaard.dk/plan9port
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tlookman (719B)
---
1 #!/usr/local/plan9/bin/rc
2
3 . 9.rc
4
5 # Usage: lookman key ...
6 # prints out the names of all manual pages containing all the given keywords
7 index=$PLAN9/man/lookman.index
8 t1=/tmp/look1.$pid
9 t2=/tmp/look2.$pid
10 fn sigexit sigint sighup sigterm{
11 rm -f $t1 $t2
12 exit 1
13 }
14 *=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars
15 if(~ $#* 0){
16 echo usage: lookman key ... >[1=2]
17 exit 1
18 }
19 look $1 $index|sed 's/.* //'|sort -u >$t1
20 shift
21 for(i in $*){
22 look $i $index|sed 's/.* //'|sort -u|
23 awk 'BEGIN {
24 while (getline < "'$t1'" > 0) table[$0] = 1;
25 }
26 { if (table[$0]) print }
27 ' > $t2
28 mv $t2 $t1
29 }
30 sort $t1 | sed 's;/.*/man/man[0-9]*/;;
31 s;(.*)\.(.*);man \2 \1 # \1(\2);'
32 rm -f $t1 $t2
33 exit 0