bzcat
View compressed bzip2 files
TLDR
View documentation for the original command
SYNOPSIS
bzcat [options] [files...]
PARAMETERS
-f, --force
Force overwrite of output files (though output is stdout, this might affect error handling for existing files in some contexts).
-q, --quiet
Suppress non-essential output messages, warnings, and error messages.
-s, --small
Reduce memory usage for decompression. This trades off speed for memory, useful on systems with limited RAM.
-t, --test
Test the integrity of the specified compressed file(s). It decompresses the file and discards the output, reporting only if the file is valid.
-V, --version
Display the version number of bzip2 (and thus bzcat) and exit.
-L, --license
Display the bzip2 software license and exit.
DESCRIPTION
bzcat is a command-line utility in Linux (and Unix-like systems) used to decompress bzip2 compressed files and output their content to standard output.
It is essentially the cat equivalent for bzip2 files, meaning it does not modify the original compressed file but streams its decompressed content. This is particularly useful for viewing the content of a compressed file without decompressing it permanently, or for piping the decompressed output directly to another command for further processing (e.g., bzcat file.bz2 | grep "pattern").
It functions as a wrapper around bzip2 -dc or bzip2 --decompress --stdout. Unlike bunzip2 (or bzip2 -d), bzcat does not remove the input file after decompression. It handles multiple input files by decompressing and concatenating them in the order specified. If no files are given, or if a hyphen (-) is given as an argument, bzcat decompresses from standard input.
CAVEATS
Binary Data: If the original file contains binary data, outputting it directly to a terminal might result in unreadable characters or disrupt terminal settings.
Compression Format: bzcat only works with bzip2 compressed files (files ending with .bz2). It cannot decompress files compressed with gzip (.gz) or xz (.xz).
Error Handling: Errors within a compressed file will typically halt the decompression process.
Performance: Decompression adds overhead, making bzcat slower than plain cat for uncompressed files.
USAGE WITH PIPES
bzcat is frequently used as the initial command in a pipeline, sending its decompressed output directly to other commands for further processing, such as grep, awk, sed, less, or more. For example: bzcat logfile.bz2 | grep "ERROR".
NO FILE MODIFICATION
A key characteristic of bzcat is that it never modifies or deletes the original .bz2 input file(s). This contrasts with bunzip2 (or bzip2 -d), which by default replaces the compressed input file with its decompressed version.
HISTORY
bzip2, the compression algorithm and utility suite that includes bzcat, was developed by Julian Seward. The first stable version, bzip2 0.1, was released in July 1996, with version 1.0 following in 2000.
bzcat was introduced as a convenient wrapper, mirroring the functionality of zcat (from the gzip suite) and the general behavior of cat. Its purpose is to provide a consistent and easy-to-use interface for decompressing and viewing bzip2 files without modifying the originals, fitting seamlessly into the Unix philosophy of chaining commands via pipes.