Generating random numbers with bash


While perusing through some documentation last week, I came across the bash RANDOM variable. This nifty little built-in can be used to generate a random signed integer value:

$ echo $RANDOM
17142

$ echo $RANDOM
1713

This could definitely be valuable for solving some bash-specific problems, but nothing can replace /dev/random and a hardware random number generator.

This article was posted by Matty on 2006-02-11 13:17:00 -0400 -0400