There I said it !
I think that providing an exit status that is not 0 when
zcatis used with an uncompressed file is useful. Though my opinion is less strong regarding whether it should write more text after an error occurred, it’s probably more useful for a process to terminate quickly when an error occurred rather than risk a second error occurring and making troubleshooting harder.I think that trying to change any existing documented features of widely used utilities will lead to us having less useful software in the future (our time is probably better spent making new programs and new documentation): https://www.jwz.org/doc/worse-is-better.html https://en.wikipedia.org/wiki/Worse_is_better
Not improving existing software leads to stagnation.
It’s certainly a good part of why so much of linux is an awkward kludgy idiosyncratic mess to use.
Whatever the first implementation does ends up being a suicide pact by default.
Another option is to change cat to auto decompress compressed files, instead of printing gibberish.
just use
-flol.less $(which zcat)shows us agzipwrapper. So we look throughgzipoptions and see:-f --force
Force compression or decompression. 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.party music
That works great now I can zcat -f /var/log/apache2/*
Well, the source code is available. Fix it if you need it that bad.
Where is it? I can’t seen to find it https://github.com/zCat?tab=repositories
Yeah, it’s a pain. Leads to bad one liners:
for i in $(ls); do zcat $i || cat $i; doneThanks !
But still we shouldn’t have to resort to this !
Also, can’t get the output through pipefor i in $(ls); do zcat $i || cat $i; done | grep mysearchtermthis appears to workfind . -type f -print0 | xargs -0 -I{} sh -c 'zcat "{}" 2>/dev/null || cat "{}"' | grep "mysearchterm"Still, that was a speed bump that I guess everyone dealing with mass compressed log files has to figure out on the fly because zcat can’t read uncompressed files ! argg !!!for i in $(ls); do zcat $i 2>/dev/null || cat $i; done | grep mysearchterm

