Handling Spaces In Substring Searches In Bash Shell Scripts
You can escape the space:
$mainSubString = *blue\ cheese*
or quote the non-wildcard portions, one example of which is
$mainSubString = *'blue cheese'*
Often, it is better to store the pattern in a variable, both to simplify the quoting and to make the [[...]]
expression more concise. Note that you must not quote the parameter expansion, as glenn jackman points out in his comment.
pattern="*blue cheese*"if [[ $mainString = *cat* || $mainSubstring = $pattern ]]; then