【问题标题】:Redirect stdout and stderr to a file and also to console in linux [duplicate]将stdout和stderr重定向到一个文件,也重定向到linux中的控制台[重复]
【发布时间】:2019-04-12 20:49:32
【问题描述】:

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

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

谁能告诉我如何将 stdout 和 stderr 重定向到文件和控制台?

【问题讨论】:

    标签: linux unix ubuntu-14.04


    【解决方案1】:

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

    所以下面的命令就可以了:

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

    手册页:http://man7.org/linux/man-pages/man1/tee.1.html

    【讨论】:

      猜你喜欢
      • 2014-07-22
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      • 1970-01-01
      相关资源
      最近更新 更多