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. BaseColumns以及自定义Column

    android provider 包下自带的BaseColumn /* * Copyright (C) 2006 The Android Open Source Project * * License ...

  2. Android之事件分发机制

    本文主要包括以下内容 view的事件分发 viewGroup的事件分发 首先来看两张图 在执行touch事件时 首先执行dispatchTouchEvent方法,执行事件分发. 再执行onInterc ...

  3. Linux命令--文件管理

    1.ls ls -a 列出目录下是所有文件 ls -l 列出文件的详细信息   2.cd cd /root 进入更目录下的root文件夹 cd file 进入当前目录的file文件夹 cd .. 进入 ...

  4. 5.建造者模式(Builder Pattern)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. Maven使用笔记(七)Maven使用问题记录

    1.Java-maven异常-cannot be cast to javax.servlet.Filter 报错 tomcat 启动后先将tomcat/lib目录下的jar包全部读入内存,如果weba ...

  6. CodeIgniter - 数据库的增删改查

    数据库操作无非是CRUD,用非装逼的语言来说就是增删改查.也许这一节会讲的很泛泛,或者很多人看不懂,没关系,大致的看看,知道是这么回事就好,继续往后看,后面会讲实例,这些枯燥而又抽象的东西可以先跳过, ...

  7. redis的PHP扩展包安装方法

    试用Redis安装.php环境连接.测试  Redis介绍     Redis本质上一个Key/Value数据库,与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解 ...

  8. 【现代程序设计】homework-08

    1. 理解C++变量的作用域和生命周期 a) 用少于10行代码演示你对局部变量的生命周期的理解 #include <iostream>int main() { ; ;i<;i++); ...

  9. VMware-WorkStation 序列号(转)

    原文摘自: http://blog.csdn.net/twlkyao/article/details/8681927 最近升级了下虚拟机,可是还要序列号,网上找了几个可以用的,留着,备用. 9.0.2 ...

  10. Loadrunner关联

    学习LoadRunner之关联(二) Lr学习之关联-随机删除一行数据和全部删除数据 录制一个系统,我录制的是一个交通方面的系统,登陆到系统里面,查询车牌颜色,将其中一条数据删除. "Nam ...