wget使用文档:https://www.gnu.org/software/wget/manual/wget.html

最开始常用的比如:

wget -O  /e/movie.mp4 http://www.com/m.mp4
输出到e盘的movie.mp4文件:可是 - O 默认会覆盖文件!
所以在最后面加个 -c  表示继续下载。wget -O  /e/movie.mp4 -c

wget -P /e/ http://www.com/m.mp4
下载到e盘,文件名保持和url上的一样(m.mp4):
-P 表示下载目录(prefix)

---

翻译了一下文档 wget 1.12的 -c 选项的使用方法。

-c
--continue

Continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program. For instance:

继续只下载了一部分的文件,可以继续 wget 未完成的下载,别的程序未完成的也可以,比如:

wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z

If there is a file named ls-lR.Z in the current directory, Wget will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file.

在当前目录已经有一个lS-IR.Z这个文件的话,它将会被wget当成远程文件的前一部分文件,然后会要求服务器从本地文件大小的位置开始续传。

Note that you don't need to specify this option if you just want the current invocation of Wget to retry downloading a file should the connection be lost midway through. This is the default behavior. -c only affects resumption of downloads started prior to this invocation of Wget, and whose local files are still sitting around.

注意,如果你只是想要在当前调用的wget中途断掉连接后,重试下载文件时续传,你没必要去指定这个选项。它会在重试的时候默认继续下载。-c 只会作用在最开始调用wget,而本地文件已经存在了的时候。

Without -c, the previous example would just download the remote file to ls-lR.Z.1, leaving the truncated ls-lR.Z file alone.

下载的时候不带-c, 之前的例子就会下载远程文件到ls-LS.Z.1,不会影响未下载完全的ls-LS.Z。

Beginning with Wget 1.7, if you use -c on a non-empty file, and it turns out that the server does not support continued downloading, Wget will refuse to start the download from scratch, which would effectively ruin existing contents. If you really want the download to start from scratch, remove the file.

从1.7版开始,如果你使用 -c 在一个不为空的文件上,恰巧服务器又不支持断点续传。wget会拒绝把抓到内容(scratch?)下载到文件,因为再继续下载的话会毁掉已经存在的文件。所以,只有移除文件,然后从头开始下载。

Also beginning with Wget 1.7, if you use -c on a file which is of equal size as the one on the server, Wget will refuse to download the file and print an explanatory message. The same happens when the file is smaller on the server than locally (presumably because it was changed on the server since your last download attempt)---because ``continuing'' is not meaningful, no download occurs.

同样是从1.7 版开始,如果你使用 -c 继续下载一个文件,恰好这个文件的大小和服务器上的一样大,wget会拒绝下载这个文件,然后命令行输出解释信息。同样的,如果服务器上的比本地文件还要小的话(也许自从上次你下载了之后更改过了),继续下载也没有意义了,也不会下载。

On the other side of the coin, while using -c, any file that's bigger on the server than locally will be considered an incomplete download and only "(length(remote) - length(local))" bytes will be downloaded and tacked onto the end of the local file. This behavior can be desirable in certain cases---for instance, you can use wget -c to download just the new portion that's been appended to a data collection or log file.

另一方面,当使用 -c 的时候,服务器的文件比本地文件大的时候都会被认为未完成的下载,只会下载 远程文件长度 减去 本地文件长度 的字节数内容,然后添加到本地文件的后面。 这个方式在大多数情况下是不错的 —— 比如,你可以使用wget -c 只下载数据收集或者日志文件新增的部分。

However, if the file is bigger on the server because it's been changed, as opposed to just appended to, you'll end up with a garbled file. Wget has no way of verifying that the local file is really a valid prefix of the remote file. You need to be especially careful of this when using -c in conjunction with -r, since every file will be considered as an ``incomplete download'' candidate.

然而,如果服务器上的文件比较大,是因为他更改过了,而不是在后面增加了,你将会得到一个没有用的文件。wget是无法验证本地的文件是否是远程文件的前一部分的。当你在和 -r 一起使用的时候,千万小心,因为每个文件都被认为是一个没有完成的下载。

Another instance where you'll get a garbled file if you try to use -c is if you have a lame HTTP proxy that inserts a ``transfer interrupted'' string into the local file. In the future a ``rollback'' option may be added to deal with this case.

另外一种情况,你用 -c 也会得到一个没用的文件:如果你使用不稳定的http代理,将会插入一个“传输中断”的字符串到你的本地文件,在之后的版本会添加“rollback” 选项,以处理这种情况。

Note that -c only works with FTP servers and with HTTP servers that support the "Range" header.

