Extract .bz2 File to Another Directory in Linux

Last updated on Dec 28, 2019 in Linux

.bz2 is a compressed file created with bzip2 utility in Linux. Extracting these type of files is straight-forward in Linux, but in order to extract the file to another directory, you need to apply some options. Type the following command in Linux terminal:

$ bzip2 -dc your-file.bz2 > folder/your-file
  • d stands for decompress
  • c tells bzip2 to output the decompressed content to the standard output

In this command we forward the standard output to the specific file in another directory folder/your-file. This also leaves the original .bz2 file unchanged. Also, note that the folder folder must exists before using this command.