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

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