Today in three different ways to achieve the shell script Print 99 multiplication table, the code is as follows
 
Method 1: Use a For loop (a.sh)
 
#!/bin/shfor i in {1,2,3,4,5,6,7,8,9}do to J in {1,2,3,4,5,6,7,8,9} do ((product= $i * $j)) Echo-ne $i \ * $j = $product "\ T" done Echodoneexit 0
 
Method 2: Use the While loop (b.sh)
 
#!/bin/shi=1j=1while ["$i"-ne]do while ["$j"-ne] Do ((product= $i * $j)) Echo-ne $i \* $j = $pro Duct "\ T" ((j + +)) done J=1 ((i++)) Echodoneexit 0
 
Method 3: Use a For loop (c.sh)
 
#!/bin/shfor ((i=1;i<10;i++)) does ((j=1;j<10;j++)) do ((product= $i * $j)) echo-ne $i * $j = $product "\ T" done Echodoneexit 0
 
Note: the command "Echo-ne XXX", the parameter n means the output is complete without wrapping, E for the support of escape characters
 
Three scripts to run:
 
 
END
Shell script: Print 99 multiplication table