Linux Script to generate random numbers in a given range

Generating random numbers is common recruitment in number of scripts. bash by default gives a variable $RANDOM which when accessed gives a random number between 0 and 32767.

There might be situations where we might need random numbers between a range of smaller numbers or between zero and a smaller number than 32767. Here is a script which can be used to generate random numbers between any range of numbers.

It takes as input the lower limit and the upper limit of the random numbers required and then generates the required number of random numbers with in the range.


save the script as,give it execute permissions.

Now execute the script to generate the random numbers

Thus we can see we can generate any number of random numbers with in any given range, using the script.

Follow by Email