The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
  

Compressing / Decompressing bz2 Files with bzip2



bzip2 is specifically designed for compressing and decompressing bz2 files (with a ".bz2" file extension). bzip2 typically achieves higher compression ratios compared to another compression tool, gzip. Commonly used options and parameters include "-d" for decompression, "-[1~9]" to specify compression levels (higher numbers result in higher compression ratios), and "-c" to output to standard output.

Example:

$ bzip2 * ←Compress all files in the current working directory
$ bzip2 -d *.bz2 ←Decompress all ".bz2" files in the current working directory
$ bzip2 -9 *.cpp ←Compress all ".cpp" files in the current working directory with compression level 9

For more examples, explanations, and parameter references about bzip2, please refer to the provided link.