1

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?

David542
  • 104,438
  • 178
  • 489
  • 842

2 Answers2

5

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
John C
  • 4,276
  • 2
  • 17
  • 28
0

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
hek2mgl
  • 152,036
  • 28
  • 249
  • 266