【发布时间】:2014-02-03 14:49:05
【问题描述】:
我需要一些帮助,从 shell 脚本中完成的 curl 调用中获取服务器信息。
在我的脚本中,我遍历列表中的多个 URL,并对每个 URL 执行 cURL。
但我很难获取服务器信息,因为它不是 cURL 结果的静态位置。
>curl -I -s $temp
其中,$temp 是任意 URL,例如例子.org
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Mon, 03 Feb 2014 14:35:39 GMT
Etag: "359670651"
Expires: Mon, 10 Feb 2014 14:35:39 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (iad/19AB)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270
example.org 的结果上方。
问题:我如何提取它说 server 的部分?
结果应该是这样的
>echo $server
将产生(所以基本上是“服务器:”之后的整个其余行)
ECS (iad/19AB)
非常感谢!
【问题讨论】: