3 ms·
This dd(1) command line would get 1 block of 4 bytes from the /dev/random file and output it to stdout. Effectively the same as a call to arc4random(): dd if=/
by acveilleux 12y ago
This dd(1) command line would get 1 block of 4 bytes from the /dev/random file and output it to stdout. Effectively the same as a call to arc4random():
dd if=/dev/random count=1 bs=4
On Linux, you'd use /dev/urandom cause /dev/random blocks stupidly.
- 101914 12y agoAgreed. But I want a pseudorandom real _number_ in decimal, to use in a shell script, not just random bytes. I gave your solution a try. a=$(dd if=/dev/urandom bs=4 count=1|od -An -tx1|sed 's/ //g') printf %d\\n 0x$a