2014-04-02 96 views
12

我在Mac OS X上,無法弄清楚如何通過命令行從URL下載文件。這是從一個靜態頁面,所以我想複製下載鏈接,然後使用curl會做的伎倆,但事實並非如此。如何使用curl下載文件

我引用了this StackOverflow question但沒有奏效。我也引用this article哪些也沒有工作。

我已經試過:

curl -o https://github.com/jdfwarrior/Workflows.git 
curl: no URL specified! 
curl: try 'curl --help' or 'curl --manual' for more information 

wget -r -np -l 1 -A zip https://github.com/jdfwarrior/Workflows.git 
zsh: command not found: wget 

如何通過命令行下載文件?

+0

的'-o'選項意味着捲曲輸出寫入到,而不是標準輸出。 – jfly

+0

你是否使用過github URL? – DShah

+1

'zsh:command not found:wget'表示沒有安裝wget軟件包。所以要使用wget,你必須首先安裝wget **。 @Alex Cory –

回答

15

-o --output選項意味着捲曲輸出寫入文件,你specicify,而不是標準輸出,你把網址-o後,使捲曲認爲URL是寫一個文件,並沒有指定的URL。您需要在-o之後的文件名,然後是url。由於URL是基於HTTPS,也許你還需要-k選項:

curl -o ./filename -k https://github.com/jdfwarrior/Workflows.git 

和wget是默認不可用在OS X

+0

我無法使用上述命令下載文件。我嘗試了兩條命令:curl -o「test.zip」-k https://github.com/jonreid/XcodeCoverage.git&curl -o「test.zip」-k https://github.com/jonreid/ XcodeCoverage/archive/master.zip 第二個命令應該已經工作,但它不工作。你能幫我嗎? – DShah

+0

只是好奇,但你爲什麼要使用curl來當你可以使用'git clone https:// github.com/jonreid/XcodeCoverage.git'? –

+1

@DShah url已被重定向,因此您需要添加'-L'標誌來指示cURL遵循任何重定向,以便到達最終端點。這將工作:'curl -L -o「test.zip」-k github.com/jonreid/XcodeCoverage/archive/master.zip' – jfly