Created
May 2, 2020 16:03
-
-
Save snown/f1ce40ed14b2a54e937c1a0f23ba40a7 to your computer and use it in GitHub Desktop.
Return a random number between two limits
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
# Return a random number between two limits | |
#------------------------------------------------------------------------------- | |
function random { | |
#default to numbers between 1-10 | |
local _min="${1:-1}" | |
local _max="${2:-10}" | |
local diff=$((${_max}-${_min}+1)) | |
echo -n "$(($((${RANDOM}%${diff}))+${_min}))" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment