Unzip a single file in a tbz archive

1.8k Views Asked by At

I have the following archived directory:

itunes20140618.tbz

I want to extract single file from it called:

itunes20140618/video

How would I do this?

So far, I am doing

$ bzip2 -d /tmp/itunes20140618.tbz 

But it seems to create a tar directory of everything. How would I extract just the single video file?

2

There are 2 best solutions below

0
On BEST ANSWER

There are a few different versions of tar around, but on my machine I can do this:

tar xjf archive.tbz filename

To extract filename from archive.

If that doesn't work you can use:

bzip2 -dc archive.tbz | tar xvf - filename

Which uses bzip2 to extract to stdout and then pipe to tar.

In both cases you can replace the x option with t to get a list of files. Eg:

tar tjf archive.tbz
0
On

You can use the tar command and pass the path of the desired file or folder as an argument to it:

tar xjf test.tbz /path/to/file/in/archive