home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / nn.tar / nn-6.5.1 / nngrab.sh < prev    next >
Text File  |  1995-04-29  |  687b  |  47 lines

  1. # nngrab -- quick news retrieval by keyword
  2. #
  3. # From: James A. Woods (ames!jaw), NASA Ames Research Center
  4. #
  5. # Naturally, you're running fast e?grep (GNU-style) or this is all for
  6. # naught.
  7.  
  8.  
  9. FOLDCASE=""
  10. case $1 in
  11. -c)
  12.     FOLDCASE="-i"
  13.     shift
  14. esac
  15.  
  16. case $# in
  17. 1) ;;
  18. *)
  19.     echo >&2 "usage: $0 [-c] keyword-pattern"
  20.     exit 1
  21. esac
  22.  
  23. case $1 in
  24. *[A-Z]*) KW="`echo "$1" | tr '[A-Z]' '[a-z]'`";;
  25. *) KW=$1
  26. esac
  27.  
  28. if [ -s $DB/subjects ] ; then
  29.     groups=`
  30.         egrep "^[^:]*:.*${KW}" $DB/subjects |
  31.         sed 's/:.*//' |
  32.         uniq
  33.     `
  34.  
  35.     case $groups in
  36.     '')
  37.         echo >&2 "Pattern '$1' not found in any subjects"
  38.         exit 1
  39.     esac
  40.  
  41.     groups="-G $groups"
  42. else
  43.     groups=all
  44. fi
  45.  
  46. exec $BIN/nn -Q -mxX $FOLDCASE -s/"$1" $groups
  47.