I ran the following command to generate 1 billion random numbers:
time shuf -i 1-1000000000 > "SHUF TEST 1"
To my surprise it was able to do this in less than 10 mins. I then ran the output file through
uniq -d to determine how many of the generated numbers were duplicate, and was again surprised when it turned out to be 0. I also ran the output file through
uniq -u and
sort -u to confirm these results.
How is it that the
shuf command is able to generate a billion random numbers in such a relatively short amount of time, and can I depend on its randomness? Note that I don't need a cryptographically secure random number generator for my needs, just something good enough to always return a unique number.