Skip to content

Instantly share code, notes, and snippets.

@snown
Created May 2, 2020 16:03
Show Gist options
  • Save snown/f1ce40ed14b2a54e937c1a0f23ba40a7 to your computer and use it in GitHub Desktop.
Save snown/f1ce40ed14b2a54e937c1a0f23ba40a7 to your computer and use it in GitHub Desktop.
Return a random number between two limits
# 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