Script to Generate Random Number Easily

How to generate random number



Here's a bash script to generate a random number. You can use this logic to generate a random number, and it is useful for AWS engineers.

Random number


Script - Here's sample logic to get a random number



RANDOM=$$ # Set the seed to the PID of the script
UPPER_LIMIT=$1
RANDOM_NUMBER=$(($RANDOM % $UPPER_LIMIT + 1))
echo "$RANDOM_NUMBER"




If you select UPPER_LIMIT as 100, then the result would be a pseudo-random number between 1 and 100.



Her is the output after executing the script




Related posts

Comments

Most Popular

7 AWS Interview Questions asked in Infosys, TCS

How to Decode TLV Quickly

Hyperledger Fabric: 20 Real Interview Questions