diff options
| author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
|---|---|---|
| committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
| commit | 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch) | |
| tree | f6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/lookman | |
| parent | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff) | |
| download | plan9front-2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f.tar.xz | |
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/lookman')
| -rwxr-xr-x | rc/bin/lookman | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/rc/bin/lookman b/rc/bin/lookman new file mode 100755 index 000000000..5854e9528 --- /dev/null +++ b/rc/bin/lookman @@ -0,0 +1,36 @@ +#!/bin/rc +# Usage: lookman key ... +# prints out the names of all manual pages containing all the given keywords +rfork e +index=/sys/lib/man/lookman/index +t1=/tmp/look1.$pid +t2=/tmp/look2.$pid +fn sigexit { + rm -f $t1 $t2 + exit +} +fn sigint sighup sigterm { + rm -f $t1 $t2 + exit note +} + +*=`{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 usage +} +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);' +exit '' |
