This command, which generates numbers from
/dev/urandom and prints how many repeated numbers there are, returns the same on every system. Why?
dd if=/dev/urandom count=1 bs=5M 2> /dev/null | od - | cut -d " " -f 2- | sed s/" "/"\n"/g | sort -n | uniq -d | wc -l
This is the command, on every system that I ran this on it returns 256^2, the 16 bit upper limit, the amount of ports on a UNIX system, or just 65536, including on different architectures.
The weird thing about this is, that each number is 6 digits and the data dump, even at 5M, is substantially bigger than the amount of possible numbers ~ It is highly unlikely that the number doesn't get repeated.
Amount of possible numbers: 100000 (because 00000-99999)
Lines in the data dump (5M): 2621441
It prints the same with any dataset above c.a. 1M.
And if I grep in the output for a random number, lets say 045765 it pops up 35-47 times, each time a different amount.
I wrote a small python script to count the numbers, and only one wasn't unique, but that was the last number in the dumb, probably because of the EOF. When printing the data dump it's always longer than the rest of the numbers and just didn't fit, so we can just ignore it. It proves tho that no number is unique, which with 2621441 lines proves that there are more than 65536 unique numbers.
I can't wrap my head around, how this can happen... Some component in that command has to have a bug.
Does anyone have an explanation as to how this can happen?