Redirect wget header output

I get a page with wget in a shell script, but the header information is collected in stdout, how can I redirect it to a file?

#!/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 
+4
source share
2 answers

The header information should be stderr , so you need to redirect this to a file. To do this, change the value > to 2>

+3
source

To get only the server response in the file, you can do:

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

You can learn more about redirecting UNIX output here.

+1
source

Source: https://habr.com/ru/post/1335785/


All Articles