Another Example of Case and For Loop #Linux/Unix: Shell Programming – 001

Output First

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

—– From: http://sitestree.com/?p=12189
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 18:48:57

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