wget [option]... [URL]...
1 curl 192.168.1.7/hello.sh 2 echo 'hello world' 3 #頁面演示
默認系統不會自帶,需要自己安裝
yum install wget -y
-q 靜默模式
1 [02:53:22 root@localhost data]#wget -q 192.168.1.7/hello.sh 2 [02:53:54 root@localhost data]#ll 3 total 4 4 -rw-r--r-- 1 root root 19 Mar 29 02:49 hello.sh 5 #靜默下載不會提示下載成功,會自動下載到本地
-c 斷點續傳
-P /path 保存在指定目錄
1 wget -P /data/f1 192.168.1.7/hello.sh 2 --2021-03-29 02:55:18-- http://192.168.1.7/hello.sh 3 Connecting to 192.168.1.7:80... connected. 4 HTTP request sent, awaiting response... 200 OK 5 Length: 19 [application/x-sh] 6 Saving to: ‘/data/f1/hello.sh’ 7 8 100%[===================================>] 19 --.-K/s in 0s 9 10 2021-03-29 02:55:18 (8.93 MB/s) - ‘/data/f1/hello.sh’ saved [19/19] 11 12 [02:55:18 root@localhost data]#ll /data/f1/hello.sh 13 -rw-r--r-- 1 root root 19 Mar 29 02:49 /data/f1/hello.sh 14 #默認下載到當前目錄,可以指定下載到其他,目錄里
-O filename 保存為指定文件名,filename 為 – 時,發送至標准輸出
1 [02:55:33 root@localhost data]#wget -O /data/hello.html 192.168.1.7/hello.sh 2 --2021-03-29 02:57:17-- http://192.168.1.7/hello.sh 3 Connecting to 192.168.1.7:80... connected. 4 HTTP request sent, awaiting response... 200 OK 5 Length: 19 [application/x-sh] 6 Saving to: ‘/data/hello.html’ 7 8 100%[===================================>] 19 --.-K/s in 0s 9 10 2021-03-29 02:57:17 (8.74 MB/s) - ‘/data/hello.html’ saved [19/19] 11 12 [02:57:17 root@localhost data]#ll 13 total 8 14 drwxr-xr-x 2 root root 22 Mar 29 02:55 f1 15 -rw-r--r-- 1 root root 19 Mar 29 02:49 hello.html 16 -rw-r--r-- 1 root root 19 Mar 29 02:49 hello.sh 17 #和-P 差不多,可以存放在其他目錄下,同時可以更改下載下來文件的名稱,
wget -O - 192.168.1.7/hello.sh --2021-03-29 03:00:56-- http://192.168.1.7/hello.sh Connecting to 192.168.1.7:80... connected. HTTP request sent, awaiting response... 200 OK Length: 19 [application/x-sh] Saving to: ‘STDOUT’ 0% [ ] 0 --.-K/s echo 'hello world' 100%[===================================>] 19 --.-K/s in 0s 2021-03-29 03:00:56 (9.47 MB/s) - written to stdout [19/19] #此處的文件名問- 的時候可以當標准輸出
如果下載下來的頁面是腳本的話,配上靜默下載,可以直接執行(確保安全的情況下)(可以運行自己的一鍵安裝腳本)
1 wget -q -O - 192.168.1.7/hello.sh |bash 2 hello world
--limit-rate= 指定傳輸速率,單位K,M等