# Test for Numeric Sources: [stackoverflow 806906](https://stackoverflow.com/questions/806906/how-do-i-test-if-a-variable-is-a-number-in-bash) answer by F. Hauri "Some performance and compatibility hints" ```bash isuint_Regx() { [[ $1 =~ ^[0-9]+$ ]] ;} isint_Regx() { [[ $1 =~ ^[+-]?[0-9]+$ ]] ;} isnum_Regx() { [[ $1 =~ ^[+-]?([0-9]+([.][0-9]*)?|\.[0-9]+)$ ]] ;} ``` Note that a more efficient way is using `case`, viz: ```bash isuint_Case() { case $1 in ''|*[!0-9]*) return 1;;esac;} isint_Case() { case ${1#[-+]} in ''|*[!0-9]*) return 1;;esac;} isnum_Case() { case ${1#[-+]} in ''|.|*[!0-9.]*|*.*.*) return 1;; esac ;} ```