Answers for "check if string contains bash"

1

bash if substring

string='Hi substring' #To check if string has "Mylong" substring do
if [[ $string == *"substring"* ]]; then
  echo "String has substring"
fi
Posted by: Guest on May-26-2021
3

check if variable contains string bash

STRING='Hello world'
if [[ $STRING =~ "Hello" ]] ; then echo "It's here" ; fi
Posted by: Guest on April-17-2021

Code answers related to "check if string contains bash"

Browse Popular Code Answers by Language