[root@localhost ~]# cat sanjiaoxing.sh #!/bin/bash
# Crushlinux
# 2017-04-10 read -p "请输入等边三角形一条边的长度:" long for ((a=1;a<=long;a++)) do echo -n " " for (( b=$long;b>a;b--)) #控制空格输出 do echo -n " " done for c in `seq 1 $a` #输出所在行数相同的数字个数 do echo -n "$a" done for d in `seq 2 $a` #输出所在行数减一的数字个数 do echo -n "$a" done echo "" done [root@localhost ~]# bash sanjiaoxing.sh 请输入等边三角形一条边的长度:8 1 222 33333 4444444 555555555 66666666666 7777777777777 888888888888888