Is there a tool that combines zcat and cat transparently?
Try it with -f
or --force
:
zcat -f -- *
Since zcat
is just a simple script that runs
exec gzip -cd "$@"
with long options that would translate to
exec gzip --stdout --decompress "$@"
and, as per the man gzip
(emphasize mine):
-f --force Force compression or decompression even if the file has multiple links or the corresponding file already exists, or if the compressed data is read from or written to a terminal. If the input data is not in a format recognized by gzip, and if the option --stdout is also given, copy the input data without change to the standard output: let zcat behave as cat.
Also:
so that I can pipe the output to
grep
for example
You could use zgrep
for that:
zgrep -- PATTERN *
though see Stéphane's comment below.
zless
It seems a pity about zcat
, as libz has an API that supports reading from both compressed and uncompressed files transparently. But the manpage does say that zcat
is equivalent to gunzip -c
.
I use exactly for the same purpose:
{ cat /var/log/messages ; zcat /var/log/messages*.gz ; }| grep something | grep "something else" ....