[SunHELP] extract tar file in the current directory?

Steve Sandau ssandau at gwi.net
Wed Nov 24 07:31:07 CST 2004


>>I have a tar file what I want to extract in a
>>temporary directory.
>>The problem is that the tarball has been created
>>by using the full-paths...
> 
> 
>>If I'd extract it in /tmp than it still overwrote
>>the original files in /opt/package...
> 
> 
>>Can I force tar to extract the files in the /tmp
>>directory?
> 
> 
> Unless you specify -P tar should remove the leading slashes,
> e.g.: 
> $ pwd
> /tmp/tmp
> $ tar tvf mytest.tar
> drwxr-xr-x andreas/andreas   0 2004-11-24 09:32:07 /tmp/test/
> -rw-r--r-- andreas/andreas   0 2004-11-24 09:32:07 /tmp/test/bla
> $ tar xvf mytest.tar
> tar: Removing leading `/' from member names
> /tmp/test/
> /tmp/test/bla
> $ ls -l
> -rw-r--r--  1 andreas andreas 10240 2004-11-24 09:33 mytest.tar
> drwxr-xr-x  3 andreas andreas  1024 2004-11-24 09:36 tmp
> 
> Also, the update flag (-U) might be an option for you.
> 
> 

Solaris tar will *keep* leading slashes unless you specify -p when you 
create the archive. GNU tar will *remove* leading slashes by default.

If you have an archive made with Solaris tar update might be a good 
option as mentioned above. You might also get away with some type of 
chroot setup to extract. though I have no idea what libs tar needs.

Here's a Sunmanagers' summary from 1988 on the same subject. It talks 
about GNU tar, Solaris tar and a chroot process:

http://www.netsys.com/sunmgr/1998-02/msg00136.html

Steve Sandau



More information about the SunHELP mailing list