Shell编程之matrix---装逼又炫酷
【摘要】
代码如下:
#!/bin/bash
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"...
代码如下:
#!/bin/bash
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"
green="\033[0;32m"
brightgreen="\033[1;32m"
red="\033[0;31m"
brightred="\033[1;31m"
white="\033[1;37m"
black="\033[0;30m"
grey="\033[0;37m"
darkgrey="\033[1;30m"
colors=($blue $brightgreen $grey)
spacing=${1:-100}
scroll=${2:-0}
screenlines=$(expr `tput lines` - 1 + $scroll)
screencols=$(expr `tput cols` / 2 - 1)
chars=(a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) ##请在此处修改你想显示的字符
count=${#chars[@]}
colorcount=${#colors[@]}
trap "tput sgr0; clear; exit" SIGTERM SIGINT
if [[ $1 =~ "-h" ]]
then
echo "display a matrix screen in the terminal"
echo "usage: matrix [SPACING [SCROLL]]"
echo "example: matrix 100 0"
exit 0
fi
clear
tput cup 0 0
while :
do
for i in $(eval echo {1..$screenlines})
do
for i in $(eval echo {1..$screenlines})
do
rand=$(($RANDOM%$spacing))
case $rand in
0)
printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} ";;
1)
printf " ";;
*)
printf "\033[2C";;
esac
done
printf "\n"
done
tput cup 0 0
done
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
执行效果如下:
文章来源: blog.csdn.net,作者:指剑,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/fly1574/article/details/88615633
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)