1

Why isn't there any difference (output filesize) with these command lines?

Gzip stdin

The output files have same filesize even though the compression levels are different

tar ... | gzip -c -1 > ...
tar ... | gzip -c -9 > ...

xz stdin

The output files have same filesize even though the compression levels are different

tar ... | xz -c -1 > ...
tar ... | xz -c -9 > ...

Gzip

The output files have same filesize even though the compression levels are different

GZ_OPT=-1 tar -zcf ...
GZ_OPT=-9 tar -zcf ...

xz

The output files have same filesize even though the compression levels are different

XZ_OPT=-1 tar -Jcf ...
XZ_OPT=-9 tar -Jcf ...
  • 2
    They look quite different to me. Perhaps you can edit to explain what aspect you're interested in? – Michael Homer Dec 25 '15 at 19:54
4

The gzip compression level does not guarantee that higher compression levels result in smaller output. In fact the BUGS section of my man gzip notes that in some cases it can be the opposite.

For xz (and bzip2), this is even more documented, as according to the manual the numerical level controls the amount of memory used by the compressor. Using more memory is supposed to make better compression, but again this is not guaranteed.

Especially if your test data is small, having the same size output is not surprising to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.