bash 语言的乘法表

 1 #!/bin/bash
 2 
 3 if [ $# -ne 1 ];then
 4         echo parmeter must be 1
 5         exit
 6 fi
 7 
 8 for ((i=1; i<$1; i++)); do
 9         for ((j=1; j<=i; j++)); do
10                 tput setaf $j
11                 echo -ne "$j"X"$i"=$((i*j))"\t"
12         done
13         echo
14 done

 如果参数不对,会显示如下

正确的命令是:

 

posted @ 2019-01-07 11:46  落叶心声  阅读(345)  评论(0编辑  收藏  举报

Contact with me