wget 命令参数使用方法

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

试验如下:
1、不指定任何参数,下载文件到当前目录;
12345678910 [root@fan ~]# wget
--2017-03-10 09:11:03-- 
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 -P /tmp/
--2017-03-10 09:11:17-- 
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 -o /tmp/
wget: /tmp/: Is a directory
 
[root@fan ~]# wget -o /tmp/a.log
 
[root@fan ~]# cat /tmp/a.log
--2017-03-10 09:11:37-- 
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
--2017-03-10 09:12:03-- 
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 -S
--2017-03-10 09:37:36-- 
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命令详解

Linux 下使用 wget/aria2 进行离线迅雷批量下载

Linux使用wget请求地址时报错

Linux下载命令wget使用详解

wget 使用大全

Linux 命令行下载工具 wget 的使用技巧

wget 命令实例

wget 命令操作实例 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14035.html