The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to extract files one by one from a directory and let some processing happen saniya Shell Programming and Scripting 7 05-23-2008 03:58 AM
tar extract to different directory ammu UNIX for Advanced & Expert Users 1 07-25-2007 07:54 AM
creating object files in a specific directory svh High Level Programming 1 02-13-2006 02:05 PM
How to extract archive to a specified directory john_trinh UNIX for Dummies Questions & Answers 4 03-02-2004 02:07 PM
redirecting tar extract to another directory colesy UNIX for Dummies Questions & Answers 7 01-28-2003 12:40 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-22-2004
Registered User
 

Join Date: Nov 2003
Posts: 53
Stumble this Post!
extract tar files without creating directory

I received a tar file of a directory with 50,000 files in it. Is it possible to extract the files in the tar file without first creating the directory?

ie. Doing tar -xvf filename.tar extracts as follows:
x directory/file1.txt
x directory/file2.txt
.
.
.

I would like to avoid the creation of "directory", otherwise I have to move the files when the process is complete.

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-28-2004
Registered User
 

Join Date: Sep 2004
Location: uk
Posts: 9
Stumble this Post!
tar- is used to create a single file out of a collection of directories and files.So,you will always get the same contents(as the original one when the tar was created) when you untar it .Because the whole directory structure and the contents are recorded as a stream of bytes in your tar file.So, I think there is no other go!!!
__________________
-->
Rakabarp Nastor
Reply With Quote
  #3 (permalink)  
Old 09-28-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,444
Stumble this Post!
One way is via pax. I created directory called tartest and populated it with a few files. The I did:
tar cvf tartest.tar tartest

This results in a tar archive with files in a directory called tartest. I can restore this with pax via:

pax -r -dv -f tartest.tar

But if I want to restore the files directly into my current directory, I can do:

pax -r -f tartest.tar -s'/tartest\///'

Before you try something like that, do this... "pax -dv -f tartest.tar" is like "tar tvf tartest.tar". It just lists the contents of the tar archive. Now do:

pax -dv -f tartest.tar -s'/tartest\///p'

and look at the results. This way you can be sure that you have the -s argument right before you try the restore.
Reply With Quote
  #4 (permalink)  
Old 09-29-2004
Registered User
 

Join Date: Nov 2003
Posts: 53
Stumble this Post!
Awesome Perderabo.

Thanks so much for the reply.
Reply With Quote
  #5 (permalink)  
Old 10-02-2006
Registered User
 

Join Date: Oct 2005
Posts: 18
Stumble this Post!
Quote:
Originally Posted by Perderabo
One way is via pax. I created directory called tartest and populated it with a few files. The I did:
tar cvf tartest.tar tartest

This results in a tar archive with files in a directory called tartest. I can restore this with pax via:

pax -r -dv -f tartest.tar

But if I want to restore the files directly into my current directory, I can do:

pax -r -f tartest.tar -s'/tartest\///'

Before you try something like that, do this... "pax -dv -f tartest.tar" is like "tar tvf tartest.tar". It just lists the contents of the tar archive. Now do:

pax -dv -f tartest.tar -s'/tartest\///p'

and look at the results. This way you can be sure that you have the -s argument right before you try the restore.
This is working correctly Perderabo. But what if I have a directory which inturn have sub-diectories in it. And i want all the files in the parent directory as well as the files in different child directories to be extracted into one single directory without the sub directories being created.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0