七彩随机shell小程序
发布时间:2020-12-15 07:11:25 所属栏目:安全 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/bin/bash#author:yanqi 2014-8-17export COLUMNS=80export LINES=40__win_C__=`tput cols`__win_L__=`tput lines`random_c(){ if [ -n "$1" ];the
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 #!/bin/bash #author:yanqi 2014-8-17 export COLUMNS=80 export LINES=40 __win_C__=`tput cols` __win_L__=`tput lines` random_c(){ if [ -n "$1" ];then #local random_num=`sed 's/-//g' /proc/sys/kernel/random/uuid|sed 's/[a-Z]//g'|sed -r 's/^0+//g'|cut -c 1-5` random_num=$RANDOM r_num=$((random_num % $1)) fi return 0; } random_cur_loc(){ random_c $__win_C__ cur_c=$r_num random_c $__win_L__ cur_l=$r_num } random_color(){ random_c 6 color_num=$r_num color=$((color_num+31)) } clear_win(){ `tput clear` } init_win(){ tput init tput setb 0 tput setf 7 tput cup 0 0 tput civis } move(){ tput cup $1 $2 } return_l(){ tput rev } print_l(){ echo -e " 33[1;$2;40m $1 33[0m" sleep 1 tput clear } clear_40(){ move 40 5 echo " " } main(){ clear_win; init_win; random_cur_loc; while : do random_cur_loc; random_color; if [ $cur_l -gt 20 ];then if [ $cur_c -gt 40 ];then move $cur_l $cur_c&&print_l "hello friends" "$color" else move $cur_l $cur_c&&print_l "hello baby" "$color" fi else if [ $cur_c -gt 40 ];then move $cur_l $cur_c&&print_l "hello yanqi" "$color" else move $cur_l $cur_c&&print_l "hello gays" "$color" fi fi clear_40&&move 40 5&&echo $cur_l $cur_c $color done } main; exit 0 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |