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

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