I am trying to match two strings (IpAddress) as below. But it's not matching.
i=192.168.2.29
ipCheckInConfig="SG_1=192.168.2.24,192.168.2.29
> SG_2=192.168.2.20,192.168.2.23,192.168.2.31"
if echo "$i" | egrep -q "$ipCheckInConfig" ; then
echo "Matched"
else
echo "Not Matched"
fi
Could someone please help?
egrep, so of course it can't find the big string in the little one. You need to echo the long string and search for the short one. Or use the built-in regex operator if your shell isbash— the Unix and Shell tags don't make that a slam-dunk.