You can download the file and get its size. But we can do better.
Use curl to get only the response header using the -I
option.
In the response header look for Content-Length:
which will be followed by the size of the file in bytes.
$ URL="http://api.twitter.com/1/statuses/public_timeline.json"
$ curl -sI $URL | grep -i Content-Length
Content-Length: 134
To get the size use a filter to extract the numeric part from the output above:
$ curl -sI $URL | grep -i Content-Length | awk '{print $2}'
134
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…