gpt4 book ai didi

windows - 如何将 Windows cmd stdout 和 stderr 重定向到单个文件?

转载 作者:可可西里 更新时间:2023-11-01 11:50:42 33 4
gpt4 key购买 nike

我正在尝试重定向 Windows command 的所有输出(stdout + stderr)到单个文件:

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 (stderr) 重定向到 1 (stdout)。您还可以通过重定向到 NUL 来隐藏消息。 Microsoft 文档页面上有更多解释和示例 Redirecting error messages from Command Prompt: STDERR/STDOUT .

关于windows - 如何将 Windows cmd stdout 和 stderr 重定向到单个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1420965/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com