点名器
echo 'jack' > name.txt
$ echo 'kevin' >> name.txt
$ echo 'monica' >> name.txt
$ echo 'amy' >> name.txt
$ echo 'lily' >> name.txt
#!/bin/bash
#function description: random pick a name, stop with CTRL + C
name_file="name.txt"
line_file=$(sed -n '$=' $name_file)
while :
do
#clear
tmp=$(sed -n "$[RANDOM%line_file+1]p" $name_file)
echo -e "\033[32m random pick name, stop with CTRL+C: \033[0m"
echo -e "\033[32m###############################\033[0m"
echo -e "\033[32m# #\033[0m"
echo -e "\033[32m $tmp \033[0m"
echo -e "\033[32m# #\033[0m"
echo -e "\033[32m##############################\033[0m"
sleep 0.5
done
网友评论