The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to unzip and extract tar file in single command darkrainbow UNIX for Advanced & Expert Users 6 02-28-2008 08:18 PM
extract bulk emails into a single flat file Amruta Pitkar Shell Programming and Scripting 1 01-21-2007 06:37 PM
splitting up of absolute filepath DILEEP410 Shell Programming and Scripting 5 01-10-2007 05:45 AM
A single file for many commands zenla15 Shell Programming and Scripting 2 07-16-2006 01:16 PM
Restoring a single file...??? Jonathan UNIX for Dummies Questions & Answers 1 05-08-2002 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-28-2008
littleIdiot littleIdiot is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 14
Question 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 ...

Code:
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 ...
Code:
/scratch2/no_archive/nlthoa/input_files/EGIS_EXPORTS/multi_runs/PB0012.run
... to ...

Code:
/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)
Code:
uname -a
SunOS xxxxxx-x-xxxxxx 5.8 Generic_117350-51 sun4u sparc SUNW,Sun-Fire-V440
Any help appreciated!

Thanks,
lil'
  #2 (permalink)  
Old 02-28-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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.
  #3 (permalink)  
Old 02-29-2008
littleIdiot littleIdiot is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 14
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.
  #4 (permalink)  
Old 02-29-2008
adderek adderek is offline
Registered User
  
 

Join Date: Sep 2007
Location: Poland
Posts: 111
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0