--- Begin Message ---
Subject: |
Enhancement request re zcat with empty files |
Date: |
Fri, 17 Jul 2020 13:42:04 +1000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Hello list,
This is my first post here, so apologies in advance for whatever I get
wrong.
I am asking for an enhancement to zcat, that it should silently ignore
empty files, either always, or (if that conflicts with POSIX or some
other standard), by a command line option.
My use case is as follows:
I maintain a server, and have occasion to scan log files for specific items.
As is typical in a logrotate environment, the files are something like
xyz.log current
xyz.log.1 previous
xyz.log.2.gz
xyz.log.3.gz etc etc
Most of the time I can search for something by
zgrep 'target' xyz*
But, wanting to further process a number of entries, I tried the obvious
zcat xyz* | awk ...
which results in
gzip: xyz.log.1: unexpected end of file
I note that it correctly handles archives with no content (just the 20
byte header)
Regards,
Peter
--- End Message ---
--- Begin Message ---
Subject: |
Re: Enhancement request re zcat with empty files |
Date: |
Wed, 6 Apr 2022 17:08:17 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
I am asking for an enhancement to zcat, that it should silently ignore
empty files, either always, or (if that conflicts with POSIX or some
other standard), by a command line option.
zcat -f does what you're asking for. For example:
$ touch empty
$ echo something | gzip >abc.gz
$ zcat -f *
something
Since the -f option satisfies your request I'll close the bug report.
--- End Message ---