Notes & TILs
Search…
Generate random numbers in bash
Posted on July 29, 2020
Easiest way is to use the $RANDOM variable.
1
>> echo "$RANDOM"
2
12261
Copied!
Each time this parameter is referenced, a random integer between 0 and 32767 is generated.
A better way which I like is to use the GNU coreutil, shuf
One Random number between 69 & 420
1
shuf -i69-420 -n1
Copied!
Five Random numbers between 69 & 420
1
shuf -i69-420 -n5
Copied!
Last modified 1mo ago
Copy link