home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # simgrep -- search compressed SimTel file list (from simlist.zip), and
- # print findings with directory names
- #
- # <rreiner@nexus.yorku.ca>
- #
- # Revised:
- # Mon Feb 3 13:08:07 EST 1992
- # Wed Oct 6 17:41:52 EDT 1993 -- changed to match new listing format
- # Thu Oct 21 19:18:51 EDT 1993 -- cleaned up.
- #
-
- ##
- ## Copyright (C) 1992 Richard Reiner, all rights reserved.
- ##
-
- #############################################################################
- # Customization section.
- #
- # The compressed file the SimTel file index is stored in:
- COMPFILE=/usr/phil/grads/phigs/lib/simlist.zip
- # The program it is to be uncompressed with:
- COMPPROG=unzip
- # The commandline switches needed to get COMPROG to extract a file to stdout:
- COMPFLAGS=-p
- # The name of the index file within COMPFILE:
- INDEXFILE=SIMIBM.LST
- # egrep:
- EGREPPROG=egrep
- # AWK:
- AWKPROG=nawk
- #
- # End of customization section.
- #############################################################################
-
- MYNAME=`basename $0`
-
- if [ $1z = z ]; then
- echo "$MYNAME: usage is $MYNAME expresssion."
- echo "$MYNAME: note: searches use case-insensitive egrep regular expressions."
- exit 1
- fi
-
- #
- # The AWK contortions at the end of the pipe do the following:
- #
- # Decide whether to print each line only when the next is encountered; then,
- # if several "Directory" lines appear in sequence, keep only the last;
- # precede each change of directory with a newline; and print everything
- # that is not a "Directory" entry.
- #
- # The egrep and AWK stages of the pipe could be consolidated, but it is
- # simpler and faster this way.
- #
- $COMPPROG $COMPFLAGS $COMPFILE $INDEXFILE | $EGREPPROG -i "^Directory"\|"$1" \
- | $AWKPROG ' { if (prevline == "") {
- prevline = $0
- next
- }
- if (prevline ~ "^Directory") {
- if ($0 ~ "^Directory") {
- prevline = $0
- next
- } else {
- print prevline
- prevline = $0
- }
- } else {
- print prevline
- prevline = $0
- if ($0 ~ "^Directory")
- print ""
- }
- }
- END { if (! (prevline ~ "^Directory"))
- print prevline
- }'
-
-