does a zgrep exist? (zgrep <> zcat | grep)

Kjetil Torgrim Homme kjetilho at ifi.uio.no
Tue Feb 19 05:45:22 AEST 1991


A suggestion for a zgrep-script:
It has the slight problem that options has to be specified in quotes, like

	zgrep ^foo "-n -v" *.Z
	zgrep 'bar[f-o]' "" *.c.*

Note: no options has to be denoted by empty quotes.
An oddity: The name of the file comes after grep's output.


Just my 2 xre. (Does the eighth bit survive the Atlantic Ocean?)
Kjetil T.

#! /bin/sh
regexp=$1; options=$2; shift 2
for file in $@; do
        zcat $file | grep -e $regexp $options
        if test $? = 0; then
                echo "-- $file --"
        fi
done



More information about the Comp.unix.shell mailing list