我正在编写一个 bash 脚本,需要将我运行的命令的 stdout
和 stderr
输出重定向到单个文件,在每一行前加上 stderr
或 stdout
,相应地。
有没有简单的方法来做到这一点?
最佳答案
annotate-output , 来自 Debian的 devscripts , 这样做。
手册页中的示例:
$ 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/