1828248 Members
2747 Online
109975 Solutions
New Discussion

tar command

 
SOLVED
Go to solution
Manuales
Super Advisor

tar command

hi
i have a tar file files.tar
the contents is:
/home/user1/files/file1/*.*
/home/user1/scripts/scrpts/*.*
...........
...........

i want to untar the files under /opt
how can i untar the files ..
i'm using
tar -xvf interface.tar

but it is being un tar the files under /home filesystem, i want they be untar under /opt fs
how can i do that?

thanks.
6 REPLIES 6
whiteknight
Honored Contributor
Solution

Re: tar command

Manuale,

You are backup using tar with relative path, you should tar in current directory.

You may not be able to untar in /opt.


WK
Problem never ends, you must know how to fix it
Manuales
Super Advisor

Re: tar command

how can i tar the files without using relative path?
Dennis Handly
Acclaimed Contributor

Re: tar command

If the contents are absolute paths, you need to use pax(1) -s option to rename them.

>how can I tar the files without using relative path?

You already did. Or did you mean untar?
In that case you need to use pax(1).
$ cd /opt
$ pax -r -f interface.tar -s:/home/user1/::

This will create /opt/files and /opt/scripts

>WK: You may not be able to untar in /opt.

Sure you can. Unless you mean you have to unpax them. :-)

Steven Schweda
Honored Contributor

Re: tar command

Dennis Handly
Acclaimed Contributor

Re: tar command

>Steven: Or GNU "tar".

pax(1) is supported and Posix standard.
Steven Schweda
Honored Contributor

Re: tar command

> pax(1) is supported and Posix standard.

And GNU "tar" works, and claims a level of
POSIX compliance/conformance:

http://www.gnu.org/software/tar/manual/tar.html#posix

A statement like "You need to use pax.",
while common around here, is not strictly
true. It may be true that "pax" will solve
the problem, but "pax" is not the only
solution, and it may not be the _best_
solution. (Isn't this obvious?)