最佳答案
我正在用 Shell Script 创建一个机器人:
# Array with expressions
expressions=("Ploink Poink" "I Need Oil" "Some Bytes are Missing!" "Poink Poink" "Piiiip Beeeep!!" "Hello" "Whoops! I'm out of memmory!")
# Seed random generator
RANDOM=$$$(date +%s)
# Loop loop loop loop loop loop ...
while [ 1 ]
do
# Get random expression...
selectedexpression=${expressions[$RANDOM % ${#RANDOM[*]}]}
# Write to Shell
echo $selectedexpression
# Wait an half hour
sleep 1 # It's one second for debugging, dear SOers
done
我要它每秒从 expressions
上打印一个随机项目。我试过这个,但它不工作。它每次只打印第一个(Ploink Poink)。有人能帮帮我吗?
谢谢