Check if a string contains a substring in bash

Check if a string contains a substring in bash

  • 2020-2-10
1
2
3
4
string='My long string'
if [[ $string == *"My long"* ]]; then
echo "It's there!"
fi

Ref: How to check if a string contains a substring in bash