bbh@whizz.uucp (Bud Hovell) (01/01/90)
Since I installed Gil's 'man' program here (thanks, Gil!), I keep and refer to many more on-line man pages, encouraged by the fact that I can now store them in compressed format, rather than on paper. There were getting to be enough of them that I wanted to be able to list them out in an orderly and convenient way, or be able to search them selectively, etc. So... A little script I found I used alot more than I ever expected. Have now completely re-written and cleaned it up for our own use - and offer it here as something that may be useful to others. Nuthin' fancy. Just alphabetically lists out the 'man' pages available on-line, either in total, by section number, by keyword for all sections, or by section & keyword. (See the included man page). (I cancelled an earlier posting of this because it contained a typo, so hopefully this is the only time you will have seen it). ------------------- cut --------------------------- cut --------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: MANIFEST manlist manlist.1 # Wrapped by bbh@whizz on Mon Jan 1 01:24:15 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'MANIFEST' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'MANIFEST'\" else echo shar: Extracting \"'MANIFEST'\" \(230 characters\) sed "s/^X//" >'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X MANIFEST 1 This shipping list X manlist 1 List man pages X manlist.1 1 Man page END_OF_FILE if test 230 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! fi # end of 'MANIFEST' fi if test -f 'manlist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'manlist'\" else echo shar: Extracting \"'manlist'\" \(3130 characters\) sed "s/^X//" >'manlist' <<'END_OF_FILE' X# $Id: manlist,v 3.2 90/01/01 01:17:43 bbh Exp $ X# X# Purpose: List 'man' pages on-line, either by key word, or by section, or in X# total, and tell us of any not compressed. X# X# Usage: manlist [section#] [keyword] X# X# This script was written for use with man directories organized under X# ~cat|man[1-8] nomenclature, and where man pages are stored X# in compressed format (we use Gil Kloepfer's 'man' program). It X# has been installed only on a Unix-pc. If you don't want uncom- X# pressed files so labelled, then just delete the line: X# X# -e 's/[a-z,A-Y,0-9]$/& \(not compressed\)/g' \ X# X# Caveat: This script will NOT work if any of your cat|man directory names X# end in a letter rather than a number (~/manl, for example). X# X# Author: Bud Hovell <bbh@whizz> X# X########################## edit these variables ########################### X# Number of display lines on your terminal? Xscreen=23 X# Where the 'man' directory lives: Xmandir=/usr/man X# Your favorite pager: Xpager=/usr/local/bin/less X# How your machine knows who it is: Xhostname=`uuname -l` X############################### edit no more ############################## X# What's he looking for? Xcd $mandir Xcase $1 in X[1-8]) # Gave us a valid section number as first argument X sec=$1 X case $sec in # Manual section definitions: X 1) section="(USER COMMANDS)" ;; X 2) section="(SYSTEM CALLS)" ;; X 3) section="(SUBROUTINES)" ;; X 4) section="(SPECIAL FILES)" ;; X 5) section="(FILE FORMATS AND CONVENTIONS)" ;; X 6) section="(GAMES)" ;; X 7) section="(MACRO PACKAGES AND LANGUAGE CONVENTIONS)" ;; X 8) section="(SYSTEM MAINTENANCE COMMANDS)" ;; X esac X if test "$2" X then alpha=$2 X fi X break X;; X[0,9]|-*) # Error - invalid section number given X echo "\nUsage: $0 [section#] [keyword]\n" X exit 0 X;; X*) # Ok - we'll treat any other first argument as a keyword X alpha=$1 X;; Xesac X X# What do we search on? Xif [ "$alpha" ] Xthen if [ $sec ] X then check=./*${sec}/*${alpha}* X else check=./*/*${alpha}* X fi Xelif [ "$sec" ] X then check=*${sec}/* X else check=* Xfi X X# Send output to pager (list <= 1 screen)? Xhowmany=`ls -a $check | wc -l | sed 's/^[ ]*//p'` Xif test "$howmany" -lt $screen-4 Xthen output="cat -u" Xelse output=$pager Xfi X X# Print the appropriate message: Xclear Xecho "\n\nListing 'man' pages \c" Xtest $sec && echo "in section ${sec} ${section}\n\t\c" Xtest $alpha && echo "having root-name '${alpha}' \c" Xecho "on host '${hostname}'\n" X X# Go to press: Xls -a $check | sort -f \ X | sed -e '/^\.\.$/D' \ X -e '/^\.$/D' \ X -e '/^[cm]a[tn].*:$/D' \ X -e '/^[ ]*$/D' \ X -e 's/[a-z,A-Y,0-9]$/& \(not compressed\)/g' \ X -e 's/^.*[cm]a[tn][1-8].//g' \ X -e 's/^.*\.[1-8].*/ &/g' \ X -e 's/\.Z$//g' \ X -e 's/^.* found.*$/No entry there./g' \ X | $output X X# someone want to make this fugly filter a bit more-elegant? :-) END_OF_FILE if test 3130 -ne `wc -c <'manlist'`; then echo shar: \"'manlist'\" unpacked with wrong size! fi # end of 'manlist' fi if test -f 'manlist.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'manlist.1'\" else echo shar: Extracting \"'manlist.1'\" \(1673 characters\) sed "s/^X//" >'manlist.1' <<'END_OF_FILE' X.TH MANLIST 1L "" UNIX-PC X.\" $Id: manlist.1,v 3.2 90/01/01 01:18:49 bbh Exp $ X.SH NAME Xmanlist \- list on-line manual pages available. X.SH SYNOPSIS X.B manlist X[ X.B section# X] X[ X.B keyword X] X.SH DESCRIPTION X.PP X.I manlist, Xwith no arguments, produces a full listing of all on-line manual pages. X.PP XIf only a X.I section Xnumber is given, then the listing will be for all man pages in that Xsection only. X.PP XIf X.I keyword Xis given, then only those man pages containing that unique character Xsequence will be listed. If preceded by X.I section Xnumber, then the keyword search will be constrained to that section only. X.PP XAll listings are output in alphabetical order, disregarding case. If the Xlisting is more than one screen in length, then output will be sent to Xthe pager. X.PP X.I Manlist Xalso comments on any man page found stored in uncompressed format X(and assumed to be an act of omission wanting correction). X.SH FILES X.I ~/bin/man. XLocally, we use the (very nice) 'man' program designed by Gil Kloepfer. X.SH ORGANIZATION XThe main ~/man directory is presumed to be seperated into sections X(subdirectories), each named with the first three letters 'cat' or 'man', Xand having for the fourth character in its name an Arabic numeral 1 Xthrough 8 (e.g., "cat4" or "man1"). X.PP XNo section may use an alpha fourth character in its name (e.g., "manp"). X.PP XMan pages can be stored in compressed format - and shall be. X.SH BUGS XA single Arabic numeral cannot be used for keyword searches, since it will Xbe understood by the script to be a valid section number \- or an error. X.PP XThe output filter is less than elegant. X.PP XReports to Bud Hovell {tektronix|sun}!nosun!whizz!bbh END_OF_FILE if test 1673 -ne `wc -c <'manlist.1'`; then echo shar: \"'manlist.1'\" unpacked with wrong size! fi # end of 'manlist.1' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 ------------------- cut --------------------------- cut --------------- Bud ________________________________________________________________________ UUCP: ...{tektronix|sun}!nosun!whizz!bbh (Just another pilgrim :-) MOTD: "Lead, follow, or get out of the way!" - Ted Turner