MyTetra Share
Делитесь знаниями!
Select a random item from an array
Время создания: 24.08.2015 16:59
Раздел: root - Linux - Console - bash
Запись: Yurons/mytetra/master/base/1440424772hpbe7dr0lb/text.html на raw.github.com
# 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 % ${#expressions[@]} ]}

    # Write to Shell
    echo $selectedexpression


    # Wait an half hour
    sleep 1 # It's one second for debugging, dear SOers
done

 
MyTetra Share v.0.65
Яндекс индекс цитирования