Bash 4+ examples. Note: not using quotes will cause issues when words contain spaces, etc. Always quote in Bash, IMO.
Here are some examples Bash 4+:
Example 1, check for 'yes' in string (case insensitive):
if [[ "${str,,}" == *"yes"* ]] ;then
Example 2, check for 'yes' in string (case insensitive):
if [[ "$(echo "$str" | tr '[:upper:]' '[:lower:]')" == *"yes"* ]] ;then
Example 3, check for 'yes' in string (case sensitive):
if [[ "${str}" == *"yes"* ]] ;then
Example 4, check for 'yes' in string (case sensitive):
if [[ "${str}" =~ "yes" ]] ;then
Example 5, exact match (case sensitive):
if [[ "${str}" == "yes" ]] ;then
Example 6, exact match (case insensitive):
if [[ "${str,,}" == "yes" ]] ;then
Example 7, exact match:
if [ "$a" = "$b" ] ;then
Example 8, wildcard match .ext (case insensitive):
if echo "$a" | egrep -iq "\.(mp[3-4]|txt|css|jpg|png)" ; then
Example 9, use grep on a string case sensitive:
if echo "SomeString" | grep -q "String"; then
Example 10, use grep on a string case insensitive:
if echo "SomeString" | grep -iq "string"; then
Example 11, use grep on a string case insensitive w/ wildcard:
if echo "SomeString" | grep -iq "Some.*ing"; then
Example 12, use doublehash to compare (if variable empty could cause false postitives etc) (case sensitive):
if [[ ! ${str##*$substr*} ]] ;then #found
Enjoy.