Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

untar to a specific directory

Donald Thaler
Super Advisor

untar to a specific directory

file was created as tar-cvf file.tar /u01/app/oracle/product/10.2.0


i want to untar it into /u04 what would the command be ??

8 REPLIES

Re: untar to a specific directory

I would take a look at using pax to read the tar archive and strip/change the leading directories, as this has been created with absolute paths.
man pax
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Mark McDonald_2
Trusted Contributor

Re: untar to a specific directory

you might be able to do something with chroot, then move the files afterwards.

In future don't create the tar files with the fill path.
Dennis Handly
Acclaimed Contributor

Re: untar to a specific directory

As Melvyn said you need to use pax or GNU tar:
pax -f file.tar -r -s":/u01:/u04:"
Donald Thaler
Super Advisor

Re: untar to a specific directory

what is the command I should have executed which would have allowed me to create a tar file from the directory /u01/app/oracle/product/10.2.0, and allow me to untar it to a /u04 directory. ?

What is a 'fill path' ?
Steven Schweda
Honored Contributor

Re: untar to a specific directory

> [...] what is the command I should have
> executed [...]

Use "cd" to get past the part of the path
which you don't want, and don't use a leading
slash in the "tar" command. For example:

cd /u01
tar cf x.tar app/oracle/product/10.2.0

cd /u04
tar xf ../u01/x.tar

(Of course, if you just wanted to copy the
whole tree, a pipeline could obviate the
"tar" archive itself.)


> What is a 'fill path' ?

What's the key jist to the left of the "I"?
Dennis Handly
Acclaimed Contributor

Re: untar to a specific directory

>what is the command I should have executed

Why worry about it when you have a better utility pax, that allows renaming?
sujit kumar singh
Honored Contributor

Re: untar to a specific directory

Hi

To achieve that i would always do it that in a way like

#cd /u01/app/oracle/product/10.2.0
#tar cvf /u04/file.tar *

Once that is over , go to another directory say /u04

#cd /u04
#tar xvf file.tar .

you can also take the help of fbackup if like

#cd /u01/app/oracle/product/10.2.0
#fabckup -0vf /u04/file.back /u01/app/oracle/product/10.2.0

#cd /u04
#frecover -rXf file.back
regards
sujit
Steven Schweda
Honored Contributor

Re: untar to a specific directory

> [...] i would always do [...]
> #tar cvf /u04/file.tar *

I would (almost) never use "*" that way. It
will miss dot-names (like ".profile"), and
the result might exceed the command line
length limit (if "*" expands to a long list).

> #tar xvf file.tar .

Why "."? Did you try this?