使用简单shell编写打印九九乘法表
[root@Centos7 bin]#vim 99.sh
#!/bin/bash
for i in {1..9};do
for j in {1..9};do
if [ $j -le $i ];then
echo -e "$j*$i=$[i*j]\t\c"
fi
done
echo
done
结果如下图:
使用简单shell编写打印国际棋盘
#!/bin/bash
for i in {1..8};do
temp1=$[ $i % 2 ]
for j in {1..8};do
temp2=$[ $j % 2 ]
if [ $temp1 -eq $temp2 ];then
echo -e -n "\033[47m \033[0m"
else
echo -e -n "\033[41m \033[0m"
fi
done
echo
done
结果如下: