Recently, I was going to review the shell, just to see the shell operation, and to write a simple 99 multiplication table like a beginner. It is suggested that you can run shell scripts directly in Http://www.runoob.com/try/runcode.php?filename=helloworld&type=bash if you do not want to install Linux environments.
First, the previous code
#!/bin/bash
#使用while循环
I=1;
While [$i-le 9];d o #-le means less than or equal to
J=1;
While [$j-le $i];d o
Echo-n ${j} "x" $[i] "=" ' Expr $i \* $j ' ""; #echo-n means that the output does not wrap, string stitching
j= ' expr $j + 1 '; #下标加1, you can also use the Let J + +
Done
echo ""; #换行
i= ' expr $i + 1 ';
Done
#使用for循环
echo "For loop implementation"
For k in ' SEQ 1 9 ';d o #使用seq increment sequence
for (m=1; $m <= $k; m++);d o
Echo-n ${m} "x" ${k} "=" ' Expr $m \* $k ' "";
Done
echo "";
Done
Operation Result:
Shell Practice Applet Exercise--99 multiplication table