我想从服务器下载一个文件,但在下载之前我想知道实际的文件大小。我知道 wget 会在下载开始时显示文件大小,但这实际上也会启动下载过程。
我怎样才能知道 http 服务器上远程文件的文件大小?
答案1
您可以尝试输入:
wget --spider
例如13.4万:
$ wget --spider "https://askubuntu.com/questions/389910/get-the-size-of-a-remote-file-from-terminal/389920#389920"
Spider mode enabled. Check if remote file exists.
--2019-09-27 20:34:46-- https://askubuntu.com/questions/389910/get-the-size-of-a-remote-file-from-terminal/389920
Resolving askubuntu.com (askubuntu.com)... 151.101.193.69, 151.101.129.69, 151.101.65.69, ...
Connecting to askubuntu.com (askubuntu.com)|151.101.193.69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 136873 (134K) [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.