#Bash, 66
LANG=C sed -r '/^-?(0|[1-9][0-9]*)$/q;s/.*/5000000/;q'</dev/random
It almost always prints 5000000. But if it found a valid number in /dev/random
, it will print that number instead.
And this one is faster:
LANG=C sed -r '/^-?(0|[1-9][0-9]*)$/q;s/.*/5000000/;q'</dev/urandom