Searching gz-compressed files

632 views
Skip to first unread message

michaellehmkuhl

unread,
Nov 18, 2008, 1:54:20 PM11/18/08
to ack dev/users
It would be really great if ack had a zgrep-like feature to be able to
search .gz compressed files.

What would be really slick is if it would have the smarts to read the
file extension rather than requiring a flag to process, so I could
search a combination of compressed and uncompressed files. A prime
example is a directory full of Apache logs where the most recent log
file is uncompressed and the historical ones are compressed.

Here's hoping one of you can make me look dumb and point out that ack
already has this capability.

Andy Lester

unread,
Nov 18, 2008, 1:57:43 PM11/18/08
to ack-...@googlegroups.com

On Nov 18, 2008, at 12:54 PM, michaellehmkuhl wrote:

> Here's hoping one of you can make me look dumb and point out that ack
> already has this capability.


I'm working on the plugins for it on the trunk. I have not made it
work yet. It's the recursive searching through tarballs that is
hanging me up, meshing that with the internal architectural changes
ack will need to have.

xoa

--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance

knot

unread,
Nov 18, 2008, 3:35:52 PM11/18/08
to ack dev/users
On 18 Lis, 19:54, michaellehmkuhl <michael.lehmk...@gmail.com> wrote:
> It would be really great if ack had a zgrep-like feature to be able to
> search .gz compressed files.

On my system, zgrep is a shell script wrapping grep - may be the
same approach could be used with ack instead of implementing
decompression logic in ack...

Andy Lester

unread,
Nov 19, 2008, 4:48:57 PM11/19/08
to ack-...@googlegroups.com
> On my system, zgrep is a shell script wrapping grep - may be the
> same approach could be used with ack instead of implementing
> decompression logic in ack...


Nope, for two reasons.

First, ack has to run on Windows.

Second, and more importantly, a .gz is just a special case of a user-
defined pluggable file format. I want to be able to search PDFs,
Excel spreadsheets, whatever.

Sitaram Chamarty

unread,
Nov 19, 2008, 9:09:48 PM11/19/08
to ack-...@googlegroups.com
On Wed, Nov 19, 2008 at 2:05 AM, knot <uze...@gmail.com> wrote:
> On my system, zgrep is a shell script wrapping grep - may be the
> same approach could be used with ack instead of implementing
> decompression logic in ack...

hmm I wonder... because zgrep doesn't take "-r", which is fundamental
to the difference between ack and grep. zgrep munges the arglist, and
runs a separate invocation of grep for each compressed file. It also
uses sed to place the filename at the front when needed, with
something like s/^/file.gz:/.

No -- if ack did this you'd have to roll it in, I think

Reply all
Reply to author
Forward
0 new messages