这个 Stack Overflow 答案中 2>nul 的目的是什么?
What is the purpose of 2>nul in this Stack Overflow answer?
This Whosebug answer 包含以下代码:
dir /a-d "C:\PLUS\ADMIN\BATCH\*" >nul 2>nul && (
start "" cmd /c "@echo Files in the directory! &@echo(&@pause
) || (
echo there are no files
)
>nul
是重定向 stdout
到 nul
。 2>nul
的作用是什么,在什么情况下需要它?
对于 Windows 控制台程序,2> 是标准错误。如果 运行 的程序可能将文本输出到 stderr,则需要它。
This Whosebug answer 包含以下代码:
dir /a-d "C:\PLUS\ADMIN\BATCH\*" >nul 2>nul && (
start "" cmd /c "@echo Files in the directory! &@echo(&@pause
) || (
echo there are no files
)
>nul
是重定向 stdout
到 nul
。 2>nul
的作用是什么,在什么情况下需要它?
对于 Windows 控制台程序,2> 是标准错误。如果 运行 的程序可能将文本输出到 stderr,则需要它。