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

move tar'd files to different directory

Donald Thaler
Super Advisor

move tar'd files to different directory

create tar file with tar -cvf banLCCC.tar /u01/app/sghe/banLCCC/admin

i want to untar this file in a directory
/u01/app/sghe/banIT and i want the directory structure to look like /u01/app/sghe/banIT/admin
not /u01/app/sghe/banIT/banLCCC/admin

what's the magical unix command to do this..

4 REPLIES
Hasan Atasoy
Honored Contributor

Re: move tar'd files to different directory

hi;

a bit trickway is

cd /u01/app/sghe/banLCCC/admin
tar cvf ../banLCCC.tar ./*
mkdir /u01/app/sghe/banIT/admin
mv /u01/app/sghe/banLCCC/banLCCC.tar .
tar xvf banLCCC.tar



Hasan

James R. Ferguson
Acclaimed Contributor

Re: move tar'd files to different directory

Hi:

Use 'pax' in lieu of 'tar'...since you 'tar'ed with absolute paths.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: move tar'd files to different directory

> Use 'pax' in lieu of 'tar' [...]

Or GNU "tar". A Forum search should find
many examples.
Dennis Handly
Acclaimed Contributor

Re: move tar'd files to different directory

As JRF mentioned, pax's -s option will allow you to change the path of your files when you extract.

You might want to experiment with a small tarfile first.