I am learning Bash script and I need to write a conditional statement which make sure that my input string is a real number.
if [ is not a real number ]; then echo "not a real number"
I have found something like this:
if [ ! "$num" =~ ^-?[0-9]*(.[0-9]+)?$ ]
It works but I cannot understand what it is. I paste this thing to GG to research but I cannot find anything explaining about this one clearly enough.
My question is: What is this and how does it work? Is there any different way to solve my problem?