home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / LINUX / ARCHIVE / MANINDEX.Z / MANINDEX / sbin / manindex
Encoding:
Text File  |  1993-01-01  |  972 b   |  24 lines

  1. #!/bin/sh
  2. # manindex: Generate a list of topic lines that you can grep through.
  3. # Then create 'apropos' and other aliases to search the list.
  4. # Run this periodically--once a month should suffice
  5. mandir=/usr/share/man     # where the manual pages are stored
  6. manlist="cat1 cat2 cat3"  # list particular directories you care about
  7. indexfile="$HOME/manindex.txt"
  8.  
  9. rm -f $indexfile
  10. for directory in $manlist
  11. do
  12.         cd $mandir/$directory
  13.         # the sed command turns filenames into "manual page" names
  14.         # e.g., converts sed.1.z to sed.  
  15.         # BUG:  won't handle names like a.out.4.Z correctly
  16.         for manpage in `ls | sed -e 's/\..*$//g'`
  17.         do
  18.                 # use man to unpack the manual page; it might be compressed
  19.                 # use col to strip garbage characters
  20.                 # egrep looks for spaces, manual page name, and dash
  21.                 man $manpage | col -b -x | egrep "^ +$manpage.* - " | uniq
  22.         done
  23. done > $indexfile
  24.