Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my target is to verify the range of number with (only with - case + esac ) , and print the range

so for example

if number is between 0-80 , case will print

 >=0<=80

or if range is between 81-100 then case will print

 >=81<=100

and so on....

the problem with my script print only >=0<=90 only if number between 0-9 ?

how to fix my script , so it will print according to number range ?

#!/bin/ksh

read number 

case $number in 
    [0-80])  echo ">=0<=80";; 
    [81-100]) echo ">=81<=100";; 
    [101-120]) echo ">=101<=120";;
    [121-300]) echo ">=121<=300";;
esac 
share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

In zsh (which ksh is symlinked to on my system) you need to use <> for numerical ranges:

case $number in
    <0-80>)  echo ">=0<=80";;
    <81-100>) echo ">=81<=100";;
    <101-120>) echo ">=101<=120";;
    <121-300>) echo ">=121<=300";;
esac
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.