zoukankan      html  css  js  c++  java
  • shell脚本实例-matrix

    [Sat Feb 27 17:51:36 1038 /dev/pts/0 192.168.2.250 ~/sh]#cat matrix
    blue="33[0;34m"
    brightblue="33[1;34m"
    cyan="33[0;36m"
    brightcyan="33[1;36m"
    green="33[0;32m"
    brightgreen="33[1;32m"
    red="33[0;31m"
    brightred="33[1;31m"
    white="33[1;37m"
    black="33[0;30m"
    grey="33[0;37m"
    darkgrey="33[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 "33[2C";;
          esac
         done
         printf "
    "
        done
        tput cup 0 0
    done
  • 相关阅读:
    《团队-团队编程项目作业名称-成员简介及分工》
    《团队-团队编程项目作业名称-需求分析》
    《结对-结对编项目作业名称-需求分析》
    团队编程项目总结
    并发工具包
    并发工具包
    spring注解的源码解释
    webservice客户端
    线程池
    问题
  • 原文地址:https://www.cnblogs.com/createyuan/p/5223323.html
Copyright © 2011-2022 走看看