将stdout和stderr重定向到文件,并在Linux中进行控制台

时间:2018-11-09 09:34:09

标签: linux unix ubuntu-14.04

我可以将stdout和stderr重定向到如下所示的文件

some_command.sh >> file.txt 2>&1

有人可以让我知道如何将stdout和stderr重定向到文件以及控制台吗?

1 个答案:

答案 0 :(得分:0)

tee命令可以为您提供帮助。它从标准输入读取并写入标准输出和文件。

因此,以下命令将起作用:

some_command.sh 2>&1 | tee file.txt

联机帮助页:http://man7.org/linux/man-pages/man1/tee.1.html

相关问题