tee and exit status

前端 未结 8 1894
礼貌的吻别
礼貌的吻别 2021-02-07 10:43

is there an alternative to \"tee\" which captures STDOUT/STDERR of the command being executed and exits with the same exit status as the processed command. Something as followin

8条回答
  •  醉酒成梦
    2021-02-07 11:28

    G'day,

    Assuming bash or zsh,

    my_command >>my_log 2>&1
    

    N.B. Sequence of redirection and duplication of STDERR onto STDOUT is significant!

    Edit: Oops. Didn't realise you wanted to see the output on screen as well. This will of course direct all output to the file my_log.

    HTH

    cheers,

提交回复
热议问题