MyTetra Share
Делитесь знаниями!
О, смотри-ка какое хорошее место. Дайте два!
Select a random item from an array
24.08.2015
16:59
Раздел: root - Linux - Console - bash
# 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.35
Яндекс индекс цитирования