ফলাফল
bash-3.2$ ./ksh_case_chart.sh
Enter your Number
9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
—-
কোড
#!/bin/ksh
#example on how to use case and for loop
multi()
{
#clear
for i in 1 2 3 4 5 6 7 8 9 10
do
echo “$Y * $i = `expr $Y \* $i`”
done
}
#take a number from the user ( 1..10)
echo “Enter your Number”
read X
case “$X” in
1)
Y=1
multi
;;
2)
Y=2
multi
;;
3)
Y=3
multi
;;
4)
Y=4
multi
;;
5)
Y=5
multi
;;
6)
Y=6
multi
;;
7)
Y=7
multi
;;
8)
Y=8
multi
;;
9)
Y=9
multi
;;
10)
Y=10
multi
;;
esac
exit
—–