1752587 Members
4805 Online
108788 Solutions
New Discussion юеВ

Re: tar command

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

tar command

Hi

i've a tar with /path1/path2... stored in.
I would like to extract the tar in a /test directory to have /test/path1/path2 ...

If i do
cd /test
tar xvf /tmp/fic.tar the extraction go directly to /path1

How to do this ?

Regards
Den
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: tar command

Shalom,

The man tar command shows the -C option. This might work.

Or change directory to the destination and tar xvf the tarfile from there.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Fat Scrape
Honored Contributor

Re: tar command

Hi,

If i do
cd /test
tar xvf /tmp/fic.tar the extraction go directly to /path1

Yes.

Regards,


A. Clay Stephenson
Acclaimed Contributor
Solution

Re: tar command

To use tar to restore files backed up with absolute pathnames, you have to do a chroot first. Man 1m chroot for details.

There is a much better way: Don't use tar use pax. Pax has a -s option that allows you to substitutes pathnames that match one pattern with another and pax can read tar, cpio, and pax archives. Man pax for details.


In the future, avoid creating backups with absolute pathnames. Instead cd / then tar so that the archived files have relative pathnames. Restores to other locations are then much easier.
If it ain't broke, I can fix that.
Leo The Cat
Regular Advisor

Re: tar command

-C is the good way
Thanks to you.

Den
Dennis Handly
Acclaimed Contributor

Re: tar command

>-C is the good way

-C only works when creating the tarfile.