graph.sh
#!/bin/bash
clear
#print first picture
for (( i=1; i<=9; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n "$i"
done
echo ""
done
read -n1 -p "press any key to continue:" key
#-n:the length of text
#print second picture
clear
for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " |"
done
echo "_ "
done
read -n1 -p "press any key to continue:" key
#-n:the length of text
#print third picture
clear
for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done
for (( i=5; i>=1; i-- ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done
验证:
[root@logstash ~]# sh graph.sh
1
22
333
4444
55555
666666
7777777
88888888
999999999
press any key to continue:
|_
| |_
| | |_
| | | |_
| | | | |_
press any key to continue:
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
[root@logstash ~]#