阅读背景:

shell圣诞树脚本_写代码的学渣的博客

来源:互联网 

圣诞树
#!/bin/bash

#!/bin/bash
# Author:
# Create Time:
# File Name:
# Description:
 
DrawTriangle() {
	a=

圣诞树
#!/bin/bash

#!/bin/bash
# Author:
# Create Time:
# File Name:
# Description:
 
DrawTriangle() {
	a=$1
	color=$[RANDOM%7+31]
	if [ "$a" -lt "8" ] ;then 
		b=`printf "%-${a}s\n" "0" |sed 's/\s/0/g'`
		c=`echo "(31-$a)/2"|bc`
                d=`printf "%-${c}s\n"`
		echo "${d}`echo -e "\033[1;5;${color}m$b\033[0m"`"
	elif [ "$a" -ge "8" -a "$a" -le "21" ] ;then
		e=$[a-8]
		b=`printf "%-${e}s\n" "0" |sed 's/\s/0/g'`
		c=`echo "(31-$e)/2"|bc`
		d=`printf "%-${c}s\n"` 
		echo "${d}`echo -e "\033[1;5;${color}m$b\033[0m"`"
	fi
}
DrawTree() {
	e=$1
	b=`printf "%-5s\n" "|" | sed 's/\s/|/g'`
	c=`echo "($e-5)/2"|bc`
	d=`printf "%-${c}s\n" " "`
	echo -e "${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}"
}
Display(){
	for i in `seq 1 2 31`; do
		[ "$i"="21" ] && DrawTriangle $i
		if [ "$i" -eq "31" ];then	
			DrawTree $i
		fi
	done
}
while :
do
	Display
	sleep 2
	clear
done
 




color=$[RANDOM%7+31] if [ "$a" -lt "8" ] ;then b=`printf "%-${a}s\n" "0" |sed 's/\s/0/g'` c=`echo "(31-$a)/2"|bc` d=`printf "%-${c}s\n"` echo "${d}`echo -e "3[1;5;${color}m$b3[0m"`" elif [ "$a" -ge "8" -a "$a" -le "21" ] ;then e=$[a-8] b=`printf "%-${e}s\n" "0" |sed 's/\s/0/g'` c=`echo "(31-$e)/2"|bc` d=`printf "%-${c}s\n"` echo "${d}`echo -e "3[1;5;${color}m$b3[0m"`" fi } DrawTree() { e=

圣诞树
#!/bin/bash

#!/bin/bash
# Author:
# Create Time:
# File Name:
# Description:
 
DrawTriangle() {
	a=$1
	color=$[RANDOM%7+31]
	if [ "$a" -lt "8" ] ;then 
		b=`printf "%-${a}s\n" "0" |sed 's/\s/0/g'`
		c=`echo "(31-$a)/2"|bc`
                d=`printf "%-${c}s\n"`
		echo "${d}`echo -e "\033[1;5;${color}m$b\033[0m"`"
	elif [ "$a" -ge "8" -a "$a" -le "21" ] ;then
		e=$[a-8]
		b=`printf "%-${e}s\n" "0" |sed 's/\s/0/g'`
		c=`echo "(31-$e)/2"|bc`
		d=`printf "%-${c}s\n"` 
		echo "${d}`echo -e "\033[1;5;${color}m$b\033[0m"`"
	fi
}
DrawTree() {
	e=$1
	b=`printf "%-5s\n" "|" | sed 's/\s/|/g'`
	c=`echo "($e-5)/2"|bc`
	d=`printf "%-${c}s\n" " "`
	echo -e "${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}"
}
Display(){
	for i in `seq 1 2 31`; do
		[ "$i"="21" ] && DrawTriangle $i
		if [ "$i" -eq "31" ];then	
			DrawTree $i
		fi
	done
}
while :
do
	Display
	sleep 2
	clear
done
 




b=`printf "%-5s\n" "|" | sed 's/\s/|/g'` c=`echo "($e-5)/2"|bc` d=`printf "%-${c}s\n" " "` echo -e "${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}\n${d}${b}" } Display(){ for i in `seq 1 2 31`; do [ "$i"="21" ] && DrawTriangle $i if [ "$i" -eq "31" ];then DrawTree $i fi done } while : do Display sleep 2 clear done #!/bin/bash # Author:



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: