重定向wget的标题输出

4

我在shell脚本中使用wget获取一个页面,但是头部信息会输出到标准输出流(stdout),我该如何将其重定向到文件?

#!/bin/sh
wget -q --server-response http://192.168.1.130/a.php > /tmp/ilan_detay.out

root@abc ./get.sh
  HTTP/1.0 200 OK
  X-Proxy: 130
  Set-Cookie: language=en; path=/; domain=.abc.com
  X-Generate-Time: 0,040604114532471
  Content-type: text/html
  Connection: close
  Date: Mon, 17 Jan 2011 02:55:11 GMT
root@abc
2个回答

3

头部信息必须被发送到stderr,因此您需要将其重定向到文件。要做到这一点,请将>更改为2>


1

要将服务器响应仅保存到文件中,您可以执行以下操作:

wget -q --server-response http://www.stackoverflow.com >& response.txt

你可以在这里阅读更多关于UNIX输出重定向的内容。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接