重定向wget标头输出

时间:2011-01-17 02:59:10

标签: bash redirect

我在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 个答案:

答案 0 :(得分:3)

标题信息必须转到stderr,因此您需要将其重定向到文件。为此,请将>更改为2>

答案 1 :(得分:1)

要获取文件中的服务器响应,您可以执行以下操作:

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

您可以阅读有关UNIX输出重定向here

的更多信息