what does > nul 2>&1 mean in a batch statment

前端 未结 1 1308
悲&欢浪女
悲&欢浪女 2021-02-06 23:50

I currently have a batch statement that looks like this

findstr \"PreprocessorDefinitions=.*%D_KEYWORD%\" %PROJ% > nul 2>&1
if errorlevel 1 (
    set D         


        
相关标签:
1条回答
  • 2021-02-07 00:18

    Don't use a piping operator, which is what ">" is.

    All programs have three streams:

    • Standard Input (the input from the console)
    • Standard Output (general logging/UI output to the console)
    • Standard Error (logging/UI output to the console meant for error messages or other exceptional behavior)

    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.

    0 讨论(0)
提交回复
热议问题