Check input consists only of numeric characters in shell script -


i need check input consists of numeric characters. have code below, didn't work properly.

if [[ $1 =~ [0-9] ]]; echo "invalid input" fi 

it should give true 678686 not yy66666.

how this:-

re='^[0-9]+$' if ! [[ $number =~ $re ]] ;    echo "error: invalid input" >&2; exit 1 fi 

or

case $number in     ''|*[!0-9]*) echo nonnumeric;;     *) echo numeric;; esac 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -