Trix & Graphix

Generating random numbers within a Bash script

Unix systems has their own random numgers generator. It can be employed, for instance, to generate a sequence of random numbers inside a Bash script. The only thing that has to be done is to use the internal function $RANDOM

The next example illustrates the idea:

set -ex

for i in $(jot 100 1 1); do
echo $RANDOM >> file
done

1 Comment:

Anonymous said...

Very good sharing this.