I currently have a batch statement that looks like this
findstr "PreprocessorDefinitions=.*%D_KEYWORD%" %PROJ% > nul 2>&1 if errorlevel 1 ( set D_OPT= ) else ( set D_OPT=/D%D_KEYWORD% )
I wanted to know what the following means ?
> nul 2>&1
I looked here and it states that
... >nul 2>nul
means ignore output of command and ignore error messages
Now my question is how can I modify this command
findstr "PreprocessorDefinitions=.*%D_KEYWORD%" %PROJ% > nul 2>&1
to show everything and not to ignore the error messages
stream 1 is the standard input/output stream, 2 is the standard error stream. A command can output to multiple streams and it's allowed to redirect each of them to a different destination. So 2>nul and 1>nul simply said that the error output and the normal output will be redirected to nul. So nothing will be outputted.
nul 2>nul. means ignore output of command and ignore error messages.
The null device is a special file that discards all data written to it, but reports that the write operation succeeded. Nul is often used to hide the output (or error output) of a command. It is called NUL rather than NULL for historical reasons, many other devices have 3 character names: AUX, PRN, CON, etc.
Type: Null (Japanese: タイプ:ヌル Type: Null) is a Normal-type Legendary Pokémon introduced in Generation VII. It evolves into Silvally when leveled up with high friendship.
Don't use a redirection operator, which is what ">" is.
All programs have three streams:
command >nul
^ This says to pipe the standard-output stream to null.
command 2>nul
^ This says to pipe the standard-error stream to null.
command 2>&1
^ This says to pipe the standard-error stream to the same place as the standard-output stream.
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