#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 it instead.