Skip to content Skip to main navigation Skip to footer

Mac OS:终端下使用curl命令下载文件

在mac os下,如何通过命令行来下载网络文件?如果你没有安装或wget命令,那么可以使用curl工具来达到我们的目的。
[cc lang=”php”] curl命令参数:
curl ‘url地址’
curl [选项] ‘url地址’
curl -O ‘url’
curl -L -O ‘url’
curl -o output.file.name.here ‘url-here’
curl -o foo.pdf ‘http://server1.cyberciti.biz/foo.pdf’
[/code] 示例:
从osetc.com服务器里下载test.rar文件
[cc lang=”php”] curl -o test.rar ‘https://www.osetc.com/test.rar。’
[/code] 选项 “-o”会将输出写入到指定的文件test.rar里
在使用curl的时候也可以指定多个url,如下面的例子:
[cc lang=”php”] curl -O http://server{1,2,3}.osetc.com/
curl -O http://server{1,2,3}.osetc.com/test.pdf
curl -O ftp://intranet.site.{us,uk,in}.google/reports/test[a-z].tar.gz
[/code]

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.