unix shell, getting exit code with piped child

后端 未结 5 483
南旧
南旧 2021-01-18 07:21

Let\'s say I do this in a unix shell

$ some-script.sh | grep mytext

$ echo $?

this will give me the exit code of grep

5条回答
  •  一生所求
    2021-01-18 08:04

    There is a utility named mispipe which is part of the moreutils package.

    It does exactly that: mispipe some-script.sh 'grep mytext'

提交回复
热议问题