yinian 发表于 2018-8-27 12:04:16

倒数的用法_shell脚本

  工作环境:Red Hat Enterprise Linux Server>  #!/bin/bash
  #
  xingming=(`cat name.txt`)
  echo "共有${#xingming[@]}位成员:${xingming[@]}"
  echo -n "让我们一起倒数:"
  #sleep 1
  #echo -n "3   "
  #sleep 1
  #echo -n "2   "
  #sleep 1
  #echo "1    "
  tput sc
  for i in `seq 10 -1 1`
  do
  tput rc
  sleep 1
  echo -n $i
  tput ed
  done
  echo -e "\n这次选出的成员是:${xingming[$[ $RANDOM % ${#xingming[@]} ]]}"
  注释:tput sc----保存当前光标
  tput rc----恢复到保存光标的位置
  tput ed----删除光标到行尾的字符

页: [1]
查看完整版本: 倒数的用法_shell脚本