我想阅读一个互联网文件的'Content-Length'。为此,我使用cURL来检索标题
OUTPUT=`curl -I $URL`
HTTP/1.1 200 OK
Date: Sun, 12 Jan 2014 00:41:11 GMT
Server: Apache/2.2.15 (Red Hat)
Last-Modified: Sun, 05 Jan 2014 09:41:44 GMT
Accept-Ranges: bytes
Content-Length: 553648128
Content-Type: application/octet-stream
但是,当我尝试打印$ OUTPUT时,我只得到最后一行。
答案 0 :(得分:1)
OUTPUT=$(curl -I $URL | grep 'Content-Length')
答案 1 :(得分:0)
的bash
curl -I $url | while read -r response
do
case "$response" in
*Content-Length* )
echo "==> $response"
;;
esac
done