[Linux-disciples] zcat v. zgrep v. zless

Stephen R Laniel steve at laniels.org
Mon Oct 4 10:39:16 EDT 2004


If you zgrep a raw-text file, it'll work fine. If you
zless a raw-text file, it likewise works fine. If you
zcat a raw-text file, however, you get an error that the
file you're trying to cat isn't gzipped.

Is there a good reason for this inconsistent behavior?

More to the point, I often find myself wanting to run
scripts against all the access.log* files in
/var/log/apache. I'd like to be able to do something like

zcat /var/log/apache/access.log* |someScript

but I can't; I have to run one command for access.log and
one for access.log.*.gz. Maybe this is me just being
needlessly picky, but I thought I'd ask.

What's the best way around this? I suppose I could write a
script that checks whether its argument is gzipped or
raw text; if the former, the script would run zcat against
it, whereas for the latter the script would just run 'cat'.
But that seems like a suboptimal approach.

-- 
``I am all about the delivery of *justice* to
  parking, people. That is all.''
 -Jon Sung, 27 September 2004



More information about the Linux-disciples mailing list