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