home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / GNUMAN.ZIP / apropos.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-01-10  |  1KB  |  60 lines

  1. #!/bin/sh
  2. #
  3. # apropos -- search the whatis database for keywords.
  4. #
  5. # Copyright (c) 1991, John W. Eaton.
  6. #
  7. # You may distribute under the terms of the GNU General Public
  8. # License as specified in the README file that comes with the man 1.0
  9. # distribution.
  10. #
  11. # John W. Eaton
  12. # jwe@che.utexas.edu
  13. # Department of Chemical Engineering
  14. # The University of Texas at Austin
  15. # Austin, Texas  78712
  16.  
  17. PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
  18.  
  19. libdir=LIBDIR
  20.  
  21. if [ $# = 0 ]
  22. then
  23.     echo "usage: `basename $0` keyword ..."
  24.     exit 1
  25. fi
  26.  
  27. manpath=`BINDIR/manpath -q | tr : '\040'`
  28.  
  29. if [ "$manpath" = "" ]
  30. then
  31.     echo "whatis: manpath is null"
  32.     exit 1
  33. fi
  34.  
  35. while [ $1 ]
  36. do
  37.         found=0
  38.         for d in $manpath /usr/lib
  39.         do
  40.             if [ -f $d/whatis ]
  41.             then
  42.                 grep -i "$1" $d/whatis
  43.                 status=$?
  44.                 if [ "$status" = "0" ]
  45.                 then
  46.                     found=1
  47.                 fi
  48.             fi
  49.         done
  50.  
  51.         if [ "$found" = "0" ]
  52.         then
  53.             echo "$1: nothing appropriate"
  54.         fi
  55.  
  56.         shift
  57. done
  58.  
  59. exit
  60.