Example Output
bash-3.2$ ./while-loop-example.sh
Enter your Number
10
10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100
The Code
#!/bin/ksh
#example : how to use while loop in shell programming
multiplication()
{
#clear
i=1
while (( i <= 10 ))
do
echo “$Y * $i = `expr $Y * $i`”
(( i = i + 1 ))
done
}
echo “Enter your Number”
read X
case “$X” in
1)
Y=1
multiplication
;;
2)
Y=2
multiplication
;;
3)
Y=3
multiplication
;;
4)
Y=4
multiplication
;;
5)
Y=5
multiplication
;;
6)
Y=6
multiplication
;;
7)
Y=7
multiplication
;;
8)
Y=8
multiplication
;;
9)
Y=9
multiplication
;;
10)
Y=10
multiplication
;;
esac
exit From: http://sitestree.com/?p=12197
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:31:36
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada