Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.shell Subject: Re: does a zgrep exist? (zgrep <> zcat | grep) Message-ID: <1991Feb15.182057.18875@convex.com> Date: 15 Feb 91 18:20:57 GMT References: Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 39 Nntp-Posting-Host: pixel.convex.com From the keyboard of brister@decwrl.dec.com (James Brister): :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. : :Does such a thing exist? You might look to lwall's pipegrep program. It's on page 265 of the perl book, and available via anon ftp from uunet inside the compressed tarchive nutshell/perl/perl.tar.Z in ch6/pipegrep. You say: $ pipegrep 'some_pattern' cmd files so you could say: $ pipegrep 'foo.*bar$' zcat *.Z It would only zcat one file at a time, and grep through the pipe, and then prepend the (command and) filename it found it on. Quoting from the book: The pipegrep program greps the output of a series of commands. The difficulty with doing this using the normal grep program is that you lose track of which file was being processed. This program prints out the command it was executing at the time, including the filename. The command, which is a single argument, will be executed once for each file in the list. It's pretty quick little program, faster than stock greps, not quite so fast as GNU grep. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "All things are possible, but not all expedient." (in life, UNIX, and perl)