Last active
March 19, 2021 12:47
-
-
Save deven96/e4c292562a7c3a58f9fdd1d2f8f8fd22 to your computer and use it in GitHub Desktop.
select a random excuse
This file contains hidden or 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
#!/bin/bash | |
# Generate a random number using date | |
RANDOM=$(date +%s) | |
EXCUSESARRAY=( | |
"to visit Nosarobumeh in the hospital" | |
"for some away screen time" | |
"as I have a slight headache" | |
"to take a rest" | |
"for the next one hour" | |
"for a bit to run some errands" | |
) | |
# Sets the $randomExcuse variable | |
function selectRandomExcuse { | |
# To get the length of an array e.g EXCUSES in bash, we use ${#arrayName[@]} | |
# so $RANDOM % (length of array) gives us a number from 0 - length of array | |
# which we then use to index from the EXCUSESARRAY | |
randomExcuse=${EXCUSESARRAY[$RANDOM % ${#EXCUSESARRAY[@]} ]} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment