在linux中启动应用程序时输出重定向

时间:2011-06-08 13:19:08

标签: linux redirect

如果我在将某个应用程序启动到另一个文件时重定向日志记录,如下所示:

./someapp.sh > somefile.log

如何修复此行,以便不仅可以在此文件中查看输出,还可以在控制台中查看输出?

3 个答案:

答案 0 :(得分:2)

这项工作有一个名为tee(1)的工具。

./someapp.sh | tee somefile.log

答案 1 :(得分:0)

./someapp.sh 2>&1 | tee somefile.log

答案 2 :(得分:0)

您可以在其他终端中使用此命令: tail -f somefile.log。 这将立即打印在控制台上写的所有内容。