方法一 #!/bin/bash # for I in {1..9}; do for A in `seq 1 $I`; do echo -n "${I}X${A}=$[$I*$A] " done echo done
方法二 #!/bin/bash # for (( i=1;i<=9;i++)) do for (( j=1;j<=i;j++)) do echo -n "$i*$j=$[i*j] " done echo done