Hello. Please help with this code. Returns an error message "syntax error near unexpected token =~. Conditional binary operator expected.
if [[ $a =~ "[^0-9]" ]] || [[ $b =~ "[^0-9]" ]]
then
echo "Enter only valid numbers"
fi
Hello. Please help with this code. Returns an error message "syntax error near unexpected token =~. Conditional binary operator expected.
if [[ $a =~ "[^0-9]" ]] || [[ $b =~ "[^0-9]" ]]
then
echo "Enter only valid numbers"
fi
Hi Pauline,
You have to leave out the double quotes:
if [[ $a =~ [^0-9] ]] || [[ $b =~ [^0-9] ]]
But it will not catch empty strings.
Thanks