vendredi 17 juillet 2020

How to match this regexp in UNIX with expr?

Can some body pl tell me why this if condition doesn't output Matched and how to change the reg exp pattern with expr to display the output as Matched. The thing is that instead of BH in the var variable there can be any country code like US or CA. All the other characters in the variable remains the same.

var1="BH.EBS.EBS.BH.RCMS.RCMS.FBACCR"
if [ `expr $var1 : "*.EBS.EBS.*.RCMS.RCMS.FBACCR"` -gt 0 ]; then
echo "Matched"
else
echo "Not matched"
fi

Thanks Gautam

Aucun commentaire:

Enregistrer un commentaire