9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: [9fans] lookman
Date: Tue, 17 Jun 2003 16:04:57 +0100	[thread overview]
Message-ID: <b465fe7b43e0a0496569073589162dfd@vitanuova.com> (raw)
In-Reply-To: <17636.1055226056@beat.cc.titech.ac.jp>

> P.S.
> I will write on my white-board `lookman ordinary_unix_command`
> a considerable times.

that reminds me.
i've been using the following version of lookman for ages now, and
often find it more useful than the one distributed.

it does the usual keyword lookup but does a grep too so that you get
some immediate context for the hits.

e.g.
% lookman serial
9p(2)
	               fully terminate the serial conversation once the file
draw(2)
	               Turns on or off debugging output (usually to a serial
html(2)
	          serial number for the form within the document.  Name is the
	          Fbutton, Fselect or Ftextarea.  Fieldid is a serial number
	          Tableid is a serial number for the table within the docu-
	          Cellid provides a serial number for the cell within the
memdraw(2)
	          the kernel, iprint prints to a serial line rather than the
[...]

it has some obvious flaws, but is nonetheless useful, i think.

  cheers,
    rog.


#!/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-z \012'}	# fold case, delete funny chars
if(~ $#* 0){
	echo Usage: lookman key ... >/fd/2
	exit 1
}
look -x $1 $index|sed 's/.*	//'|sort -u >$t1
allkey=$*
shift
for(i in $*){
	look -x $i $index|sed 's/.*	//'|sort -u|
		awk 'BEGIN {
			while (getline < "'$t1'" > 0) table[$0] = 1;
			}
			{ if (table[$0]) print }
			' > $t2
	mv $t2 $t1
}
for (i in `{sort $t1}) {
	echo $i | sed 's:/sys/man/([0-9])/(.*):\2(\1):'
	for (j in $allkey) {
		nroff -man $i | grep -i -e $j | sed 's/^/	/'
	}
}

rm -f $t1 $t2
exit 0



  reply	other threads:[~2003-06-17 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-10  4:24 [9fans] change password from a terminal? YAMANASHI Takeshi
2003-06-10  4:30 ` boyd, rounin
2003-06-10  5:03   ` YAMANASHI Takeshi
2003-06-10  6:24     ` boyd, rounin
2003-06-10  6:10   ` Russ Cox
2003-06-10  6:25     ` boyd, rounin
2003-06-10 11:49     ` David Presotto
2003-06-10 17:20       ` Dan Cross
2003-06-10 17:17     ` Dan Cross
2003-06-10  6:11 ` Russ Cox
2003-06-10  6:20   ` YAMANASHI Takeshi
2003-06-17 15:04     ` rog [this message]
2006-09-12 15:08 [9fans] lookman Skip Tavakkolian
2006-09-13  1:07 ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b465fe7b43e0a0496569073589162dfd@vitanuova.com \
    --to=rog@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).