#!/bin/bash
for j in {1..9}dofor i in `seq $j`
do
echo -e -n "${i}x${j}=$[ $i * $j ]\t"
done
echo
done
实现效果
[root@localhost ky15]# sh 99.sh
1x1=11x2=22x2=41x3=32x3=63x3=91x4=42x4=83x4=124x4=161x5=52x5=103x5=154x5=205x5=251x6=62x6=123x6=184x6=245x6=306x6=361x7=72x7=143x7=214x7=285x7=356x7=427x7=491x8=82x8=163x8=244x8=325x8=406x8=487x8=568x8=641x9=92x9=183x9=274x9=365x9=456x9=547x9=638x9=729x9=81
[root@localhost ky15]# sh 99.sh
1x1=11x2=22x2=41x3=32x3=63x3=91x4=42x4=83x4=124x4=161x5=52x5=103x5=154x5=205x5=251x6=62x6=123x6=184x6=245x6=306x6=361x7=72x7=143x7=214x7=285x7=356x7=427x7=491x8=82x8=163x8=244x8=325x8=406x8=487x8=568x8=641x9=92x9=183x9=274x9=365x9=456x9=547x9=638x9=729x9=81
倒三角
#!/bin/bash
for j in {9..1..-1}dofor i in `seq $j`
do
echo -e -n "${i}x${j}=$[ $i * $j ]\t"
done
echo
done
实现效果
[root@localhost ky15]# sh 99.sh
1x9=92x9=183x9=274x9=365x9=456x9=547x9=638x9=729x9=811x8=82x8=163x8=244x8=325x8=406x8=487x8=568x8=641x7=72x7=143x7=214x7=285x7=356x7=427x7=491x6=62x6=123x6=184x6=245x6=306x6=361x5=52x5=103x5=154x5=205x5=251x4=42x4=83x4=124x4=161x3=32x3=63x3=91x2=22x2=41x1=1