'Write a backlink in regular terms to determine the equality of two numbers

Please tell, how it is possible to execute it For example the person entered 24 and 24 appeared on the screen "ok", on the contrary when entered 24 and 23 person received "not ok"? I tried as follows:

#!/bin/bash

read a
read b
if <("$a" == "$b")>.*<\1>
then
   echo ok
else
   echo not ok
fi


Solution 1:[1]

You only need a direct variable comparison:

#!/bin/bash

read a
read b
if [ "$a" -eq "$b" ];
then
   echo ok
else
   echo not ok
fi

enter image description here

Back-reference is for complex requirements like this:

https://javascript.info/regexp-backreferences

Also regex is not used to compare different values. It is used to compare the incoming value with a predefined, expected or desired pattern like this example in which the expected pattern is a mail and the incoming value could be any string

if [[ "$1" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]
then
    echo "Email address $email is valid."
else
    echo "Email address $email is invalid."
fi

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1