- 1 year ago
Running command with /dev/null on Windows
Comment
1 / 1
On Windows, the equivalent of /dev/null
is NUL
. You can redirect command output to NUL
to discard it. Here's an example of how you can run a command and discard its output on Windows:
bashcommand > NUL 2>&1
In the above command:
>
is used to redirect the standard output (stdout) of the command toNUL
.2>&1
is used to redirect the standard error (stderr) of the command to the same location as the standard output, which isNUL
.
By redirecting both stdout and stderr to NUL
, you effectively discard any output from the command.
Replace command
with the actual command you want to run. For example:
bashecho Hello, World! > NUL 2>&1
This will run the echo
command and discard its output.
Note that NUL
is a special device file on Windows that discards any data written to it.