Bzip2 Compression Tool - Compress & Decompress Files

Compress and decompress files using the Bzip2 command-line tool. Learn how to zip and unzip files efficiently with Bzip2 for optimal data compression.

Bzip2 Compression Utility

Bzip2 is a free and open-source software utility for data compression. It is known for its high compression ratios, often outperforming older algorithms like LZW and Deflate, making it a popular choice for archiving and distributing large files. This utility is commonly used on Unix-like operating systems.

Compress Files with Bzip2

To compress a file named foo into a new file named foo.bz2, you can use the -z option:

bzip2 -z foo

Decompress Files with Bzip2

To decompress a file named foo.bz2 back to its original form (foo), use the -d option:

bzip2 -d foo.bz2

Compress to Standard Output

You can compress a file and send the output directly to standard output (stdout) using the -c option. This is useful for piping the compressed data to another command or redirecting it to a file without modifying the original file.

bzip2 -zc foo > foo.bz2

Decompress to Standard Output

Similarly, you can decompress a Bzip2 archive and send the output to stdout using the -c option with -d.

bzip2 -dc foo.bz2

Understanding Bzip2 Options

  • -z: Compress a file.
  • -d: Decompress a file.
  • -c: Output to standard output (stdout).

External Resources