如何使用 curl 下载文件 [英] How to download a file using curl
问题描述
我使用的是 mac OS X,无法弄清楚如何通过命令行从 URL 下载文件.它来自一个静态页面,所以我认为复制下载链接然后使用 curl
可以解决问题,但事实并非如此.
I'm on mac OS X and can't figure out how to download a file from a URL via the command line. It's from a static page so I thought copying the download link and then using curl
would do the trick but it's not.
我参考了 这个 StackOverflow 问题 但这没有用.我还参考了 这篇文章也没有奏效.
I referenced this StackOverflow question but that didn't work. I also referenced this article which also didn't work.
我尝试过的:
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
如何通过命令行下载文件?
推荐答案
-o --output
选项意味着 curl 将输出写入您指定的文件而不是 stdout.您的错误是将 url 放在 -o
之后,因此 curl 认为该 url 是一个要写入评分的文件,因此未指定任何 url.-o
后面需要一个文件名,然后是 url:
The -o --output
option means curl writes output to the file you specify instead of stdout. Your mistake was putting the url after -o
, and so curl thought the url was a file to write to rate and hence that no url was specified. You need a file name after the -o
, then the url:
curl -o ./filename https://github.com/jdfwarrior/Workflows.git
并且 wget 在 OS X 上默认不可用.
And wget is not available by default on OS X.
这篇关于如何使用 curl 下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!