Created
May 25, 2019 13:33
-
-
Save ruanbekker/27b64820907a8853e676bdef723d1909 to your computer and use it in GitHub Desktop.
Selecting Random Numbers in BASH
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
# 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