方法一:
1 #!/bin/bash 2 for a in {1..9};do 3 for b in {1..9};do 4 c=`echo "$a*$b" |bc` 5 if [ "$a" -ge "$b" ];then 6 echo -n -e "$b*$a=$c\t" 7 fi 8 done 9 echo 10 done
方法二:
1 #!/bin/bash 2 for a in `seq 1 9`;do 3 for b in `seq 1 $a`;do 4 c=`awk BEGIN"{print $a*$b}"` 5 echo -n -e "$b*$a=$c\t" 6 done 7 echo 8 done
方法三:
1 #!/bin/bash 2 for ((a=1;a<=9;a++));do 3 for ((b=1;b<=a;b++));do 4 echo -n -e "$b*$a=$((a*b))\t" 5 done 6 echo 7 done