home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / filedocs / grep.sim < prev    next >
Text File  |  1994-03-04  |  2KB  |  50 lines

  1. #! /bin/sh
  2. #    This is grep.sim -- a Unix script view simibm.idx on Unix systems.
  3. #    Copyright (C) 1990  David J. Camp
  4. #
  5. #    This program is free software; you can redistribute it and/or modify
  6. #    it under the terms of the GNU General Public License as published by
  7. #    the Free Software Foundation; either version 1, or (at your option)
  8. #    any later version.
  9. #
  10. #    This program is distributed in the hope that it will be useful,
  11. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #    GNU General Public License for more details.
  14. #
  15. #    You should have received a copy of the GNU General Public License
  16. #    along with this program; if not, write to the Free Software
  17. #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. #
  19. # david@wubios.wustl.edu             ^     Mr. David J. Camp
  20. # david%wubios@wugate.wustl.edu    < * >   +1 314 382 0584
  21. # ...!uunet!wugate!wubios!david      v     "God loves material things."
  22. #
  23. IDX=/mirrors/msdos/filedocs/simibm.idx
  24. if test "$1" = "-help"
  25.     then
  26.     echo "usage: grep.sim"
  27.     echo "   or: grep.sim PATTERN"
  28.     echo "calls your pager displaying only lines matching PATTERN"
  29.     echo "but also includes the directories containing the matches"
  30.     exit 1 
  31.     fi
  32. if test "${PAGER:=UNDEFINED}" = "UNDEFINED"
  33.     then
  34.     if ( `which less` > /dev/null )
  35.         then
  36.         PAGER=`which less`
  37.     else
  38.         PAGER=`which more`
  39.         fi
  40.     fi
  41. if test "$1" = "" 
  42.     then
  43.     set -- '.*'
  44.     fi
  45. exec simcvt < $IDX 2>&1 | \
  46.     sed -n -e '/PD[0-9]*:<.*\..*>/{x;s/.*/ /;x;H;d;}' \
  47.         -e "/$*/{H;g;p;s/.*//;h;}" | \
  48.     grep -v '^$' | \
  49.     $PAGER
  50.