bzip2
Archives
Usage
bzip2 [-k] <file>Squeezes harder than gzip but takes longer, and like gzip it deletes the original and leaves only the .bz2 unless you pass `-k`; the tar flag for it is `-j`, and decompressing is `-d`, which is what bunzip2 does.
Common flags
| Flag | Meaning |
|---|---|
| -k | Keep the original, which it otherwise deletes. |
| -d | Decompress; bunzip2 is the same thing. |
| -c | Write to stdout. |
| -1 / -9 | Block size from 100k to 900k. -9 is the default. |
| -t | Test integrity. |
Examples
bzip2 -k bigfile.logCompress but keep the original.
bzip2 -dc data.bz2 | wc -lCount lines without unpacking to disk.
tar -cjf logs.tar.bz2 ./logsThe tar flag for bzip2 is -j.
Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does bzip2 do?
Squeezes harder than gzip but takes longer, and like gzip it deletes the original and leaves only the .bz2 unless you pass `-k`; the tar flag for it is `-j`, and decompressing is `-d`, which is what bunzip2 does.
Q. How do I type it?
bzip2 [-k] <file> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man bzip2. This command sits under Archives.
Related commands
man page: man bzip2