search_1='hello' search_2='Hello' str='helloworld' if [[ $str =~ $search_1 ]] then echo 'get search_1' be if [[ $str =~ $search_2 ]] then echo 'get search_2' be #Ignore case just convert to upper case or lower case first search_3=$(echo $search_2 | tr '[A-Z]' '[a-z]') echo $search_3 if [[ $str =~ $search_3 ]] then echo 'get search_3' be
Here you need to focus on the usage of the tr command http://man.linuxde.net/tr