Operating System - HP-UX
1832413 Members
2813 Online
110042 Solutions
New Discussion

Unpacking a tar file into a different directory

 
SOLVED
Go to solution
Pete Mattison
Advisor

Unpacking a tar file into a different directory

I have a tar file "mysql-3.23.32-hp-hpux10.20-hppa1.1.tar" which when unpacked naturally ends up with the "mysql-3.23.32-hp-hpux10.20-hppa1.1" directory.

Is it possible to unpack the tar file into the directory /usr/local/mysql? or do I have to unpack the file then rename the directory?

I'm curious to see if this is possible - tried tar xvf "file.name" -C /usr/local/mysql but the computer didn't do anything, didn't complain either.

Pete
4 REPLIES 4
Thierry Poels_1
Honored Contributor
Solution

Re: Unpacking a tar file into a different directory

hi,
if fixed directory path has been used to create the tar file, then I'm afraid there's is no way in restoring them elsewere. An alternative would be to create a link to the directory where you want the files to be dropped.

BTW the name of the tar file does not have to contain the destination directory name.

good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
John Bolene
Honored Contributor

Re: Unpacking a tar file into a different directory

Since you already have a tar file, tar will use the same directory structure in which it was saved. The path names can be relative or absolute. Absolute means that you have no control where it goes, it will go where it was saved from. Relative means that you can put the file under any other directory that you want it, but you will have to move it if that is not where you wanted it.

You can use the pipeline to create a tar and pipe it to another directory or machine.

An example would be tar cf - stufftobackup | remsh remotemachine 'cd /whateversubdir;tar xf -'
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
Pete Mattison
Advisor

Re: Unpacking a tar file into a different directory

Okay, at least I know now and thanks for telling me :-)

Pete
Darren Miller
Advisor

Re: Unpacking a tar file into a different directory

Pete,

Here's a kludge that should work for you:

# mkdir /usr/local/mysql
# ln -s /usr/local/mysql /mysql-3.23.32-hp-hpux10.20-hppa1.1
# tar -xvf mysql-3.23.32-hp-hpux10.20-hppa1.1.tar
# rm /mysql-3.23.32-hp-hpux10.20-hppa1.1

Hope that helps.

Darren