wget 命令参数使用方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wget 命令参数使用方法相关的知识,希望对你有一定的参考价值。
wget 命令参数用法:
-P 指定下载文件的存放目录 /dir
-O 指定下载文件的名字,重命名 /dir/file
-o 屏幕输出信息保存到日志中;相当于 > /dir/logfile
-a 屏幕输出信息追加到日志中;相当于 >> /dir/logfile
-S 屏幕输出服务器响应头信息;
试验如下:
1、不指定任何参数,下载文件到当前目录;
[[email protected] ~]# wget http://wangyaohua.cn/Resume.pdf --2017-03-10 09:11:03-- http://wangyaohua.cn/Resume.pdf Resolving wangyaohua.cn... 121.42.161.135 Connecting to wangyaohua.cn|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 下载文件到指定目录
[[email protected] ~]# wget http://wangyaohua.cn/Resume.pdf -P /tmp/ --2017-03-10 09:11:17-- http://wangyaohua.cn/Resume.pdf Resolving wangyaohua.cn... 121.42.161.135 Connecting to wangyaohua.cn|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 把屏幕输出信息保存到一个文件中;文件还会下载到当前目录下;
[[email protected] ~]# wget http://wangyaohua.cn/Resume.pdf -o /tmp/ wget: /tmp/: Is a directory [[email protected] ~]# wget http://wangyaohua.cn/Resume.pdf -o /tmp/a.log [[email protected] ~]# cat /tmp/a.log --2017-03-10 09:11:37-- http://wangyaohua.cn/Resume.pdf Resolving wangyaohua.cn... 121.42.161.135 Connecting to wangyaohua.cn|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 指定文件存放目录并改名
[[email protected] ~]# wget -O /tmp/a.pdf http://wangyaohua.cn/Resume.pdf --2017-03-10 09:12:03-- http://wangyaohua.cn/Resume.pdf Resolving wangyaohua.cn... 121.42.161.135 Connecting to wangyaohua.cn|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 输出服务器响应头详细信息
[[email protected] ~]# wget http://wangyaohua.cn/Resume.pdf -S --2017-03-10 09:37:36-- http://wangyaohua.cn/Resume.pdf Resolving wangyaohua.cn... 121.42.161.135 Connecting to wangyaohua.cn|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]
本文出自 “模范生的学习博客” 博客,请务必保留此出处http://mofansheng.blog.51cto.com/8792265/1905057
以上是关于wget 命令参数使用方法的主要内容,如果未能解决你的问题,请参考以下文章