Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created May 25, 2019 13:33
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 ruanbekker/27b64820907a8853e676bdef723d1909 to your computer and use it in GitHub Desktop.
Save ruanbekker/27b64820907a8853e676bdef723d1909 to your computer and use it in GitHub Desktop.
Selecting Random Numbers in BASH
# create the array
for x in {1..1000}
do
array[$x]="$x"
done
# print random number between 1-1000
size=${#array[@]}
echo ${array[$(($RANDOM % $size))]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment