1#!/bin/rc 2# Usage: lookman key ... 3# prints out the names of all manual pages containing all the given keywords 4rfork e 5index=/sys/lib/man/lookman/index 6t1=/tmp/look1.$pid 7t2=/tmp/look2.$pid 8fn sigexit { 9 rm -f $t1 $t2 10 exit 11} 12fn sigint sighup sigterm { 13 rm -f $t1 $t2 14 exit note 15} 16 17*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'} # fold case, delete funny chars 18if(~ $#* 0){ 19 echo Usage: lookman key ... >/fd/2 20 exit usage 21} 22look $1 $index | sed 's/.* //' | sort -u >$t1 23shift 24for(i in $*){ 25 look $i $index | sed 's/.* //' | sort -u | 26 awk 'BEGIN { 27 while (getline < "'$t1'" > 0) 28 table[$0] = 1 29 } 30 { if (table[$0]) print } 31 ' > $t2 32 mv $t2 $t1 33} 34sort $t1 | sed 's;/sys/man/;; 35 s;(.*)/(.*);man \1 \2 # \2(\1);' 36exit '' 37