我正在尝试重定向 a 的所有输出(stdout + stderr)Windows命令 https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands到单个文件:
C:\>dir 1> a.txt 2> a.txt
The process cannot access the file because it is being used by another process.
是否可能,或者我应该重定向到两个单独的文件?
你要:
dir > a.txt 2>&1
语法2>&1
将重定向2
(标准错误)到1
(标准输出)。您还可以通过重定向到隐藏消息NUL
。更多解释和示例位于 Microsoft 文档页面从命令提示符重定向错误消息:STDERR/STDOUT https://learn.microsoft.com/en-US/troubleshoot/developer/visualstudio/cpp/language-compilers/redirecting-error-command-prompt.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)