在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具。它支持文件的上传和下载,是综合传输工具,但按传统,习惯称url为下载工具。
语法:# curl [option] [url]
参数:
-A/–user-agent <string> 设置用户代理发送给服务器
-b/–cookie <name=string/file> cookie字符串或文件读取位置
-c/–cookie-jar <file> 操作结束后把cookie写入到这个文件中
-C/–continue-at <offset> 断点续转
-D/–dump-header <file> 把header信息写入到该文件中
-e/–referer 来源网址
-f/–fail 连接失败时不显示http错误
-o/–output 把输出写到该文件中
-O/–remote-name 把输出写到该文件中,保留远程文件的文件名
-r/–range <range> 检索来自HTTP/1.1或FTP服务器字节范围
-s/–silent 静音模式。不输出任何东西
-T/–upload-file <file> 上传文件
-u/–user <user[:password]> 设置服务器的用户和密码
-w/–write-out [format] 什么输出完成后
-x/–proxy <host[:port]> 在给定的端口上使用HTTP代理
-#/–progress-bar 进度条显示当前的传送状态
1.基本用法
curl http://www.linux.com
执行后,www.linux.com 的html就会显示在屏幕上了
2、保存访问的网页
2.1:使用linux的重定向功能保存
# curl http://www.linux.com >> linux.html
2.2:可以使用curl的内置option:-o(小写)保存网页
$ curl -o linux.html http://www.linux.com
执行完成后会显示如下界面,显示100%则表示保存成功

2.3:可以使用curl的内置option:-O(大写)保存网页中的文件,会以服务器上的名称保存文件到本地
注意这里后面的url要具体到某个文件
# curl -O http://www.linux.com/hello.sh
wget方式下载文件
1.下载网页
wget www.baidu.com
2.下载图片或者文件
3.下载文件到指定目录
wget -P /tmp/tomcat/api http://salt-pkg.duobeiyun.com/nebula/script-maintain/web/api/pkg/ROOT.tar.gz
Does your site have a contact page? I’m having a tough
time locating it but, I’d like to shoot you an e-mail.
I’ve got some ideas for your blog you might
be interested in hearing. Either way, great website and I look
forward to seeing it grow over time.
It’s actually a nice and helpful piece of information. I’m satisfied
that you just shared this useful information with us.
Please stay us informed like this. Thanks for sharing.
Thanks for your comment。