bash-3.2$ cat multiplication.sh
#!/bin/bash
# Example use of function/method declaration in Shell Programming
# Example use of for loop
#a function that will multiply 1 to 10 with 5
multiplication()
{
x=5
for i in {1..10}
do
echo $i
echo “the multiplication result is:” $(($i*$x))
done
}
echo “Print 1 to 10; also multiply each number with 5 and show the multiplication result”
multiplication
—————————–
Output – ?????
bash-3.2$ ./multiplication.sh
Print 1 to 10; also multiply each number with 5 and show the multiplication result
1
the multiplication result is: 5
2
the multiplication result is: 10
3
the multiplication result is: 15
4
the multiplication result is: 20
5
the multiplication result is: 25
6
the multiplication result is: 30
7
the multiplication result is: 35
8
the multiplication result is: 40
9
the multiplication result is: 45
10
the multiplication result is: 50 From: http://sitestree.com/?p=12185
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 18:16:06
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