Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to download a tar of a git repo and extract its contents to another folder.

The following line (broken up for clarity) works:

curl -L -0 nt-dotfiles.tar.gz https://api.github.com/repos/nicktomlin/laptop/tarball \
 | tar --strip-components=1 -zx -C ~/Documents/dotfiles

but gives gives this error:

curl: (6) Could not resolve host: nt-dotfiles.tar.gz; nodename nor servname provided, or not known

I'm fine with leaving things as-is (because it still works) but I'm curious about the error, and would feel better if it went away.

Thanks!

share|improve this question
1  
I'm not sure what the question is, the message is saying that it is expecting a host (like a web URL) but instead getting a file (which can't resolve to an IP). –  Dave Jan 11 '13 at 15:56
    
your syntax is wrong. take a look at the manual: curl.haxx.se/docs/manpage.html –  Lorenzo Von Matterhorn Jan 11 '13 at 16:01

1 Answer 1

up vote 4 down vote accepted

Your syntax should be: curl -L -o nt-dotfiles.tar.gz https://api. ... You are using a zero instead of lower case 'Oh'. Zero forces curl to use http1.0. 'o' provides an output filename.

From the man page:

-0, --http1.0
          (HTTP)  Forces curl to issue its requests using HTTP 1.0 instead
          of using its internally preferred: HTTP 1.1. 


-o, --output <file>
          Write output to <file> instead of stdout. If you are using {} or
          [] to fetch multiple documents, you can use '#'  followed  by  a
          number  in  the <file> specifier. That variable will be replaced
          with the current string for the URL being fetched. Like in:

            curl http://{one,two}.site.com -o "file_#1.txt"
share|improve this answer
    
also, URL syntax is protocol dependent, refer to this RFC for clarification: ietf.org/rfc/rfc3986.txt –  Lorenzo Von Matterhorn Jan 11 '13 at 16:02
    
+1 for your totally clear edit explaining arguments. –  Lorenzo Von Matterhorn Jan 11 '13 at 16:04
    
not to comment snipe, but after accepting this I've noticed that using -o does not actually extract the archive. If I use -0 (which I know is wrong) the archive gets extracted to the folder I specify with tar -C. I get the could not resolve host: error, but it works. Any ideas? –  Nick Tomlin Jan 16 '13 at 15:21
    
@NickTomlin OK, try not using the -o option at all. I originally suggested it because I thought that's what you were trying to do with the -0. I think that not having the -o filename option will allow you to pipe the curled file to the tar command. As I said in the answer, the -0 option is definitely not what you want, so maybe the original answer should have been to just remove it. PS: I'd say a comment snipe is justifiable in the circumstances :-) –  mcalex Jan 17 '13 at 13:04

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.