I'm writing a shell script, and I'm trying to check if the output of a command contains a certain string. I'm thinking I probably have to use grep, but I'm not sure how. Does anyone know?
Testing $?
is an anti-pattern
if ./somecommand | grep -q 'string'; then
echo "matched"
fi