- The pbzip2 command will compress a single file:
pbzip2 myfile.tar
pbzip2 detects the number of cores on your system and compresses myfile.tar, to myfile.tar.bz2.
- To compress and archive multiple files or directories, we use pbzip2 in combination with tar, as follows:
tar cf sav.tar.bz2 --use-compress-prog=pbzip2 dir
Alternatively, this can be used:
tar -c directory_to_compress/ | pbzip2 -c > myfile.tar.bz2
- Extracting a pbzip2 compressed file is as follows:
The -d flag will decompress a file:
pbzip2 -d myfile.tar.bz2
A tar archive can be decompressed and extracted using a pipe:
pbzip2 -dc myfile.tar.bz2 | tar x