注意 -c 只会在支持“range” 头的ftp服务器和http服务器上使用。

用wget下载文件的更多相关文章

  1. 多线程爬虫Java调用wget下载文件,独立线程读取输出缓冲区

    写了个抓取appstore的,要抓取大量的app,本来是用httpclient,但是效果不理想,于是直接调用wget下载,但是由于标准输出.错误输出的原因会导致卡住,另外wget也会莫名的卡住. 所以 ...

  2. linux上使用wget下载文件

    首次安装的centos操作系统是没有安装wget的,所以首先需要先安装wget,然后才能使用wget下载文件. 1.第一步,保证centos能正常连网.使用命令  :yum -y install wg ...

  3. CentOS7.5 通过wget下载文件到指定目录

    在Linux命令行下面下载文件,通过wget是比较普遍简单的,比如在CentOS7 里面也一样. 我们先来看下自己的CentOS7 系统有没有安装wget: [root@test redis]# rp ...

  4. wget下载文件

    http://blog.sina.com.cn/s/blog_4af3f0d20100n1k0.html 一.下载目录 #wget -r -np -nd http://example.com/pack ...

  5. CentOS7通过wget下载文件到指定目录

    查看自己的CentOS7系统有没有安装wget: [duanyongchun@192 3DUnetCNN]$ rpm -qa|grep wget 已安装提示: #已安装提示:wget-1.14-18. ...

  6. 利用WGET下载文件,并保存到指定目录

    wget是Linux上一个非常不错的下载指令,也算是Linux工作者常用的指令之一 而这个指令我想在各大系统都预设有提供,包括了Ubuntu.Fedora等,而一般来说,要使用wget下载档案,只需要 ...

  7. wget 下载文件重进行命名

    wget在下载的时候就重命名的: wget -c "www.baidu.com" -O baidu.index.html 保存输出日至,可以使用: wget -c "ww ...

  8. wget 下载文件

    # -c 继续执行上次终端的任务# --http-user http用户名# --http-passwd http密码# --no-check-certificate 不检查ssl/tsl证书. wg ...

  9. wget下载FTP的文件

    在Linux中我们怎么样实现wget来下载文件  下面例子 下载所有的py结尾的文件到当前目录 wget ftp://anymous:anymous@42.51.152.2/soft/*.py 递归的 ...

随机推荐

  1. sina发现并不会去导入qq使用的

    看问题需要多角度,为之不能实现也是有可能没有完善的.确实是由于短时间发布过多,还是bky好点好像有30S

  2. JAVA读取XML文件数据

    XML文档内容如下: <?xml version="1.0" encoding="UTF-8"?> <root> <field t ...

  3. EAS使用中FineUI的配置

    <?xml version="1.0" encoding="utf-8"?> <configuration> <configSec ...

  4. loj 1150(spfa预处理+二分+最大匹配)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26864 思路:首先是spfa预处理出每个'G'到'H'的最短距离, ...

  5. mysql之对表的操作

    1. 表的基本概念 在数据库中,表是一种非常重要的数据库对象,是组成数据库的基本对象,由若干个字段组成,主要用来储存数据记录. 表中的数据库对象包含列,索引和触发器. 列:也称属性列,在具体创建表时必 ...

  6. jQuery对象和DOM对象之间的相互转换

    DOM对象:DOM(Document Object Model,文档对象模型),每一份DOM都可以表示成为一棵树,DOM对象可以使用javascript中的方法. jQuery对象:jQuery对象就 ...

  7. 暴力/set Codeforces Round #291 (Div. 2) C. Watto and Mechanism

    题目传送门 /* set的二分查找 如果数据规模小的话可以用O(n^2)的暴力想法 否则就只好一个一个的换(a, b, c),在set容器找相匹配的 */ #include <cstdio> ...

  8. BZOJ3680 : 吊打XXX

    本题就是找一个受力平衡的点 我们一开始假设这个点是(0,0) 然后求出它受到的力,将合力正交分解后朝着合力的方向走若干步,并不断缩小步长,一步步逼近答案 #include<cstdio> ...

  9. HDU 1242 (BFS搜索+优先队列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1242 题目大意:多个起点到一个终点,普通点耗时1,特殊点耗时2,求到达终点的最少耗时. 解题思路: ...

  10. 哈希表工作原理 (并不特指Java中的HashTable)

    1. 引言         哈希表(Hash Table)的应用近两年才在NOI中出现,作为一种高效的数据结构,它正在竞赛中发挥着越来越重要的作用.  哈希表最大的优点,就是把数据的存储和查找消耗的时 ...