#! /bin/bash
number=$1
if [ $number -gt 9 -o $number -lt 100 ]
then
if [ $number -eq 10 ]
then
echo Ten
exit
elif [ $number -eq 11 ]
then
echo Eleven
else
echo Thirteen
fi
fi
This is my code but only in case input value is 10 it is printed, 11 does not show up in case I input 11 and also with other values as well. Do you know the reason here?
-----------edited
number=$1
output=""
if [ $number -lt 0 -a $number -gt 999 ]
then
echo put the right input between 0 and 999
fi
case "$number"
in
[0-9])
if [ $number -eq 0 ]
then
echo Zero
elif [ $number -eq 1 ]
then
echo One
elif [ $number -eq 2 ]
then
echo Two
elif [ $number -eq 3 ]
then
echo Three
elif [ $number -eq 4 ]
then
echo Four
elif [ $number -eq 5 ]
then
echo Five
elif [ $number -eq 6 ]
then
echo Six
elif [ $number -eq 7 ]
then
echo Seven
elif [ $number -eq 8 ]
then
echo Eight
elif [ $number -eq 9 ]
then
echo Nine
fi
;;
10|99)
if [ $number -gt 9 -a $number -lt 100 ]
then
if [ $number -eq 10 ]
then
echo Ten
elif [ $number -eq 11 ]
then
echo Eleven
else
echo Thirteen
fi
fi
;;
100|999)
if [ $number -gt 99 -a $number -lt 1000 ]
then
echo Two
fi
;;
esac
Here ( 10|99 ) also does not show up the value except 10..
Thirteenfor an input of10000too. The firstifwill always be true for an integer value. Was that-osupposed to be-a?