What you are attempting is better achieved with a simple string comparison.
if [[ "abc-vcu def" == *"abc.vcu"* ]]; then
echo "String B contained in String A"
else
echo "No containment"
fi
Notice also how this avoids the antipattern of examining $?. Just to elaborate, anything that looks like
command
if [ $? == 0 ]; then ...
is better written as
if command; then ...
Tangentially, if you really do want or have to use grep, there are some options you need to understand. grep matches regular expressions, not just strings. There is a separate option to change the search expression into a string, namely -F (traditionally available as a separate command fgrep):
echo moo | grep m.o # true
echo moo | grep -F m.o # false
Just for completeness, note also that grep looks for a match anywhere in the input. So echo moo | grep o is true. If you really want to look for an exact match, you need the -x option (or change the expression you are grepping for):
echo moo | grep -x moo
echo moo | grep '^moo$'
Like @Kent remarks, grep will print any matching lines by default, which you probably don't want here -- you are only running grep to see if there is a match. So you need the -q flag as well. To summarize,
echo "abc-vcu def" | grep -Fxwq "abc.vcu"
Finally, you should probably also be aware of case:
case "abc-vcu def" in *"abc.vcu"*) echo true;; *) echo false;; esac
Unlike the [[ Bash-only test, case is portable all the way back to the original Bourne shell.
[[?-qoption to grep.