Imagine that, I have got download-list.txt
. It contains some file urls:
http://example.com/a.txt
http://example.com/b.txt
http://example.com/c.txt
http://example.com/d.txt
http://example.com/e.txt
When I run wget -i download-list.txt --spider
, it shows like:
http://example.com/a.txt
...
Length: 128 (128B) [text/txt]
...
http://example.com/b.txt
...
Length: 120 (120B) [text/txt]
...
http://example.com/c.txt
...
Length: 100 (100B) [text/txt]
...
http://example.com/d.txt
...
Length: 90 (90B) [text/txt]
...
http://example.com/e.txt
...
Length: 80 (80B) [text/txt]
...
But, I do not need individual file size, I need total file size:
518 (128+120+100+90+80)
How to achieve this result? (Any other methods without wget
is also appreciated)
I would suggest to use
curl
:The
curl
will print the header information (which file?) as like below that contains"Content-Length"
in bytes (if the remote server can provide that); then withawk
we are summing-up the second column which is the file size for the line if matched withContent-Length
and at the END print the total size saved intotal_size
variable.from
man curl