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

Mike Faber sleepy at wybbs.mi.org
Tue Feb 19 03:02:34 AEST 1991


In article <BRISTER.91Feb14204903 at saratoga.decwrl.dec.com> brister at decwrl.dec.com (James Brister) writes:
>I guess this is marginally under comp.unix.shell...
Well, here's a comp.unix.shell solution...


>It would be nice to grep through compressed files. Sure, you can do zcat |
>grep regexp, but then you loose the ability of grep to tell you the
>filename and/or linenumber of a match.  Uncompressing the files before
>greping isn't really wanted, cause you may not have the space on disk.
>James

for i in (list of files you want to zgrep or $*)
do
zcat $i | grep (whatever) | awk fil=$i '{printf("%s:%s\n",fil,$0)}'
done

Ok, it's ugly, but it should work...

--
sleepy at wybbs.UUCP                     He who uses curses often...
Michael Faber                         curses often.



More information about the Comp.unix.shell mailing list