I need to run cmd1
. If and only if PATTERN is missing from its STDOUT, i need to run cmd2
too:
cmd1 | grep "$PATTERN" || cmd2
But I'd like to see all output from cmd1, not just the lines that match PATTERN.
I know I could do something like this:
OUTPUT=`cmd1`
echo "$OUTPUT"
echo "$OUTPUT" | grep -q "$PATTERN" || cmd2
but this would separate STDOUT from STDERR. Also I'd rather have a handy one-liner. So I am looking for an option in grep, or an alternative to grep, saying "Don't filter, just set the exit code".