|
Home > Archive > Unix Shell > August 2007 > number range case statement
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
number range case statement
|
|
| peter sands 2007-08-23, 1:27 pm |
| Hi,
I have a case statement where the value of $coy , may hold any number
from 1 to 230, in order to validate the number I am using a case
statement, or rather trying...
How to do I specify a number range in the case ?
I thought something like this , but it does not work:
case $coy
1..$coy)
echo " number is valid : $coy, "
;;
*) echo "out of range : $coy
;;
esac
Any help please,
thanks
Pete.
| |
| Joachim Schmitz 2007-08-23, 1:27 pm |
|
"peter sands" <peter_sands@techemail.com> schrieb im Newsbeitrag
news:1187883383.884629.145500@i13g2000prf.googlegroups.com...
> Hi,
> I have a case statement where the value of $coy , may hold any number
> from 1 to 230, in order to validate the number I am using a case
> statement, or rather trying...
> How to do I specify a number range in the case ?
> I thought something like this , but it does not work:
>
> case $coy
> 1..$coy)
> echo " number is valid : $coy, "
> ;;
> *) echo "out of range : $coy
> ;;
> esac
if [ "$coy" -ge 1 ] && [ "$coy" -le 230 ]
then
echo " number is valid : $coy, "
else
echo "out of range : $coy
fi
Bye, Jojo
|
|
|
|
|