我知道可以将两者都重定向到特定文件:
./command 1> out.log 2> err.log
或
./command 1>test.log 2>&1
将两者都写入文件。但是我不知道在只打印两个文件时都将它们写入同一文件的方法。 tee
不是很有用,因为它同时打印两个文件描述符。
使用tee
将标准输出写到一个文件而又写到另一个文件很简单:
{ cmd | tee stdout.log; } &> both.log
将标准错误写给一个人,并且都写给另一个人比较棘手。
{ foo 2>&1 1>&3 | tee stderr.log ; } 3>&1 | tee both.log > /dev/null