Created
April 8, 2015 04:56
-
-
Save joerx/bd2ea764ceaa182c01da to your computer and use it in GitHub Desktop.
Random item from list in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Array with expressions | |
dishes=(":hamburger:" ":pizza:" ":poultry_leg:" ":rice:" ":curry:" ":ramen:" ":spaghetti:" ":sushi:") | |
# Seed random generator | |
RANDOM=$$$(date +%s) | |
# Get random expression... | |
selecteddish=${dishes[$RANDOM % ${#dishes[@]} ]} | |
echo $selecteddish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracefully copied from somebody on Stackoverflow, modified by me to make it more tasty.