Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 在使用wget下载图像之前查找文件大小_Unix_Wget - Fatal编程技术网

Unix 在使用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

我正在尝试在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. 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