You can use the case statement:
case "$myvar" in *string*) echo yes ;; * ) echo no ;; esac
All you have to do is replace the string with everything you need.
For example:
case "HELLOHELLOHELLO" in *HELLO* ) echo "Greetings!" ;; esac
Or in other words:
string="HELLOHELLOHELLO" word="HELLO" case "$string" in *$word*) echo "Match!" ;; * ) echo "No match" ;; esac
Of course, you should be aware that $word should not contain the glob magic characters unless you intend to match glob.
ams
source share