Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can we extract specific files from a large tar.gz file? I found the process of extracting files from a tar in Untar only a certain number of files from a large tarball but, when i tried the mentioned command there, i got the error:

$ tar --extract --file={test.tar.gz} {extract11}

tar: {test.tar.gz}: Cannot open: No such file or directory

tar: Error is not recoverable: exiting now

How do i extract a file from tar.gz then?

share|improve this question

2 Answers 2

you can also use tar -zxvf <tar filename> <file you want to extract>

-x: instructs tar to extract files.
-f: specifies filename / tarball name.
-v: Verbose (show progress while extracting files).
-z: filter archive through gzip, use to decompress .gz files.
share|improve this answer
    
$ tar -zxvf test.tar.gz extract11 tar: extract11: Not found in archive tar: Error exit delayed from previous errors –  Ankit Vashistha Jan 16 '13 at 7:52
    
then try this tar tf archive.tar.gz | grep extract11.please check whether extract11 is in the archive or not –  harish.venkat Jan 16 '13 at 8:06
    
You must write the file name exacty as tar ztf test.tar.gz shows it. If it says e.g. ./extract11, or some/bunch/of/dirs/extract11, that's what you have to give (and the file will show up under exactly that name, needed directories are created automatically). –  vonbrand Jan 21 '13 at 20:16

Your example works for me if you omit the braces

$ tar --extract --file=test.tar.gz extract11

If your file extract11 is in a subfolder, you should specify the path within the tarball.

$ tar --extract --file=test.tar.gz subfolder/extract11
share|improve this answer
    
$ tar --extract --file=test.tar.gz extract11 tar: extract11: Not found in archive tar: Error exit delayed from previous errors –  Ankit Vashistha Jan 16 '13 at 7:51
    
Then obiously extract11 is not in the tar-file. Be sure that you need to provide the relative path. See edit –  Bernhard Jan 16 '13 at 7:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.