工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash

#!/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 ---- 删除光标到行尾的字符