It may just be me… but… One thing I tend to do is extract entire tarballs, find the file I want, and then copy the file. Tar can be used to extract a single file from the archive. Further, it will extract the tree. Let’s take a peek at the archive using head and the t option:
srv-8:STORE2 usr4$ tar -tjf non*.bz2 | head sources/ sources/zlib-1.2.3.tar.gz sources/glibc-2.3.5.tar.bz2 sources/shadow-4.0.18.1-useradd_fix-2.patch sources/CleanSourceTrees.sh sources/findutils-4.4.1.tar.gz sources/less-429.tar.gz . . . |
We know the structure. Likely everything is under sources. We want sources/mcj.rsd. Let’s make sure we can find it first using t and v options:
srv-8:STORE2 usr4$ tar -tjvf non*.bz2 sources/mcj.rsd -rwxr-xr-x root/root 52097024 2009-11-03 20:45:16 sources/mcj.rsd srv-8:STORE2 usr4$ |
Note that there is no sources directory:
srv-8:STORE2 usr4$ ls ct mcjnonic.rsd glcomp.txt mcjo.rsd glibc.html network glibc_files ngg journal nonic mcj nonic3.1.sources.tar.bz2 mcjl tkit mcjngg.rsd |
The extraction will create the directory:
srv-8:STORE2 usr4$ tar -xjf nonic*.bz2 sources/mcj.rsd srv-8:STORE2 usr4$ ls ct mcjnonic.rsd glcomp.txt mcjo.rsd glibc.html network glibc_files ngg journal nonic mcj nonic3.1.sources.tar.bz2 mcjl sources mcjngg.rsd tkit srv-8:STORE2 usr4$ ls sources mcj.rsd srv-8:STORE2 usr4$ |
Note that you can match and extract multiple files:
srv-8:STORE2 usr4$ tar -tjvf non*.bz2 sources/XFree* -rw-r--r-- root/root 11985968 2009-05-22 19:50:47 sources/XFree86-4.8.0-src-4.tgz -rw-r--r-- root/root 3163472 2009-05-22 19:50:47 sources/XFree86-4.8.0-src-6.tgz -rw-r--r-- root/root 5907777 2009-05-22 19:50:44 sources/XFree86-4.8.0-src-2.tgz -rw-r--r-- root/root 10618247 2009-05-22 19:50:43 sources/XFree86-4.8.0-src-1.tgz -rw-r--r-- root/root 12840281 2009-05-22 19:50:46 sources/XFree86-4.8.0-src-3.tgz -rw-r--r-- root/root 4680606 2009-05-22 19:50:48 sources/XFree86-4.8.0-src-7.tgz -rw-r--r-- root/root 4351386 2009-05-22 19:50:47 sources/XFree86-4.8.0-src-5.tgz srv-8:STORE2 usr4$ |
To extract from a directory on down, use:
tar -xjf archive.tar.bz2 dir/subdir/ |