untar | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

untar

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-02-2008
allwin allwin is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 24 July 2012, 10:38 AM EDT
Posts: 11
Thanks: 4
Thanked 0 Times in 0 Posts
untar

Hi,

How can i untar a set of files in to different directory.

This is content

tar -tvf samba.tar
drwxrwxrwx 0 0 0 Nov 28 18:35:41 2008 samba/
-rw-r--r-- 0 0 0 Nov 18 15:12:40 2008 samba/b.txt
-rw-r--r-- 0 0 0 Nov 18 15:12:40 2008 samba/c.txt
-rw-r--r-- 0 0 0 Nov 18 15:12:40 2008 samba/d.txt
drwxrws--- 0 0 0 Nov 28 18:35:41 2008 samba/test/
-rw-r--r-- 0 0 0 Nov 18 15:12:40 2008 samba/a.txt

I need to extract the file without creating samba folder.

Is it possible?

Many thanks
Allwin

Last edited by allwin; 12-02-2008 at 09:20 AM..
Sponsored Links
    #2  
Old 12-02-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 21 November 2014, 12:59 AM EST
Location: St. Gallen, Switzerland
Posts: 6,244
Thanks: 124
Thanked 453 Times in 412 Posts
Not that I know. Best you just tar it without leading samba or just extract it at some tmp directory and mv only the part to the destination that you need.
Sponsored Links
    #3  
Old 12-02-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 23 November 2014, 2:05 PM EST
Location: In the leftmost byte of /dev/kmem
Posts: 4,337
Thanks: 45
Thanked 839 Times in 662 Posts
You can limit what gets extracted from the archive by using a filename. For instance, going with your example, to extract only a.txt you could issue


Code:
tar -xvf samba.tar samba/a.txt

but this would still create a directory "./samba" and put "a.txt there. It would only prevent the other files getting untarred too.

If you do not want this or for some reason cannot mv the files afterwards to different locations you will have to create the tar archive in such a way that allows to extract files to a flat hierarchy. You could pipe a list of filenames to tar like this:


Code:
echo *txt | tar -cvf my.tar

"my.tar" would contain all the *txt files in the current directory and you could extract an arbitrary subset of these with the mechanism sketched above.

I hope this helps.

bakunin
    #4  
Old 12-02-2008
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 23 November 2014, 6:27 PM EST
Location: Asia pacific region
Posts: 13,026
Thanks: 522
Thanked 884 Times in 404 Posts
Well, this is not the way I would do it, but in theory you could create a symbolic link, linking samba to the current directory and untar in that (current) directory

Not sure why you would do it, but it is possible by creating the symlink.
Sponsored Links
    #5  
Old 12-02-2008
shockneck's Avatar
shockneck shockneck is offline Forum Advisor  
No RISC - No Fun
 
Join Date: Mar 2008
Last Activity: 24 January 2011, 4:56 AM EST
Posts: 465
Thanks: 1
Thanked 13 Times in 12 Posts
Quote:
Originally Posted by allwin View Post
[...]
How can i untar a set of files in to different directory.
[...]
You might try pax:

Code:
# pax -rpe -f /tmp/samba.tar -s :^/samba:/newdir1/newdir2:g

Wrote from memory, but the above command sample should restore files from /samba into /newdir1/newdir2. Read the man page and adapt to your needs.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Not able to untar file aks_1902 Shell Programming and Scripting 5 11-02-2011 05:31 AM
tar/untar over ssh chuikingman Red Hat 0 09-08-2011 01:43 AM
untar & unzip brendan76 Linux 1 01-16-2008 03:50 AM
Untar problems vinothg UNIX for Dummies Questions & Answers 2 11-09-2007 01:27 AM
untar prakash96453 UNIX for Advanced & Expert Users 2 10-19-2007 02:59 AM



All times are GMT -4. The time now is 07:59 PM.