Bash:RegularExpressions Regex match if [[ $yournumber =~ ^[0-9]+$ ]] ; then # ... fi See also bash regex Favorite site Regular expressions