Answers for "shell: search a substring in another string"

0

shell: search a substring in another string

# Search for a substring in another string using wildcard

string='My long string'
substr='My long'

# Note: the wildcard character (*) is outside the double qoute ("")
if [[ "$string" == *"$substr"* ]]; then
  echo "Found substring!"
fi
Posted by: Guest on April-20-2022

Code answers related to "shell: search a substring in another string"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language