Hi All,
I am new to shell scripting.
I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting.
Thanks
Vignesh
Hi All,
I am new to shell scripting.
I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting.
Thanks
Vignesh
IF u want to use if-Syntax[ksh],
if [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ]
then
echo "Num is between 0-8"
elif [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ]
then
echo "Num is between 9-17"
elif [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ]
then
echo "Num is between 18-24"
fi
Use case for your problem...
case $ur_variable
"") echo "Not entered"
[0-8]) echo "Num is between 0-8";break;
[9-17]) echo "Num is between 9-17";break;
[18-24]) echo "Num is between 18-24";break;
*) echo "Non-Numeric or Alphabetic or Spl,chars or Not in range[0-24];break;
esac
Thanks a lot!!!!!!!