Galud
Galud

Reputation: 27

Extract a tar file using tar -xzvf

I want to extract a tar file that I obtained by using: curl -O https://github.com/fhcrc/seqmagick/archive/0.6.1.tar.gz but when I try: tar -xzvf 0.6.1 I get tar: Error opening archive: Failed to open '0.6.1'

I see the file in the directory as 0.6.1.tar.gz and I tried to do tar -xzvf 0.6.1.tar.gz but I get error Error exit delayed from previous errors.

Any suggestion will be much appreciated.

Upvotes: 0

Views: 2737

Answers (2)

George Vasiliou
George Vasiliou

Reputation: 6335

I use to manipulate curl issues like bellow. I first use -o- option with curl. This forces curl to "dump" contents in screen - in real time.
In your case the situation is like advised by merlin2011 :

$ curl -o- "https://github.com/fhcrc/seqmagick/archive/0.6.1.tar.gz"
<html><body>You are being <a href="https://codeload.github.com/fhcrc/seqmagick/tar.gz/0.6.1">redirected</a>.</body></html>

PS: With -o- option, if the archive was correct would flood the screen with many unrecognized characters... So handle with care or pipt to tar

This movement can be solved with -L option of curl, which follows the moved links.
I use to include also -s for "silent" operation. Combine with a pipe to tar to see on screen the files content included in this archive without downloading it:

$ curl -sL -o- "https://github.com/fhcrc/seqmagick/archive/0.6.1.tar.gz" |tar -zt
seqmagick-0.6.1/
seqmagick-0.6.1/.gitignore
seqmagick-0.6.1/.travis.yml
seqmagick-0.6.1/CHANGELOG
seqmagick-0.6.1/CONTRIB
seqmagick-0.6.1/INSTALL
seqmagick-0.6.1/LICENSE
seqmagick-0.6.1/MANIFEST.in
<much more files here>

So now we have hit the correct archive. You can now use -O option to store the correct file in your current working directory.

$ curl -sLO "https://github.com/fhcrc/seqmagick/archive/0.6.1.tar.gz"
$ ls -l *.tar.gz
-rw-r--r-- 1 root root 672141 Apr  3 11:37 0.6.1.tar.gz
$ tar -tf 0.6.1.tar.gz
seqmagick-0.6.1/
seqmagick-0.6.1/.gitignore
seqmagick-0.6.1/.travis.yml
seqmagick-0.6.1/CHANGELOG
seqmagick-0.6.1/CONTRIB
seqmagick-0.6.1/INSTALL
seqmagick-0.6.1/LICENSE
seqmagick-0.6.1/MANIFEST.in
<much more files follow>

Upvotes: 0

merlin2011
merlin2011

Reputation: 75545

If you open the file 0.6.1.tar.gz, you will see the following message

<html><body>You are being <a href="https://codeload.github.com/fhcrc/seqmagick/tar.gz/0.6.1">redirected</a>.</body></html>

It seems that curl does not follow the redirect. wget appears to work for this purpose.

wget https://github.com/fhcrc/seqmagick/archive/0.6.1.tar.gz
tar xfz 0.6.1.tar.gz

Upvotes: 1

Related Questions