Linux – Why can’t I get wget to pipe standard output to /dev/null

gnulinuxUbuntuwget

When I run this command it works as expected:

wget -p https://www.google.com/

After running this command I check the error code with

echo $?

This returns 0, indicating that last command ran without experiencing any errors.

Now I run:

wget -p https://www.google.com/ >/dev/null

This last command should suppress standard output- but it doesn't. So what is going on? This almost seems particular to wget, because I've never had an issue piping standard output before with other commands.

It's also worth noting that if you run:

wget -p https://www.google.com/ 2>/dev/null

all output is suppressed. Would someone care to enlighten a confused human?

Best Answer

Well, wget -p https://www.google.com/ &> /dev/null is working. That is because wget output to stderr instead of stdout. You could check wget manual.

‘--output-file=logfile’

Log all messages to logfile. The messages are normally reported to standard error.