tar: extract single file to different filepath

Hi,

This is my first post here - I'm hoping I can get some help! I have searched these forums and othersand not getting anything that works.

I am trying to extract a single file from a tar archive to a diffierent location than it will default to.

For example my tar log shows me ...

a /scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/ 0K
a /scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/README.txt 4K
a /scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/multi_runs/ 0K
a /scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/multi_runs/PB0012.run 2K

... and I want to extract this file ...

/scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/multi_runs/PB0012.run

... to ...

/home/nlthoa/tmp

So how can I do that?

The system will not allow me to recreate the original file path, and I do not want the entire contents either.

I am working in Solaris 8 (I think)

uname -a
SunOS xxxxxx-x-xxxxxx 5.8 Generic_117350-51 sun4u sparc SUNW,Sun-Fire-V440

Any help appreciated!

Thanks,
lil'

Unfortunatly, this might e tough to get round. The problem is that when the tarball was created, it was done so using absolute paths (generally a bad thing to do in tar).

Different versions of tar handle absolute paths differently, some ignore it on restore (which is sort of what you want), some ignore it during creation and do it relative instead. Some honour it one way, some both.

I would suggest grabbing a copy of gnu tar (it's a bit different from Sun tar) and trying that. You might find it'll be able to extract your file relative to your homedir instead.

A collegue found a work around - he created a link file in the top level directory (as root) that pointed to some other place, and when I ran the noraml untar, all the data came out as I wanted it.

I agve up trying to get just one file out of the tarball.

Thought I'd just post this for the sake of completness.

We have worked on some application which was meant to uncompress tar files. Due to security reasons (hopefully you know about tar bombs, don't you?) data extraction (and decompression when input files were *.tar.gz) was made using some open-source JAVA module that can handle *.tar packages. And what is more important - this module can skip the paths.