将stdout和stderr重定向到单个文件 [英] Redirect stdout and stderr to a single file

查看:142
本文介绍了将stdout和stderr重定向到单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试重定向 DOS 命令的所有输出(stdout + stderr)到单个文件:

I'm trying to redirect all output (stdout + stderr) of a DOS command to a single file:

C:\>dir 1> a.txt 2> a.txt
The process cannot access the file because it is being used by another process.

有可能,还是应该重定向到两个单独的文件?

Is it possible, or should I just redirect to two separate files?

推荐答案

您需要:

dir > a.txt 2>&1

这篇关于将stdout和stderr重定向到单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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