LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 11-28-2007, 01:11 PM   #1
lrt
Member
 
Registered: Sep 2007
Location: Chattanooga, TN
Distribution: Ubuntu
Posts: 84

Rep: Reputation: 15
tar extract specific directory


how do i use tar to extract a specific directory including all its containing files and subdirectories?
 
Old 11-28-2007, 01:41 PM   #2
jphilput
Member
 
Registered: Nov 2007
Posts: 58

Rep: Reputation: 15
tar xpf filename.tar /path/to/directory/to/extract
 
Old 11-28-2007, 01:55 PM   #3
lrt
Member
 
Registered: Sep 2007
Location: Chattanooga, TN
Distribution: Ubuntu
Posts: 84

Original Poster
Rep: Reputation: 15
i already tried that but for some reason it hangs when it reaches the last subdirectory.

Code:
tar xvzf file.tgz path/to/directory
this will extract the directory and all its sub directories to the working directory but when it gets to the last subdirectory the cursor just blinks. i would expect to see also the files being extracted with the verbose option set but i don't see any files being extracted, i just see the directories.
 
Old 11-28-2007, 02:24 PM   #4
jphilput
Member
 
Registered: Nov 2007
Posts: 58

Rep: Reputation: 15
Tar will appear to hang after the last file is extracted while it cleans up after itself (releases the file, clears the memory etc.). On my systems this can take anywhere from a couple of seconds to several minutes depending on the speed of the system and the size of the tarball.

I do normally see filenames with only one v option set. You might try adding an extra v or two to increase the level of detail it sends to stdout.
 
Old 11-28-2007, 02:45 PM   #5
lrt
Member
 
Registered: Sep 2007
Location: Chattanooga, TN
Distribution: Ubuntu
Posts: 84

Original Poster
Rep: Reputation: 15
its been hanging for a while now. about 15 minutes. the size of the folder is about 16GB, so its size may be a reason why its still hanging. i have a feeling something is not right though. why does it hang after the last subfolder? this seems very odd although i'm not sure how tar is supposed to behave.

does it first extract directory structures and then start over again to extract the files??? if it does, it is hanging right before its starts on the files because after the last subfolder it just hangs. i've tried this with a smaller directory (just a few folders and files) and it works fine.

if i extract with the option --files-from it still also hangs after the last subfolder. any ideas, i'm completely lost.
 
Old 11-29-2007, 06:49 AM   #6
lrt
Member
 
Registered: Sep 2007
Location: Chattanooga, TN
Distribution: Ubuntu
Posts: 84

Original Poster
Rep: Reputation: 15
some progress (i think). i think this may be a permissions problem. i can't seem to change the ownership on the tar file even as root.

the `ls` command shows the owner and group as numbers. why???? could it be because this file is a CIFS share ??? how do i change permissions on this???

-rwxr--r-- 1 35026 35005 176080142271 2007-09-18 15:14 affull.091807.tgz
 
Old 11-30-2007, 01:02 PM   #7
jphilput
Member
 
Registered: Nov 2007
Posts: 58

Rep: Reputation: 15
Sorry for the delay in my reply.

Tar should be extracing the files in each directory before moving on to extract another directory. For a multi-GB tar file, the hang time at the end will likely be substantial. I once had an 80GB tarball that took several hours to close out after extracting the files I needed. The machine doing the extraction was a bit slow though, so I let it run overnight.

The permissions are showing up as numbers because they are owned by a UID and GID that your system has not yet allocated. Is there a way you could get another copy of the tarball? There shouldn't be any problem with your changing the permissions as root.
 
Old 12-01-2007, 08:40 AM   #8
lrt
Member
 
Registered: Sep 2007
Location: Chattanooga, TN
Distribution: Ubuntu
Posts: 84

Original Poster
Rep: Reputation: 15
typo on previous post. the size of the tarball is actually 160GB, not 16GB. This is a tarball of a FULL backup. I know it should take some considerable amount of time to extract, i just don't know how long is TOO long. i have for the moment given up on this tarball and extracted my differential backup instead which was a lot smaller and had the files we needed. as for UID and GID, i don't know much about this, (file permissions in linux weren't always my strong suit), so i guess its time to do some research. thanks for you help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tar - extract to different directory hcclnoodles Linux - Newbie 4 03-05-2011 03:47 PM
How to extract specific directory from a TAR file? Micro420 Linux - General 4 04-18-2007 12:04 AM
Is it possible to unpack a *.tar into a specific directory whammack Linux - Software 3 01-29-2007 06:04 PM
tar: how to extract only one directory from a backup guarriman Linux - General 1 01-29-2007 10:35 AM
How To extract .tar.gz To A Specific Directory? George2 Linux - Software 4 02-18-2006 07:01 AM


All times are GMT -5. The time now is 04:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration