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 5 05-19-2008 10:02 AM
tar extract to different directory ammu UNIX for Advanced & Expert Users 1 07-25-2007 11:54 AM
creating object files in a specific directory svh High Level Programming 1 02-13-2006 06:05 PM
How to extract archive to a specified directory john_trinh UNIX for Dummies Questions & Answers 4 03-02-2004 06:07 PM
redirecting tar extract to another directory colesy UNIX for Dummies Questions & Answers 7 01-28-2003 04:40 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 09-22-2004
here2learn here2learn is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 53
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.
  #2 (permalink)  
Old 09-28-2004
rakabarp rakabarp is offline
Registered User
  
 

Join Date: Sep 2004
Location: uk
Posts: 9
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!!!
  #3 (permalink)  
Old 09-28-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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.
  #4 (permalink)  
Old 10-02-2006
rony_daniel rony_daniel is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 18
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.
  #5 (permalink)  
Old 09-29-2004
here2learn here2learn is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 53
Awesome Perderabo.

Thanks so much for the reply.
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 08:24 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