bash - 将 stdout 和 stderr 重定向到带有前缀的单个文件

标签 bash stdout redirect stderr

我正在编写一个 bash 脚本,需要将我运行的命令的 stdoutstderr 输出重定向到单个文件,在每一行前加上 stderr stdout,相应地。

有没有简单的方法来做到这一点?

最佳答案

annotate-output , 来自 Debiandevscripts , 这样做。

手册页中的示例:

$ annotate-output make
21:41:21 I: Started make
21:41:21 O: gcc -Wall program.c
21:43:18 E: program.c: Couldn't compile, and took me ages to find out
21:43:19 E: collect2: ld returned 1 exit status
21:43:19 E: make: *** [all] Error 1
21:43:19 I: Finished with exitcode 2

关于bash - 将 stdout 和 stderr 重定向到带有前缀的单个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2432535/

相关文章:

linux - bash 4.3.42 。 : is/dev/fd/1 incorrect after redirecting or closing stdout?

java - 如何回显可运行的应用程序路径,在 Windows 环境变量中注册

shell - xargs -P 困惑标准输出

在没有 302 状态代码的 ASP MVC 4 中重定向

java发布表单并在重定向后获取响应 header

jquery - 为什么在asp.net mvc中 session 超时后jquery ajax调用失败?

bash - fswatch 与 grep 不管道

C - 使用 printf 和 scanf 的管道..暂停

linux - 捕获其他程序stderr和stdout的程序

java - 字符串:用 "("替换 "\("