I have a tar.gz file and I want to extract it using terminal. I used following commands: tar tvzf ldtp_3.5.0.orig.tar.gz and tar -xvzf ldtp_3.5.0.orig.tar.gz. However, I get the same result for both the files:

tar: This does not look like a tar archivetar: Skipping to next headertar: Exiting with failure status due to previous errorsI output of the file command shows its a gzip file:

$ file ldtp_3.5.0.orig.tar.gz ldtp_3.5.0.orig.tar.gz: gzip compressed data, from UnixI can extract it using Right-click --> Extract but I want to do that using terminal. Can anyone tell me how to do that?

You are watching: This does not look like a tar archive

linux unix compression tar archiving
Improve this question
edited Nov 18 "14 at 19:26

47.1k1616 gold badges150150 silver badges189189 bronze badges
asked Nov 18 "14 at 18:44

63722 gold badges88 silver badges1111 bronze badges
Add a comment |

1 Answer 1

Active Oldest Votes

See more: Which Of The Following Is True Of Abraham Maslow’S Contribution To The Field Of Human Relations?

Looking at the error you are seeing coupled with the fact that you can indeed decompress it says that the file is a genuine TAR/Gzip archive, but perhaps not an immediate TAR is created after the Gzip.

Meaning, if you downloaded this from a web server, sometimes Gzip compression get’s applied to web content on the server level to speed up content download. But if not properly set on the server to ignore already compressed content such as this, it can inadvertently double-Gzip files.

With that in mind I would see if simply un-Gzip it from the command line to see what happens. Use a command like this:

gzip -d ldtp_3.5.0.orig.tar.gzAnd see what the resulting file is. I have a funny feeling after you run that command, you will not see a ldtp_3.5.0.orig.tar in the directory but rather a file named like the source—ldtp_3.5.0.orig.tar.gz— but perhaps with modification changed? If that is the case it is truly double-Gzipped. So at this point—after that initial un-Gzip—you can run the tar command you have like this:

tar -xvzf ldtp_3.5.0.orig.tar.gzAnd it should now properly decompress the full TAR archive.

Another way of doing something similar to that two step process is to pipe the output of gzip to tar like this:

gzip -dc ldtp_3.5.0.orig.tar.gz | tar -xvzf -The c in the gzip as well as the - at the end of the command is the key:

The c option for gzip will tell gzip to decompress to the standard output stream.The - at the end of the tar command means “use standard input.” So coupled with the the -c in gzip, the pipe will then take the standard output stream piped to it from gzip and connect that to standard input in tar.