https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/ 4 methods e.g. 1. Using Wildcards #!/bin/bash STR='GNU/Linux is an operating system' SUB='Linux' if [[ "$STR" == *"$SUB"* ]]; then echo "It's there." fi 2. Using the case operator #!/bin/bash STR='GNU/Linux is an operating system' SUB='Linux' case $STR in *"$SUB"*) echo -n "It's there." ;; esac 3. Using Regex Operator #!/bin/bash STR='GNU/Linux is an operating system' SUB='Linux' if [[ "$STR" =~ .*"$SUB".* ]]; then echo "It's there." fi 4. Using Grep #!/bin/bash STR='GNU/Linux is an operating system' SUB='Linux' if grep -q "$SUB" <<< "$STR"; then echo "It's there" fi