I want to suppress the output of my script running under DOS, similar to the following under a *nix environment:
$ command 1>/dev/null
How can I do this?
and NUL is Windows' equivalent of /dev/null .
/dev/null is a special filesystem object that discards everything written into it. Redirecting a stream into it means hiding your program's output. The 2>&1 part means "redirect the error stream into the output stream", so when you redirect the output stream, error stream gets redirected as well.
After executing the ping command, '>/dev/null' tells the system to suppress the output, and '2>&1' directs the standard error stream to standard output. In this way, all output of the command is discarded.
Specifying 2>/dev/null will filter out the errors so that they will not be output to your console. In more detail: 2 represents the error descriptor, which is where errors are written to. By default they are printed out on the console. /dev/null is the standard Linux device where you send output that you want ignored.
It should be >NUL
on both DOS and Windows console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With