How to redirect output to a file and stdout

后端 未结 10 1592
借酒劲吻你
借酒劲吻你 2020-11-22 08:11

In bash, calling foo would display any output from that command on the stdout.

Calling foo > output would redirect any output from that

10条回答
  •  天命终不由人
    2020-11-22 08:44

    Another way that works for me is,

     |& tee  
    

    as shown in gnu bash manual

    Example:

    ls |& tee files.txt
    

    If ‘|&’ is used, command1’s standard error, in addition to its standard output, is connected to command2’s standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error to the standard output is performed after any redirections specified by the command.

    For more information, refer redirection

提交回复
热议问题