linux - 如何将stderr和stdout重定向到脚本同一行中的不同文件?

我知道这么多:

$ command 2>> error

$ command 1>> output

有什么办法可以将stderr输出到错误文件,并将stdout输出到bash的同一行中的输出文件?

最佳答案

只需在一行中添加它们command 2>> error 1>> output

但是,请注意,>> 用于在文件已有数据的情况下进行追加。而 > 将覆盖文件中的任何现有数据。

所以,command 2> error 1> output 如果你不想追加的话。

为了完成,你可以把 1> 写成 > 因为默认的文件描述符是输出。所以 1>> 是一回事。

所以,command 2> error 1> output 变成,command 2> error > output

https://stackoverflow.com/questions/7901517/

相关文章:

python - 如何根据任意条件函数过滤字典?

linux - 退出 bash 脚本但不退出终端的任何方式

linux - sed 中的环境变量替换

python - 使用 dict 文字和 dict 构造函数之间有区别吗?

python - 类型错误 : method() takes 1 positional argume

c - 如何将文件指针 ( FILE* fp ) 转换为文件描述符 (int fd)?

linux - 如何在 Ubuntu 上设置和运行 PhantomJS?

linux - 查找不属于特定用户的文件

python - 如何获得 Pandas 系列的元素逻辑非?

python - 为什么 Pycharm 的检查员提示 "d = {}"?