shell写一个图形形状
#!/bin/bash
#
read -p "Please enter a number:" number
for ((i=1;i<=$number;i++))
do
for((j=1;j<$number;j++))
do
echo -n "+ "
done
echo "+"
done[root@node home]# ./square.sh
Please enter a number:4
+ + + + +
+ + + + +
+ + + + +
+ + + + +[root@node home]# cat triangle.sh
#!/bin/bash
#
read -p "Please enter a number:" number
for ((i=1;i<=$number;i++))
do
for((j=1;j<$i;j++))
do
echo -n " * "
done
echo " *"
done
[root@node home]# ./triangle.sh
Please enter a number:8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *待续