Functions utils to play with random number.
Get randomly a number between 0 to 10 or 5.
if rand::boolean; then
echo "$(rand::next 10)"
else
echo "$(rand::next 5)"
fi| #/bin/bash | |
| # Functions utils to play with random number | |
| # Return a random number from 0 to bound (exclusive). | |
| # BOUND | |
| function rand::next () { | |
| echo $(( $RANDOM % $1 )) | |
| } | |
| # Return randomly true or false (1/0). | |
| function rand::boolean () { | |
| (( $RANDOM % 2 == 0 )) | |
| } |