bunzip2
Decompress BZ2 compressed files
TLDR
View documentation for the original command
SYNOPSIS
bunzip2 [options] [files ...]
PARAMETERS
-d, --decompress
Forces decompression. This is the default operation for bunzip2, so it's often implied.
-f, --force
Forces overwrite of existing output files. Without this, bunzip2 will prompt before overwriting.
-k, --keep
Keeps (does not delete) the original input files during decompression.
-q, --quiet
Suppresses all non-error messages, including progress indicators.
-s, --small
Reduces memory usage for decompression at the cost of speed. Useful on systems with limited RAM.
-t, --test
Tests the integrity of the compressed file without decompressing it.
-v, --verbose
Be more verbose, displaying a list of files processed and other information.
-h, --help
Displays a help message and exits.
--version
Displays the version number and exits.
DESCRIPTION
bunzip2 is a command-line utility in Linux systems specifically designed to decompress files that have been compressed using the bzip2 algorithm. It functions as a decompressor for files typically ending with the .bz2 extension.
Essentially, bunzip2 is a symbolic link or hard link to the bzip2 command itself, internally invoking bzip2 -d to perform the decompression. This command is part of the bzip2 compression suite, which is known for its high compression ratios, often outperforming gzip for certain types of data, though it typically uses more memory and is slower during both compression and decompression.
By default, bunzip2 will replace the compressed input file with its decompressed version, similar to gunzip for gzip files. Users can override this behavior using specific options to keep the original file or to force overwriting of existing uncompressed files. It supports processing multiple files, reading from standard input, and writing to standard output, making it versatile for scripting and pipeline operations.
CAVEATS
- Memory Usage: bunzip2 can use a significant amount of memory for decompression, especially for large files. The --small option can mitigate this but at the cost of slower performance.
- File Extension: It only recognizes and decompresses files with the .bz2 (or .bzip2, .bz, etc.) extension by default. Files without the correct extension may need to be explicitly specified or renamed.
- Single File Decompression: Unlike archiving tools, bunzip2 decompresses a single stream/file at a time. For archives containing multiple files (like .tar.bz2), tar is used in conjunction with bunzip2 (e.g., tar xjf file.tar.bz2).
STANDARD I/O USAGE
If no files are specified, bunzip2 will read compressed data from standard input (stdin) and write the decompressed data to standard output (stdout). This makes it ideal for use in shell pipelines, e.g., cat file.bz2 | bunzip2 > decompressed_file.
ERROR HANDLING
bunzip2 provides error messages if a file is not in bzip2 format, is corrupted, or if an output file cannot be written due to permissions or existing files (unless --force is used).
HISTORY
The bzip2 compression algorithm, on which bunzip2 is based, was developed by Julian Seward. The first public release was in 1996, and version 1.0 was released in 2000. It quickly gained popularity for its superior compression ratios compared to gzip for many data types, especially text and executable files, at the cost of increased computational resources. bunzip2 was introduced as a convenience alias to simplify the decompression process, mirroring the gzip/gunzip distinction.