2013-04-28 27 views
16

我用「捲曲 - SO」命令,以從該項目GitHub的鏈接來下載項目文件: http://github.com/ziyaddin/xampp/archive/master.zip不能下載GitHub的項目,curl命令

但是,我無法下載。有錯誤發生,並說:

Archive: /home/ziyaddin/Desktop/master.zip 
[/home/ziyaddin/Desktop/master.zip] End-of-central-directory 
signature not found. Either this file is not a zipfile, or it 
constitutes one disk of a multi-part archive. In the latter case 
the central directory and zipfile comment will be found on the last 
disk(s) of this archive. zipinfo: cannot find zipfile directory in 
one of /home/ziyaddin/Desktop/master.zip or 
      /home/ziyaddin/Desktop/master.zip.zip, and cannot find 
/home/ziyaddin/Desktop/master.zip.ZIP, period. 

,但我可以下載使用curl命令此鏈接: http://cloud.github.com/downloads/pivotal/jasmine/jasmine-standalone-1.3.1.zip

我認爲,這是因爲它是在cloud.github.com。我想知道如何從curl命令的第一個鏈接下載?

回答

34
 
$ curl -LOk https://github.com/ziyaddin/xampp/archive/master.zip 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 119 100 119 0  0 375  0 --:--:-- --:--:-- --:--:-- 388 
    0  0 0 1706 0  0 1382  0 --:--:-- 0:00:01 --:--:-- 333k 
  • 必須使用https://
  • 必須使用-L遵循重定向
  • 您必須使用-k如果您的證書文件丟失
+0

工作正常!非常感謝! – 2013-04-28 10:49:00

+0

我可以使用這個當前命令來保存目標文件夾中的文件嗎?我必須寫什麼來保存在我寫的目標文件夾中? – 2013-05-03 15:15:00

+0

多好的答案。 – 2015-11-19 01:59:04

2
 
$ curl -I http://github.com/ziyaddin/xampp/archive/master.zip 
HTTP/1.1 301 Moved Permanently 
Server: GitHub.com 
Date: Sun, 28 Apr 2013 09:24:53 GMT 
Content-Type: text/html 
Content-Length: 178 
Connection: close 
Location: https://github.com/ziyaddin/xampp/archive/master.zip 
Vary: Accept-Encoding 

...所以你如果您想要遵循HTTP重定向,則需要使用-L。或者只是閱讀史蒂芬竹篙答案...

+0

謝謝,丹尼爾! – 2013-04-28 10:50:06

4

您也可以下載一個tarball與* .tar.gz)有:

curl -LkSs https://api.github.com/repos/ziyaddin/xampp/tarball -o master.tar.gz 

,或者如果您使用-O可以省略文件名,但那麼你保存的「.tar.gz」文件默認命名爲「tarball」,所以你必須重命名並添加「.tar.gz」文件類型後綴。因此,如上所述使用(小寫)-o。其餘:

  • Ss - 使用安靜模式,但顯示的錯誤,如果有的話
  • k - 使用而不檢查TLS證書的不安全 SSL連接。