bash message partial match 1

bash message partial match

if [[ $string == *"foo"* ]]; then
  echo "It's there!"
fi

Here is what the above code is Doing:
1. We’re using the == operator to check if the string contains the substring “foo”.
2. If the string contains the substring “foo”, then the if statement will be true.
3. If the string does not contain the substring “foo”, then the if statement will be false.
4. If the if statement is true, then the echo command will be executed.

Similar Posts