How can we redirect output of command to /dev/null
?
I tried it with:
command > /dev/null
But it didn't work.
How can we redirect output of command to /dev/null
?
I tried it with:
command > /dev/null
But it didn't work.
Your command had redirected standard output to /dev/null
, but maybe the command
printed to standard error instead of standard output, so you still see the text in terminal.
To redirect standard output and standard error to /dev/null
, you need:
command >/dev/null 2>&1
Note that the order of redirection is important, swapping them to 2>&1 >/dev/null
won't work because standard error was redirected to standard output at the time when standard output still point to terminal, you still see the text in terminal if command
write to standard error.
command 2>&1 > /dev/null
? – YoMismo Oct 08 '15 at 09:57command > /dev/null
? what it outputs? – Pandya Oct 08 '15 at 10:19ls file-does-not-exist 2>&1 >/dev/null
. – cuonglm Oct 08 '15 at 10:38command 2>&1 > /dev/null
doesn't work because the redirection is read from right to left so the>/dev/null
is applied before the2>&1
. So yes, it is actually wrong. However, even if it weren't, that wouldn't give you the right to use the kind of language you did. I'll be sorry to see you go, you post good content, all you need to do is be civil. – terdon Oct 08 '15 at 13:32