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服务器上使用。