Skip to content

Instantly share code, notes, and snippets.

@deven96
Last active March 19, 2021 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deven96/e4c292562a7c3a58f9fdd1d2f8f8fd22 to your computer and use it in GitHub Desktop.
Save deven96/e4c292562a7c3a58f9fdd1d2f8f8fd22 to your computer and use it in GitHub Desktop.
select a random excuse
#!/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