Meaning of =~ in shell script

Please let me understand the meaning of following line in unix bash scripting .is =~ means not equal to or equal to .

if [[ $INFA_HOME =~ .*9.5.1.* ]]; then

    
      echo -e "pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER" \
        "-pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN" \
        "-f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait" \
        "-rin ${INFA_RUN_ID} ${WORKFLOW};"

      pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER \
        -pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN \
        -f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait \
        -rin ${INFA_RUN_ID} ${WORKFLOW};

      export WF_RET_VAL=$?
    else

That's the regular expression match operator. Which means what you have at the right of it is not globbing but a regular expression. Therefore .*9.5.1.* means match (almost) any character, zero or more times, followed by a nine, followed by (almost) any character, followed by a five, followed by (almost) any character, followed by a one, followed by (almost) any character, zero or more times.

Normally . (dot) will not match any line break characters.

1 Like

To add:
It is strangely written, it is equivalent to:

if [[ $INFA_HOME =~ 9.5.1 ]]; then

And I suspect the dots are a mistake and they meant literal dots, rather than "any character":

if [[ $INFA_HOME =~ 9\.5\.1 ]]; then

Which is equivalent to the following pattern match:

if [[ $INFA_HOME == *9.5.1* ]]; then
1 Like