>是什么批处理语句中nul 2& 1均值 [英] what does > nul 2>&1 mean in a batch statment

查看:154
本文介绍了>是什么批处理语句中nul 2& 1均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个如下所示的批处理语句

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

推荐答案

不要使用管道运算符,这就是>".

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

所有程序都有三个流:

  • 标准输入(来自控制台的输入)
  • 标准输出(常规日志记录/UI输出到控制台)
  • 标准错误(向控制台记录日志/UI输出,用于显示错误消息或其他异常行为)

命令> nul

command >nul

^这表示将标准输出流通过管道传递为空.

^ This says to pipe the standard-output stream to null.

命令2> nul

command 2>nul

^这表示将标准错误流传递给null.

^ This says to pipe the standard-error stream to null.

命令2>& 1

command 2>&1

^这表示将标准错误流通过管道传递到与标准输出流相同的位置.

^ This says to pipe the standard-error stream to the same place as the standard-output stream.

这篇关于>是什么批处理语句中nul 2& 1均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