pigz(1)
pigz is a parallel implementation of gzip that compresses files using multiple processors for faster compression and decompression.
Synopsis
pigz [OPTION]... [FILE]...Description
pigz compresses files in parallel, using multiple cores to speed up gzip compression. It maintains full compatibility with gzip format, so compressed files can be decompressed with standard gunzip or gzip -d. By default, pigz uses all available processors to divide the work.
pigz is especially useful for compressing large files or multiple files simultaneously. It automatically detects the number of CPU cores and distributes compression tasks accordingly, making it significantly faster than single-threaded gzip on modern multi-core systems.
Common options
| Flag | What it does |
|---|---|
-k | keep input files after compression (do not delete) |
-d | decompress instead of compress |
-9 | use maximum compression level (1-9, default is 6) |
-1 | use fastest compression with minimal compression ratio |
-p n | use n parallel threads instead of auto-detected number |
-t | test the integrity of compressed files |
-l | list information about compressed files |
-v | verbose output showing compression details |
-r | recursively compress all files in directories |
-S .suf | use custom suffix for compressed files (default .gz) |
-c | write output to stdout instead of creating new files |
-f | force overwriting of output files |
Examples
Compress largefile.log in parallel, creating largefile.log.gz and removing the original
pigz largefile.logCompress all .txt files in parallel while keeping originals
pigz -k *.txtDecompress file.gz back to original format
pigz -d file.gzCompress backup.tar using exactly 4 parallel threads
pigz -p 4 backup.tarCompress with maximum compression level, keeping the original file
pigz -9 -k largefile.sqlRecursively compress all files in /var/log/ directory
pigz -r /var/log/List compression information and ratios for all .gz files
pigz -l *.gzPipe input through pigz and write compressed output to stdout
cat data.txt | pigz > data.txt.gz