如何让 wget 创建适当的零字节文件?

如何让 wget 创建适当的零字节文件?

我正在尝试wget从网络服务器下载整个目录及其内容。其中一些文件的长度为零。

有没有办法wget在客户端创建 0 字节文件?当我现在尝试这样做时,wget200 OK ... Content-Length: 0从服务器获取文件,认为文件已下载,因此不执行任何操作。

$ wget -dS http://gateway/zero
Debugging support not compiled in. Ignoring --debug flag.
--2015-01-28 16:58:44--  http://gateway/zero
Resolving gateway... 172.16.19.2
Connecting to gateway|172.16.19.2|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Wed, 28 Jan 2015 15:58:44 GMT
  Server: Apache/2.4.7 (Ubuntu)
  Last-Modified: Wed, 28 Jan 2015 15:58:34 GMT
  ETag: "0-50db87194310f"
  Accept-Ranges: bytes
  Content-Length: 0
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive

    The file is already fully retrieved; nothing to do.
$ ls -l zero
ls: zero: No such file or directory

答案1

--no-cache您可以使用以下选项尝试wget

wget --no-cache -dS http://gateway/zero

请参阅手册页wget

`--no-cache'

       Disable server-side cache. In this case, Wget will send the remote server
       an appropriate directive (‘Pragma: no-cache’) to get the file from the
       remote service, rather than returning the cached version. This is
       especially useful for retrieving and flushing out-of-date documents on
       proxy servers.

       Caching is allowed by default.

相关内容