Unix 在使用wget下载图像之前查找文件大小
我正在尝试在wget实际下载之前获取图像/视频大小。有没有办法获取大小并将其保存到变量中 我试图在线查找此问题,但找不到任何解决方案。使用Unix 在使用wget下载图像之前查找文件大小,unix,wget,Unix,Wget,我正在尝试在wget实际下载之前获取图像/视频大小。有没有办法获取大小并将其保存到变量中 我试图在线查找此问题,但找不到任何解决方案。使用--spider选项,然后将输出保存到文本文件: $ wget --spider https://www.google.com/image.jpg > output.txt $ wget --spider https://www.google.com/video.mp4 > output.txt 示例输出: Spider mode enabled
--spider
选项,然后将输出保存到文本文件:
$ wget --spider https://www.google.com/image.jpg > output.txt
$ wget --spider https://www.google.com/video.mp4 > output.txt
示例输出:
Spider mode enabled. Check if remote file exists.
--2016-09-16 14:23:42-- http://www.bbc.co.uk/
Resolving www.bbc.co.uk (www.bbc.co.uk)... 212.58.244.67, 212.58.246.91
Connecting to www.bbc.co.uk (www.bbc.co.uk)|212.58.244.67|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset=utf-8
...
Length: 171933 (168K) [text/html] <---------- Right here is the file size
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
$ awk 'fileSize==10 {print $2}' output.txt