LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-24-2009, 10:56 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,129

Rep: Reputation: 30
extract file from tar


I want to extract a file from tar file , if I use tar -xvf will extract all files , if I want to only extract a directory , can advise what can i do ? thx
 
Old 03-24-2009, 11:10 PM   #2
jeff_k
Member
 
Registered: Jan 2008
Location: San Diego, CA USA
Distribution: Debian / Ubuntu
Posts: 51

Rep: Reputation: 17
http://ubuntuforums.org/showthread.php?t=318178
 
Old 03-24-2009, 11:17 PM   #3
John VV
Guru
 
Registered: Aug 2005
Posts: 12,608

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
have you read the output of these two commands
Code:
tar --help
-- and --
man tar
also please state the nix distro you are running in your posts
i can tell you how to grab 1 file using Gnome or kde ( file roller or ark )
just double click on the file and extract that 1 file .
 
Old 03-24-2009, 11:49 PM   #4
JaksoDebr
Member
 
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
Quote:
tar -xzf foo.tar.gz blah.txt
extract the file blah.txt from foo.tar.gz
a similar approach should work for packed directories, though for very nested directories you need to pass the pathname relative to the tarball, I guess.

Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 05:02 AM.
 
Old 03-29-2009, 04:30 PM   #5
tadosborn
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
How to extract directory from tgz directory within tgz file?

I have a very large backup.tgz file that contains another file dirs.tgz and I would like to extract a directory within the dirs.tgz file.

I can accomplish this by tar -xzvf backup.tgz
then tar -xzvf dirs.tgz

The problem is that it takes hours to exract the files, fills up my drive and I only need a directory from the dirs.tgz.

Does anyone have a simple command to extract a directory?

Last edited by tadosborn; 03-29-2009 at 06:22 PM.
 
Old 03-29-2009, 06:55 PM   #6
John VV
Guru
 
Registered: Aug 2005
Posts: 12,608

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
then don't tar.gz the dir. in that tar.gz
that in my opinion is a wast anyway
Code:
file1.tar.gz
 |-- folder 1.tar.gz
 |-- folder 2.tar.gz
 |-- folder 3.tar.gz
     | -- sub-folder.tar.gz 
     | -- sub-folder1.tar.gz
-- this should be
Code:
file1.tar.gz
 |-- folder 1
 |-- folder 2
 |-- folder 3
     | -- sub-folder
     | -- sub-folder1
 
Old 03-29-2009, 07:06 PM   #7
tadosborn
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
Still seeking answer

Thanks for the post, but I'm seeking an answer to my question. I didn't tar the directory to begin with...it is the situation that I've been provided.
 
Old 03-31-2009, 06:59 AM   #8
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,206

Rep: Reputation: 229Reputation: 229Reputation: 229
ust:

===I want to extract a file from tar file , if I use tar -xvf will extract all files , if I want to only extract a directory , can advise what can i do ? thx===

tadosborn:

===Does anyone have a simple command to extract a directory?===

use command:

cpio -i

to learn how to use it:

man cpio

Goodluck. Hope this helps.
 
Old 03-31-2009, 07:23 AM   #9
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
OK;
Code:
tar -zxvf backup.tgz dirs.tgz
tar xvf dirs.tgz filename
 
  


Reply

Tags
extract, tar, tgz


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to extract tar.gz file ???/ wahaha Linux - Software 6 10-27-2007 08:33 AM
extract tar.gz file manolakis Linux - Newbie 3 11-13-2006 10:49 AM
can not extract the tar.gz file sharad durgawad Linux - Software 3 10-05-2005 02:41 AM
How to extract a tar.gz file? deWin Linux - Newbie 3 11-10-2004 11:24 AM
extract and locating tar.gz file... zagreb Linux - Newbie 2 03-02-2003 02:23 AM


All times are GMT -5. The time now is 04:53 AM.

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