echo "string" | grep 'x' >/dev/null 2>&1 if [ "$?" -eq "0" ]; then echo "Found x in string" else echo "Couldnt find it" fi