Operating System - HP-UX
1833869 Members
1616 Online
110063 Solutions
New Discussion

Restoring one file from a tar archive

 
Andrew Kaplan
Super Advisor

Restoring one file from a tar archive

Hi there,

I am trying to restore a single file from a tar archive. The syntax that I used was

tar -xvf ./seaberg/1lmn.egsimp

The problem I am confronting is tar restoring the entire seaberg directory contents rather than just the 1lmn.egsimp file. What other syntax do I need to have in the command?
A Journey In The Quest Of Knowledge
5 REPLIES 5
Massimo Bianchi
Honored Contributor

Re: Restoring one file from a tar archive

Hi,
the sintax is

tar -xvf ARCHIVE FILE


when you put the "-f" you are going to specify the file you want to use (e.g. myfile.tar) or a tape device, (e.g. /dev/rmt/0m).

So

ARCHIVE = yourarchive

FILE =
./seaberg/1lmn.egsimp

Supposing you want to extract the file you have mentioned in the mail.

HTH,
Massimo
Frederic Sevestre
Honored Contributor

Re: Restoring one file from a tar archive

Hi,

# tar xvf seaberg 1lmn.egsimp

(tar xvf archive file)

Regards,
Fr??d??ric
Crime doesn't pay...does that mean that my job is a crime ?
Robert-Jan Goossens
Honored Contributor

Re: Restoring one file from a tar archive

Hi,

Restore one file
#tar xvf /dev/rmt/0m (file)

Here is a good doc,

http://www5.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000063197953

Hope it helps,

Robert-Jan.
Patrick Wallek
Honored Contributor

Re: Restoring one file from a tar archive

Was the tar archive created to a file or to a tape?

If you created a tarball file try:

# tar -xvf filename.tar ./seaberg/1lmn.egsimpz

If you created a tar tape:

# tar -xvf /dev/rmt/?m ./seaberg/1lmn.egsimp

To see what exactly is in the tar file so you can get the file name syntax correct:

# tar -tvf filename.tar

or

# tar -tvf /dev/rmt/?mn
Jeff Schussele
Honored Contributor

Re: Restoring one file from a tar archive

I agree with Patrick.
You need to do a tar tvf on the input file/device to determine whether the file paths are absolute (/path/to/file) or relative (./path/to/file)
You must use the proper syntax in the command - either:

Absolute -> tar xvf /dev/rmt/0mn /path/to/file

Relative -> tar xvf /dev/rmt/0mn ./path/to/file

Using the wrong syntax will not work.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!