10
1
I want to download a file with Wget, but per the usual UNIX philosophy, I don't want it to output anything if the download succeeds. However, if the download fails, I want an error message.
The -q
option suppresses all output, including error messages. If I include -nv
option instead, Wget still prints (on stderr):
2012-05-03 16:17:05 URL:http://example.net/ [2966] -> "index.html" [1]
How can I remove even that output, but still get error messages?
+1 I missed that all output was going to stderr; I've deleted my answer of just redirecting stdout to /dev/null. – chepner – 2012-05-03T14:29:04.137
5That works, but it's lame.
error_log=$(wget -nv example.net 2>&1) || echo $error_log
is a more elegant solution, but still clumsy. – phihag – 2012-05-03T14:29:26.103