Generating a simple* random number in bash is really easy.
Let say you need a random number between 10 and 30.
Set the variables $MIN and $MAX
MAX=30
MIN=10
Generate the random number in variable $T.
T=$((MIN+$RANDOM%$((MAX-MIN))))
Notice the $RANDOM that is build into bash.
* Simple as in don't use this for security applications.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment