手机版
你好,游客 登录 注册
背景:
阅读新闻

wget 命令参数使用方法

[日期:2017-03-29] 来源:Linux社区  作者:mofansheng [字体: ]

wget 命令参数用法:
-P 指定下载文件的存放目录 /dir
-O 指定下载文件的名字,重命名 /dir/file
-o 屏幕输出信息保存到日志中;相当于  > /dir/logfile
-a 屏幕输出信息追加到日志中;相当于 >> /dir/logfile
-S 屏幕输出服务器响应头信息;

试验如下:
1、不指定任何参数,下载文件到当前目录;
12345678910 [root@fan ~]# wget http://linuxidc.com/Resume.pdf
--2017-03-10 09:11:03--  http://linuxidc.com/Resume.pdf
Resolving linuxidc.com... 121.42.161.135
Connecting to linuxidc.com|121.42.161.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366990 (358K) [application/pdf]
Saving to: `Resume.pdf'
 
100%[=====================================================================>] 366,990      365K/s  in 1.0s
2017-03-10 09:11:05 (365 KB/s) - `Resume.pdf' saved [366990/366990]

2、指定-P 下载文件到指定目录
12345678910 [root@fan ~]# wget http://linuxidc.com/Resume.pdf -P /tmp/
--2017-03-10 09:11:17--  http://linuxidc.com/Resume.pdf
Resolving linuxidc.com... 121.42.161.135
Connecting to linuxidc.com|121.42.161.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366990 (358K) [application/pdf]
Saving to: `/tmp/Resume.pdf'
 
100%[=====================================================================>] 366,990      403K/s  in 0.9s
2017-03-10 09:11:18 (403 KB/s) - `/tmp/Resume.pdf' saved [366990/366990]

文件保存在/tmp/Resume.pdf

3、-o 把屏幕输出信息保存到一个文件中;文件还会下载到当前目录下;
[root@huangxiaofan ~]# wget http://linuxidc.com/Resume.pdf -o /tmp/
wget: /tmp/: Is a directory
 
[root@fan ~]# wget http://linuxidc.com/Resume.pdf -o /tmp/a.log
 
[root@fan ~]# cat /tmp/a.log
--2017-03-10 09:11:37--  http://linuxidc.com/Resume.pdf
Resolving linuxidc.com... 121.42.161.135
Connecting to linuxidc.com|121.42.161.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366990 (358K) [application/pdf]
Saving to: `Resume.pdf.1'
 
0K .......... .......... .......... .......... .......... 13%  137K 2s
50K .......... .......... .......... .......... .......... 27%  275K 1s
100K .......... .......... .......... .......... .......... 41% 8.01M 1s
150K .......... .......... .......... .......... .......... 55%  281K 1s
200K .......... .......... .......... .......... .......... 69% 10.8M 0s
250K .......... .......... .......... .......... .......... 83%  284K 0s
300K .......... .......... .......... .......... .......... 97% 11.7M 0s
350K ........                                              100% 11.1M=0.9s
2017-03-10 09:11:39 (391 KB/s) - `Resume.pdf.1' saved [366990/366990]

日志文件保存在/tmp/a.log

4、-O 指定文件存放目录并改名
[root@fan ~]# wget  -O /tmp/a.pdf http://linuxidc.com/Resume.pdf
--2017-03-10 09:12:03--  http://linuxidc.com/Resume.pdf
Resolving linuxidc.com... 121.42.161.135
Connecting to linuxidc.com|121.42.161.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366990 (358K) [application/pdf]
Saving to: `/tmp/a.pdf'
 
100%[=====================================================================>] 366,990      390K/s  in 0.9s
2017-03-10 09:12:04 (390 KB/s) - `/tmp/a.pdf' saved [366990/366990]

文件保存在/tmp/a.pdf

5、-S 输出服务器响应头详细信息
12345678910111213141516171819 [root@fan ~]# wget http://linuxidc.com/Resume.pdf -S
--2017-03-10 09:37:36--  http://linuxidc.com/Resume.pdf
Resolving linuxidc.com... 121.42.161.135
Connecting to linuxidc.com|121.42.161.135|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
  Server: nginx/1.8.0
  Date: Fri, 10 Mar 2017 01:37:36 GMT
  Content-Type: application/pdf
  Content-Length: 366990
  Last-Modified: Wed, 08 Mar 2017 13:23:37 GMT
  Connection: keep-alive
  ETag: "58c005d9-5998e"
  Accept-Ranges: bytes
Length: 366990 (358K) [application/pdf]
Saving to: `Resume.pdf.2'
 
100%[=====================================================================>] 366,990      186K/s  in 1.9s
2017-03-10 09:37:38 (186 KB/s) - `Resume.pdf.2' saved [366990/366990]

Linux wget命令详解 http://www.linuxidc.com/Linux/2012-08/67837.htm

Linux 下使用 wget/aria2 进行离线迅雷批量下载 http://www.linuxidc.com/Linux/2011-10/46052.htm

Linux使用wget请求地址时报错 http://www.linuxidc.com/Linux/2011-07/39345.htm

Linux下载命令wget使用详解 http://www.linuxidc.com/Linux/2011-01/30980.htm

wget 使用大全 http://www.linuxidc.com/Linux/2008-09/15722.htm

Linux 命令行下载工具 wget 的使用技巧 http://www.linuxidc.com/Linux/2007-10/8293.htm

wget 命令实例 http://www.linuxidc.com/Linux/2014-10/108733.htm

wget 命令操作实例  http://www.linuxidc.com/Linux/2015-12/126159.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-03/142336.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款