I have a file as: filename.bz2 I need to decompress.
I have tried the command: tar xvjf filename.tar.bz2, but it didn't work as the file is not a tar file.
How do I decompress this file?
06 Answers
Try the following:
bzip2 -d filename.bz2Note, that this command will not preserve original archive file.
To preserve the original archive, add the -k option:
bzip2 -dk filename.bz2 4 To explain a bit further, a single file can be compressed with bzip2 thus:
bzip2 myfile.txt
tar is only required when compressing multiple files:
tar cvjf myfile.tar.bz *.txt
Hence, when uncompressing a .bz2 file use bunzip, when uncompressing a tar.bz2 file use tar xjvf.
Use the bunzip2 (or bzip2 -d) command to decompress the file. For more information see this man page,
bzip2 is mono-threaded, which means it will take a long time to decompress a large file.
To decompress a .bz2 file multithreadedly, you can use the free, open source program lbzip2:
sudo apt-get install lbzip2
lbzip2 -d my_file.bz2-d indicates you wish to decompress the file. It would automatically determine how many threads it will use. To specify the exact number of threads you want to use, use the -n parameter, e.g.:
lbzip2 -d -n 32 my_file.bz2A few more useful commands with lbzip2:
To compress a file with a progress bar:
pv adb_int.tar | lbzip2 > adb_int.tar.bz2Requirements for the progress bar:
sudo apt-get install -y pvTo compress a folder:
tar -c -I lbzip2 -f file.tar.bz2 folder_nameTo uncompress a folder:
tar -I lbzip2 -xvf file.tar.bz2Parameters:
-I, --use-compress-program PROG filter through PROG (must accept -d)
-x, --extract, --get extract files from an archive
-v, --verbose verbosely list files processed
-f, --file ARCHIVE use archive file or device ARCHIVESome alternatives to decompress a .bz2 file multithreadedly:
sudo apt-get install pbzip2
pbzip2 -d my_file.bz2mpibzip2: designed to be used on on cluster machines.
If you need some large .bz2 files to experiment with:
For example (a 14 GB .bz2 file, 200 GB uncompressed):
wget
lbzip2 -d -n 32 wikidatawiki-20170120-pages-articles-multistream.xml.bz2 did the benchmark:
For further information regarding the parameters for lbzip2: :
bzip2 -dc my_file.tar.bz2 | tar xvf -worked for me on cygwin
4- Go to .
- Upload the file.
- Convert it into a .tar file.
- Download it.
- Extract it from there, in your terminal.