Script to Generate Random Number Easily

Here's a useful Unix script to generate random numbers. In Korn Shell, there is an in-built variable ( 'RANDOM' ). You can use this to write a script quickly. This script is useful for AWS engineers.



Script to Generate Random Number Easily


Here is Script



RANDOM=$$ # Set the seed to the PID of the script

UPPER_LIMIT=$1

RANDOM_NUMBER=$(($RANDOM % $UPPER_LIMIT + 1))

echo "$RANDOM_NUMBER"

Suppose, the user specifies the UPPER_LIMIT as 100, then the result would be a pseudo-random number between 1 and 100.

Actual Result


References

Comments

Popular posts from this blog

How to Fix Python Syntax Errors Quickly

7 AWS Interview Questions asked in Infosys, TCS

Hyperledger Fabric: 20 Real Interview Questions