Print 99 multiplication table
#for Statement Format
#!/bin/bash
for ((a = 1; a <= 9; a++))
Do
for ((b=1; b<= $a; b++))
Do
Let Sum=b*a
Echo-ne "$a * $b = $sum \ t"
Done
echo ""
Done
#while Statement Format
#!/bin/bash
A=1
While [$a-le 9]
Do
B=1
While [$b-le $a]
Do
Let sum= $a * $b
Echo-ne "$a * $b = $sum \ t"
Let b++
Done
echo ""
Let a++
Done
Print equilateral triangle
#for statement format, positive triangle
#!/bin/bash
For ((i=1;i<=9;i++))
Do
for ((a=9; a>= $i; a--))
Do
Echo-n ""
Done
for ((b=1; b<=i; b++)
Do
Echo-n "$i"
Done
echo ""
Done
#while statement format, inverted triangle
#!/bin/bash
I=8
While [$i-ge 1]
Do
A=9
While [$a-ge $i]
Do
Echo-n ""
Let a--
Done
B=1
While [$b-le $i]
Do
Echo-n "$i"
Let b++
Done
echo ""
Let i--
Done
Print Diamond
#while Statement Format
#!/bin/bash
I=1
While [$i-le 9]
Do
A=9
While [$a-ge $i]
Do
Echo-n ""
Let a--
Done
B=1
While [$b-le $i]
Do
Echo-n "$i"
Let b++
Done
c=2
While [$c-le $i]
Do
Echo-n "$i"
Let C + +
Done
echo ""
Let i++
Done
I=8
While [$i-ge 1]
Do
A=9
While [$a-ge $i]
Do
Echo-n ""
Let a--
Done
B=1
While [$b-le $i]
Do
Echo-n "$i"
Let b++
Done
c=2
While [$c-le $i]
Do
Echo-n "$i"
Let C + +
Done
echo ""
Let i--
Done
#for Statement Format
for (i=9; i>0; i--)
Do
for ((a=1; a<= $i; a++))
Do
Echo-n ""
Done
for ((b=9; b>= $i; b--))
Do
Echo-n "$i"
Done
for ((c=8; c>= $i; c--))
Do
Echo-n "$i"
Done
echo ""
Done
for ((i=2; i<=9; i++)
Do
for ((a=1; a<= $i; a++))
Do
Echo-n ""
Done
for ((b=9; b>= $i; b--))
Do
Echo-n "$i"
Done
for ((c=8; c>= $i; c--))
Do
Echo-n "$i"
Done
echo ""
Done
Shell Script Exercise II