How to redirect and append both stdout and stderr to a file with Bash?

前端 未结 7 1168
春和景丽
春和景丽 2020-11-22 01:16

To redirect stdout to a truncated file in Bash, I know to use:

cmd > file.txt

To redirect stdout in Bash, appending to

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 01:22

    This should work fine:

    your_command 2>&1 | tee -a file.txt
    

    It will store all logs in file.txt as well as dump them on terminal.

提交回复
热议问题