2021-05-12 14:32:11
wget 命令引數使用方法
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
相關文章