Can you untar selectively?

Paul Almquist paul at almquist.name
Wed Jun 15 06:27:31 UTC 2005


On Tuesday 14 June 2005 22:04, stefaan wrote:
> How would I go about untarring a particular file selectively out of a
> tarball.
>
> Is this possible at all if I know the path/filename existing in the
> tarball?
yup, use:
tar -xf tarfilename  path/of/desired/file

If not sure of path/of/desired/file use
tar -tf tarfilename
to get a list of contents
Paths are relative paths, i.e., they do not start with a /
when extracted the desired file is in the path as specified starting in your 
current directory.  I think that there is an option to put it elsewhere.

If tar file is compressed with gzip insert the "z" option before the "f"
tar does not care about the format of the tarfile name.  It does not require 
a .tar suffix.

If the tarfile is compressed and you forget the "z" option it will say that 
the file does not look like a tar file.  You can also use the "file" command 
to find out what the file contents is.
-- 
Paul Almquist
paul at almquist.name
Eau Claire, WI  USA




More information about the fedora-list mailing list