Linux基础-文件下载命令

Posted 旗木卡卡祥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux基础-文件下载命令相关的知识,希望对你有一定的参考价值。

文件下载命令

1.wget //文件下载
[root@localhost ~]# ll
total 4
-rw-------. 1 root root 1317 Feb 17 19:25 anaconda-ks.cfg
[root@localhost ~]# wget www.baidu.com
--2019-02-17 19:55:17-- http://www.baidu.com/
Resolving www.baidu.com (www.baidu.com)... 61.135.169.125, 61.135.169.121
Connecting to www.baidu.com (www.baidu.com)|61.135.169.125|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2381 (2.3K) [text/html]
Saving to: ‘index.html’

100%[====================================================================================================================================>] 2,381 --.-K/s in 0s

2019-02-17 19:55:17 (173 MB/s) - ‘index.html’ saved [2381/2381]

[root@localhost ~]# ll
total 8
-rw-------. 1 root root 1317 Feb 17 19:25 anaconda-ks.cfg
-rw-r--r-- 1 root root 2381 Jan 23 2017 index.html

-O // 指定存放路径,更改文件名称

[root@localhost ~]# ll ssx-test/
total 0
[root@localhost ~]# wget -O ./ssx-test/index-test.html wwww.baidu.com
--2019-02-17 19:59:28-- http://wwww.baidu.com/
Resolving wwww.baidu.com (wwww.baidu.com)... 123.125.114.144
Connecting to wwww.baidu.com (wwww.baidu.com)|123.125.114.144|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.baidu.com/ [following]
--2019-02-17 19:59:29-- http://www.baidu.com/
Resolving www.baidu.com (www.baidu.com)... 61.135.169.121, 61.135.169.125
Connecting to www.baidu.com (www.baidu.com)|61.135.169.121|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2381 (2.3K) [text/html]
Saving to: ‘./ssx-test/index-test.html’

100%[====================================================================================================================================>] 2,381 --.-K/s in 0s

2019-02-17 19:59:29 (233 MB/s) - ‘./ssx-test/index-test.html’ saved [2381/2381]

[root@localhost ~]# ll ssx-test/
total 4
-rw-r--r-- 1 root root 2381 Jan 23 2017 index-test.html
[root@localhost ~]#

-q // 安静下载(关闭wget输出)

[root@localhost ~]# ll ssx-test/
total 0
[root@localhost ~]# wget -O ./ssx-test/index-test.html wwww.baidu.com -q
[root@localhost ~]# ll ssx-test/
total 4
-rw-r--r-- 1 root root 2381 Jan 23 2017 index-test.html
[root@localhost ~]#

-T -- 超时时间
--spider -- 网络爬虫

wget --spider -q -T 10 -t 3 http://www.baidu.com

2.curl
-o -- 指定存放路径,更改文件名称
-I --head Show document info only
-s --silent Silent mode. Don‘t output anything

Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 277
Content-Type: text/html
Date: Tue, 12 Nov 2019 02:23:13 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18

[root@wll ~]# curl -I www.baidu.com | grep HTTP
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 277 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
HTTP/1.1 200 OK
[root@wll ~]# curl -Is www.baidu.com | grep HTTP
HTTP/1.1 200 OK
[root@wll ~]# curl -Is www.baidu.com | grep HTTP | awk ‘{print $2}‘
200
[root@wll ~]# curl -Is www.baidu.com | awk ‘NR==1{print $2}‘
200
[root@wll ~]#

以上是关于Linux基础-文件下载命令的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统基础-Linux系统文件操作常用命令

linux基础命令之文件管理

Linux基础篇之五基础命令 ---- 3

Linux基础篇之五基础命令 ---- 3

Linux基础 常用Linux命令

linux基础命令学习文件的特殊属性