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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract a tar file

Status
Not open for further replies.

clkaren

MIS
Sep 3, 2001
10
0
0
SG
Hi all,

I have backup a file with the tar command (with absolute path.)
I need to extract the tar file but do not have sufficient disk space in the absolute path.
How can I specify to extract the file to another directory instead.

Any advise will be appreciated, thks.
Karen
 
If your original file is in directoryA and is called yourfile

cd /directoryB
tar cvf newfile.tar directoryA/yourfile (writes tar to newfile.tar)

ls -l

newfile.tar

To extract: -

tar xvf newfile.tar

This should work

 
Hello

Try chroot command

Following example in man chroot does exactly what you want

Example 1: Using the chroot utility.

The chroot utility provides an easy way to extract tar files
(see tar(1)) written with absolute filenames to a different
location:

example# cp /usr/sbin/static/tar /tmp
example# dd if=/dev/nrst0 | chroot /tmp tar xvf -

Note that tar is statically linked, so it is not necessary
to copy any shared libraries to the newroot filesystem.
 
What I should have said is: -
If your original file is in directoryA and is called yourfile

cd /directoryA
tar cvf yourfile.tar directoryB/yourfile (writes youyfile to yourfile.tar)
cd directoryB

ls -l

yourfile.tar

To extract: -

tar xvf newfile.tar

This should work!
 
The main point is to use absolute pathing.

tar cvf /$PATH_to destination/tarfile.tar /$PATH_of_source_ directory/
 
Hi all,

Thanks for responsing. But I need some clarification regarding the usage of chroot command.

What I have done:
=================

# tar -cvf /karen/mon.tar /opt/test/backup

# cp /usr/sbin/tar /tmp

# dd if=/karen/mon.tar |chroot /tmp tar xvf -
tar: Cannot find /usr/lib/ld.so.1
Killed
------------------------------------------------
What I want to achieve is to extract the mon.tar file to /tmp.

Is this possible and how can I achieve it.
And where can I locate /usr/lib/ld.so.1

thanks.



 
Hello

Copy /usr/sbin/static/tar to /tmp directory and
not /usr/sbin/tar.

All other steps you have done are correct.

Sharad
 
Hi sharadmarathe,

I have try but cannot locate /usr/sbin/static directory.
My tar command is located at /usr/sbin/tar.

Any idea,thks.

 
Hi

It is really strange. All systems in our environment (Solaris 7 & 8) does contents /usr/sbin/static directory and following files in to it.

cp, ln, mv, rcp & tar

:(
 
wouldn't it be easier just to make a link to the tar file in /tmp and then extract it from /tmp?
 
it looks like you are tarring with absolute pathing, but you don't want to extract absolute pathing. Why can't you tar with relative pathing?

cd /opt/test/backup
tar -cvf /karen/mon.tar *
cd /tmp
ln -s /karen/mon.tar mon.tar
tar xvf mon.tar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top