tar question: how do I extract some files without extracting directories.

tar question: how do I extract some files without extracting directories.

Post by Erik Terpstr » Thu, 13 Mar 2003 01:18:49



For example, if I have foo.tar.gz consisting of:

foo/
   bar/
     baz/
       file1.png

What (GNU) tar options do I have to use to extract the file 'file1.png'
to ~/tmp without the directory hierarchy 'foo/bar/baz'?

Something like:

  $ tar zx ~/tmp/file1.png f foo.tar.gz   #This does not work...

Should produce:

~/tmp/
   file1.png

Any thoughts?

TIA,

   Erik.

 
 
 

tar question: how do I extract some files without extracting directories.

Post by Nils Petter Vaskin » Thu, 13 Mar 2003 18:13:33


[snip]

I already answered this on comp.os.linux.misc
Don't multipost, if you think your post is relevant for several
newsgroups crosspost (to a small number) instead.

Multipost == posting identical messages to several groups
Crosspost == ONE post that shows up in several newsgroups, replies will
show up in all the groups not just in the one where the reply was made.

NP

 
 
 

tar question: how do I extract some files without extracting directories.

Post by Bill Marcu » Thu, 13 Mar 2003 22:38:18


On Tue, 11 Mar 2003 17:18:49 +0100, Erik Terpstra

> For example, if I have foo.tar.gz consisting of:

> foo/
>    bar/
>      baz/
>        file1.png

> What (GNU) tar options do I have to use to extract the file 'file1.png'
> to ~/tmp without the directory hierarchy 'foo/bar/baz'?

> Something like:

>   $ tar zx ~/tmp/file1.png f foo.tar.gz   #This does not work...

> Should produce:

> ~/tmp/
>    file1.png

> Any thoughts?

tar zxfO foo.tar.gz foo/bar/baz/file1.png > ~/tmp/file1.png