wget 下载命令 Alex

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等

------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
原文地址:https://www.cnblogs.com/alexlv/p/14592456.html