Automation, Orchestration, and Scripting

A script stores a pattern with pattern='^[0-9]+\.[0-9]+$' and must test whether the variable ver, such as 4.18, is a major.minor version number. Which test applies the stored pattern as a regular expression?

Show the answer

Correct answerC. [[ $ver =~ $pattern ]]

The =~ operator in [[ ]] with an unquoted variable expands the pattern and treats it as an extended regex. Quoting the variable makes the match literal, so a value like 4.18 would not match.