Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tar file: extracting files

Status
Not open for further replies.

cptk

Technical User
Mar 18, 2003
305
US
I have a Solaris 8 tar file containing files with prefixes all starting with /opt/somedir/blahblah... But unfortunately I can't extract the blahblah files to another workstation because I don't have root access to the /opt/ directory...and I can't temporary create /opt/somedir/.

Is there a way to extract the files and in effect ignore the leading /opt/somedir directory?

HISTORY:
Basically, what happen was that I needed to back-up my entire home directory (/opt/somedir/....) to copy to a new box. But the new box's "home" directory structure is setup a little differently compared to the older box-- it's now /export/home/somedir.

Can I use the arch cmd? How in an extract?

Yes, I know I should of been a little more careful by first cding to the /opt/somedir/ directory before creating the tar file!

Thanks ...
 
tar -xvA tarfile

"A" option if available in Solaris will remove the absolute pathname, and extract to the current directory.
If not available then do a "man tar" to see which one will be




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
You can also untar it in your preferred directory with no problems, it will simply create a /opt/ and subdirs in your present dir. Then navigate into the /opt/somedir/ and mv the subdirs to wherever you want them.

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
That's not true on Solaris aixmurderer. If you create a tar with full path names the files will always be extracted relative to root.

One way to get around it is to do the following:

[tt]mkdir /destdir
cp /usr/sbin/static/tar /destdir
cat /tmp/tarfile.tar | chroot /destdir ./tar xvf -[/tt]



Annihilannic.
 
Never used it my self but here is a note I saw on this..

There is an easy way to do
this using the "pax" command.
Note: Not available on all
flavors.

Firstly, copy the archive to
the relative location in
which you wish to untar it.

Then, execute the following
command:

pax -r -s ',^/,,' -f file.tar

The contents of file.tar will now
be in the $CWD.


In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top