pbzip2(1)
Compress or decompress files in parallel using the bzip2 algorithm.
Synopsis
pbzip2 [OPTION]... [FILE]...Description
pbzip2 is a parallel implementation of bzip2 that uses multiple processors to compress and decompress files faster than the standard bzip2. It produces output identical to bzip2 but leverages multi-core systems for improved performance.
When compressing, pbzip2 divides the input into blocks and processes them in parallel. When decompressing, it detects concatenated bzip2 streams and decompresses them concurrently. By default, it uses all available CPU cores.
Common options
| Flag | What it does |
|---|---|
-d | Decompress file instead of compressing |
-c | Write output to stdout instead of a file |
-k | Keep input file (do not delete after compression/decompression) |
-v | Verbose mode; show compression ratio and processing details |
-f | Force overwrite of output file if it exists |
-p NUM | Use NUM parallel threads instead of auto-detecting CPU count |
-m NUM | Use NUM × 900KB blocks for compression (default 9); higher uses more memory |
-q | Quiet mode; suppress non-essential output |
-1 | Compress faster using smaller blocks (equivalent to -m 1) |
-9 | Compress better using larger blocks (equivalent to -m 9) |
Examples
Compress largefile.txt to largefile.txt.bz2 using all available cores
pbzip2 largefile.txtDecompress largefile.txt.bz2 back to largefile.txt in parallel
pbzip2 -d largefile.txt.bz2Compress archive.tar to archive.tar.bz2, keep the original, and show progress
pbzip2 -k -v archive.tarCompress to stdout and pipe directly to a remote server over SSH
pbzip2 -c largefile.txt | ssh user@host 'cat > remotefile.bz2'Compress using exactly 4 threads with maximum compression ratio
pbzip2 -p 4 -9 bigdata.binDecompress and extract a tar archive in parallel in one pipeline
pbzip2 -d -c backup.tar.bz2 | tar -x