Answers for "check if variable is a number in bash"

0

check if variable is a number in bash

re='^[0-9]+$'
if ! [[ $yournumber =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi
Posted by: Guest on April-15-2020

Code answers related to "check if variable is a number in bash"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language