0

I'm trying to get the version of RHEL and echo a message if its higher than or equal to RHEL 7.0. I want to use regular expressions.

str=$(cat /etc/redhat-release)
if [[ "$str" =~ .*release\s+7.* ]]; then
echo "Compatible OS"
fi

The output of the cat /etc/redhat-release is :

Red Hat Enterprise Linux Server release 7.0 (Maipo)

but i can't get the pattern to match and echo the success message. It works if the regexp I use is .*7.* but not with .*release\s+7.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266

0 Answers0