Piping both stdout and stderr in bash?

后端 未结 2 1470
盖世英雄少女心
盖世英雄少女心 2020-11-28 03:51

It seems that newer versions of bash have the &> operator, which (if I understand correctly), redirects both stdout and stderr to a file (&>

2条回答
  •  醉梦人生
    2020-11-28 04:02

    Bash has a shorthand for 2>&1 |, namely |&, which pipes both stdout and stderr (see the manual):

    cmd-doesnt-respect-difference-between-stdout-and-stderr |& grep -i SomeError
    

    This was introduced in Bash 4.0, see the release notes.

提交回复
热议问题