Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!paperboy!think.com!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!sharkey!wyn386!wybbs!sleepy From: sleepy@wybbs.mi.org (Mike Faber) Newsgroups: comp.unix.shell Subject: Re: does a zgrep exist? (zgrep <> zcat | grep) Message-ID: <346@wybbs.mi.org> Date: 18 Feb 91 16:02:34 GMT References: Reply-To: sleepy@wybbs.UUCP (Mike Faber) Organization: Consultants Connection, Jenison MI Lines: 21 In article brister@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@wybbs.UUCP He who uses curses often... Michael Faber curses often.