home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / mail / listserv / utils / pmigrep.sh.Z / pmigrep.sh
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-03-24  |  649 b   |  29 lines

  1. #!/bin/sh
  2. #
  3. # Poor man's grep -i: For those systems that do not support the -i flag to
  4. # grep.
  5. # Author: Erik-Jan Vens.  E.J.Vens@icce.rug.nl
  6. #
  7. # To use, edit src/defs.h and redefine the symbol GREP as follows:
  8. #
  9. #define GREP         "pmigrep" /* "grep -i" */
  10.  
  11. if [ "$1" = "" ]; then
  12.         echo "Usage: pmigrep <pattern> <file>"
  13.         exit
  14. fi
  15. if [ "$2" = "" ]; then
  16.         echo "Usage: pmigrep <pattern> <file>"
  17.         exit
  18. fi
  19.  
  20. PAT=`echo "$1"|tr '[a-z]' '[A-Z]'`
  21. cat $2|tr '[a-z]' '[A-Z]'>/tmp/$2.$$
  22. LINENOS=`grep -n ${PAT} /tmp/$2.$$|sed 's/\([0-9][0-9]*\):.*/\1p/g'`
  23. rm /tmp/$2.$$
  24. for CLO in ${LINENOS}
  25. do
  26.         sed -n "${CLO}" $2
  27. done
  28.