Is there a way to get the size of a remote file like
http://api.twitter.com/1/statuses/public_timeline.json
in shell script?
Is there a way to get the size of a remote file like
http://api.twitter.com/1/statuses/public_timeline.json
in shell script?
I use like this
([Cc]ontent-[Ll]ength:)
, because I got server give multiple Content-Length character at header responseAccept-Ranges: bytes Access-Control-Expose-Headers: Date, Server, Content-Type, Content-Length Server: WowzaStreamingEngine/4.5.0 Cache-Control: no-cache Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: OPTIONS, GET, POST, HEAD Access-Control-Allow-Headers: Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range Date: Tue, 10 Jan 2017 01:56:08 GMT Content-Type: video/MP2T Content-Length: 666460
Two caveats to the other answers:
Also, you can do this without grep/awk or piping:
And the same request with compression:
Similar to codaddict's answer, but without the call to
grep
:different solution:
gives you the size in KB
The accepted solution was not working for me, this is:
To combine all the above for me works:
This will return just the content length in bytes: