Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

check if variable is a number in bash

re='^[0-9]+$'
if ! [[ $yournumber =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #variable #number #bash
ADD COMMENT
Topic
Name
6+5 =