Bash /dev/null equivalent of Win CMD NUL

dev/null => NUL 2>&1

Redirect all output to /dev/null on Windows Command

A lot of Linux code redirects output to /dev/null as a way of not sending any output to the console. I work in Windows and often use Command Prompt (cmd.exe) as the command shell. This is just a small note to remember how to do the same in Windows.

Not much here – it’s just:

C:\> ur_command > NUL 2>&1

The > NUL redirects the stdout to the NUL device (the equivalent of /dev/null) and the 2>&1 also redirects the stderr to stdout so that nothing is output to the console.

I wrote this up so that I keep it on my mind.

Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.