如何重定向标准错误和stdout到不同的文件在同一行的bash? [英] How to redirect stderr and stdout to different files in the same line of bash?

查看:100
本文介绍了如何重定向标准错误和stdout到不同的文件在同一行的bash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这么多:

$ command 2>> error

$ command 1>> output

有没有什么办法可以输出标准错误的错误文件和输出在同一条线上的bash的标准输出到输出文件?

Is there any way I can output the stderr to the error file and output stdout to the output file in the same line of bash?

推荐答案

只需添加他们一行命令2 - ;>错误1>>输出

不过,请注意,>> 是追加,如果该文件已经有了数据。然而,方式> 将文件中的覆盖任何现有数据

However, note that >> is for appending if the file already has data. Whereas, > will overwrite any existing data in the file.

因此​​,命令2 - ;错误1>输出如果你不想追加。

So, command 2> error 1> output if you do not want to append.

刚刚完成的缘故,你可以写 1> 刚才> 因为默认文件描述符的输出。所以 1 GT; 方式> 是同一个东西。

Just for completion's sake, you can write 1> as just > since the default file descriptor is the output. so 1> and > is the same thing.

因此​​,命令2 - ;错误1>输出变,命令2 - ;错误>输出

这篇关于如何重定向标准错误和stdout到不同的文件在同一行的bash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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