First of all, you need to learn to quote arguments properly. Simply double-quote anything with a variable in it, and you should be fine, most of the time.
If the strings also contain regex specials (in this case, asterisks), those need to be escaped somehow, or you need to use a different comparison function. May I suggest the plain old case statement?
case $A in *"$B"*) echo "$A contains $B";; *) echo does not;; esac
just wondering how come double quotes are escaped properly in case statement ! while [ "$A" =~ "$B" ] does not work ! seems like I have lot of catching up to do in shell basics ..
The double quotes are not the problem, it's that you are using the regular expression match operator on something which is just a string, and which happens to contain characters which have a special meaning in regular expressions. " " (space asterisk) matches zero or more spaces in a regular expression, but doesn't match a literal asterisk. "log" matches "lo", "log", "logg", "loggg", "logggg" etc but doesn't match "log*".