Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In my application I need do compress of logs that are text files.

Seems that bzip2 and gzip have the same compression ratio.

Is that correct?

share|improve this question

migrated from stackoverflow.com Dec 1 '11 at 12:49

This question came from our site for professional and enthusiast programmers.

xz (from xz-tools or 7z from p7zip, it is very like lzma) is the best. bzip2 is better than gzip. –  osgx Dec 1 '11 at 12:36

5 Answers 5

up vote 3 down vote accepted

Normally, bz2 has a better compression ratio, combined with better recoverability features.

OTOH, gz is faster.

xz is said to be even better than bz2, but I don't know the timing behaviour.

share|improve this answer
xz is slower than bzip2. –  osgx Dec 1 '11 at 14:46

Maybe you could have a look to those benchmarks, especially the part testing the log files compression.

share|improve this answer

bz2 has tighter compression, the algorithm has more options to look for redundancy to compress away.

gzip is in much more tools, and is more cross platform. More Windows tools can deal with .gz files. It's part of http, so even web browsers can understand it.

On linux, there are tools that let you work on compressed files directly. zgrep and bzgrep can search in compressed files.

If just on Linux, I'd use bzip2, for the slightly better compression ratios.

share|improve this answer

xz compresses much better than bz2, but takes more time. So, if maximum compression is your goal and space on your hard drive is at a premium (which is my case with one drive at 98% full - while I reorganize my file systems), and you can fire off a script to do the work - take a break and come back in 5 minutes.

unxz is very fast to uncompress in my experience - which is a good thing for me on a daily basis.

bz2 is faster to compress than xz, but does not appear to achieve the compression results of xz.

The only way to make these assessments is to run benchmarks against a mix of common files you normally would compress/decompress, and vary the parameters to see which comes out on top.

share|improve this answer

cmix is the current best text compressor based of these three competitions:

More details: Byron Knoll develops cmix as libre software (GPL) since 2013 based on the book Data Compression Explained by Matt Mahoney. Matt Mahoney also maintains the above three benchmarks and proposes ZPAQ (WP), a command line incremental archiver.

If you prefer a more standard tool I advice lrzip as proposed in the Alexander Riccio's answer.

More details: lrzip is an evolution of rzip by Con Kolivas and can stand for Long Range ZIP and for Lzma RZIP too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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