I have a follow-up question on Checking if output of a command contains a certain string in a shell script. However, the answers given in this post do not suit my problem. For expample,
./somecommand | grep -q 'string' && echo 'matched'
throws "matched" once somecommand has finished and grep found "string" in its stdout. In my case, I would like to terminate somecommand immediately after "string" has been piped to the grep command. So far, I have
./somecommand | sed '/string/q'
,
but I am wondering whether there exists a better solution than waiting for a broken pipe signal.