LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   extract file from tar (https://www.linuxquestions.org/questions/linux-newbie-8/extract-file-from-tar-714215/)

ust 03-24-2009 10:56 PM

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

jeff_k 03-24-2009 11:10 PM

http://ubuntuforums.org/showthread.php?t=318178

John VV 03-24-2009 11:17 PM

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 .

JaksoDebr 03-24-2009 11:49 PM

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

tadosborn 03-29-2009 04:30 PM

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?

John VV 03-29-2009 06:55 PM

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


tadosborn 03-29-2009 07:06 PM

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.

malekmustaq 03-31-2009 06:59 AM

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.

alan_ri 03-31-2009 07:23 AM

OK;
Code:

tar -zxvf backup.tgz dirs.tgz
tar xvf dirs.tgz filename



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