bud@mtek.com (Bud Hovell) (03/22/91)
Submitted-by: Bud Hovell <bud@mtek.com> Posting-number: Volume 17, Issue 63 Archive-name: manlist/part01 This little script is something I've been using for a *long* time, and I thought I'd offer it as a possible addition to the archives, since it seems to fill a gap, on our SYSV machines. Basically, it does a listing of all available 'man' pages, either by section, key word, or in-total. The header further qualifies how it works. No man page for it - it's pretty simple (my kind of work :-). Bud Hovell ____________ bud@mtek.com --------------------- cut ------------------------ cut ------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # Contents: manlist # Wrapped by kent@sparky on Fri Mar 22 09:23:11 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive."' if test -f 'manlist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'manlist'\" else echo shar: Extracting \"'manlist'\" \(3623 characters\) sed "s/^X//" >'manlist' <<'END_OF_FILE' X# $Id: manlist,v 3.4 91/03/21 16:00:52 bbh Usenet_Rel $ 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 [ -list | [ 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 3b1 and 3b2 machines. If you don't X# want uncompressed 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@mtek.com> 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-list) # List section names and numbers: X cat << "end_list" X X 'MAN' SECTION LISTING X X Section 1: USER COMMANDS X Section 2: SYSTEM CALLS X Section 3: SUBROUTINES X Section 4: SPECIAL FILES X Section 5: FILE FORMATS AND CONVENTIONS X Section 6: GAMES X Section 7: MACRO PACKAGES AND LANGUAGE CONVENTIONS X Section 8: SYSTEM MAINTENANCE COMMANDS X Xend_list Xexit 0 X;; 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 [ -list | [ 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: Xtput clear 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? :-) X END_OF_FILE if test 3623 -ne `wc -c <'manlist'`; then echo shar: \"'manlist'\" unpacked with wrong size! fi # end of 'manlist' fi echo shar: End of archive. exit 0 exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.