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

标签 linux bash

我知道这么多:

$ 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

关于linux - 如何将stderr和stdout重定向到脚本同一行中的不同文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7901517/

相关文章:

c - bash 解释器 linux 的读/写标准输入/输出,fork - execl

bash - 获取存储到 ssh 命令内变量的退出状态

python - 需要通过用户输入(GPIO.input)结束子进程的循环

linux - 如何在运行 Linux 的 VM 上获取/dev/ptp0 ptp 硬件时钟?

linux - shell 中的 GtkDialog

c++ - 错误 : argument of type "void (opca_hello::)()" does not match "void* (*)(void*)"

Python 失去对子进程的控制?

security - 在 bash 脚本执行之间保存密码

linux - 如何在 bash 中隐藏 "Created new window in existing browser session"

bash - 将完整环境导出到 GNU Parallel