shell脚本实例

1.打印形状

#!/bin/bash
# 打印等腰三角形
read -p "Please input the length: " n
for i in `seq 1 $n`
do
   for ((j=$n;j>i;j--))
   do
     echo -n " " 
   done

   for m in `seq 1 $i`
   do
     echo -n "* "
   done
   echo 
done

相关推荐