bash - Verifying a variable using case statement -


if have script (bash shell) , want check see if argument passed within range of numbers, how using case statements? instance, script perform series of commands, if argument entered numbers 10-20, otherwise error message returned. able if statements know how case statements. i've read other pages, doesn't make sense do:

case $1 in 10 *command executed 11 *command executed etc... 

try doing :

if (($1 >= 10 && $1 <=20));     echo "correct range" else     echo >&2 "incorrect range" fi 

i use bash arithmetic. using case statement here seems bit inefficient.

if insist whit case :

case $1 in     1[0-9]|20) echo "correct range" ;;     *) echo >&2 "incorrect range" ;; esac 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -