I have a .tar.bz2 file that I want to be decompressed and extracted via the 7-zip commandline tool.
So basically I'm looking for the equivalent of
tar -xjf foo.tar.bz2
with 7-zip there is only the option "x" for extract, so doing
7z x foo.tar.bz2
gives me the inflated foo.tar file instead of unpacking all the directories inside the tar.
What's the corresponding option for 7z?
Best Answer
With 7zip, you have to run the command twice, once to decompress and again to extract. The tar file format is just a "wad" of everything stuck end to end. Then the whole tar file is compressed using various compression algorithms, in your example bzip. Basically the resulting file has two layers. When you "extract" the bzip layer you get a tar file, then when you extract the tar file you get a bunch of individual files.
7zip doesn't handle multiple layers at once, although it is able to handle both layers:
Actually the standard unix tools work the same way:
However the the unix
tar
command has convenience features that call the secondary compression and decompression steps using another program before/after it handles the tar part. Basically the-j
argument callsbzip2
/bunzip2
, you just don't see the second step. Likewise-z
will callgzip
/gunzip
, etc.