A Couple Ways to Return a Random Number on the Command Line

Lets explore a couple ways to get random numbers on the command line.

Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin.
John von Neumann

$RANDOM Bash Internal

$RANDOM is an internal Bash function (not a constant) that returns a pseudo-random integer in the range of 0 - 32767.

echo $RANDOM
8437

echo $RANDOM
29923

Getting a random number between 1 - X, or 0 - (X-1).

X=10
echo $[RANDOM%X+1] # return number between 1 and 10
8

echo $[RANDOM%X]   # return number between 0 and 9
3

Kernel Entropy

A random number from 1 - 256 using kernel entropy:

od -An -N1 -tu1 /dev/random
181

All sorts of options.