shell脚本练习
Posted 东篱昏后
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本练习相关的知识,希望对你有一定的参考价值。
三角形
#!/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 #倒直角三角形 read -p "please input the length(倒直角三角形): " len for i in `seq 1 $len` do for j in `seq $i $len` do echo -n "* " done echo done #直角三角形 read -p "please input the length(直角三角形): " len for i in `seq 1 $len` do for ((j=1;j<=$i;j++)) do echo -n "* " done echo done #菱形 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 for i in `seq 1 $n` do for ((j=1;j<=$i;j++)) do echo -n " " done for ((k=$i;k<=$len-1;k++)) do echo -n "* " done echo done
以上是关于shell脚本练习的主要内容,如果未能解决你的问题,请参考以下文章