Random Number Variable in BASH - Linux Commands
In this video we go over how to generate random numbers in bash using the random builtin variable. The random variable doesn't act like any normal variable in BASH. Assigning a number to the random variable seeds the variables random number generator instead of storing it.
As the random variable generates pseudorandom numbers, by controlling the seed value you can actually predict the numbers that the random variable will produce.
The first example that we go over is how to produce random numbers that are within a range of 0-10 and 1.10.
We expand on this in the second example by restricting the numbers produced to be a binary random choice of either 0 or 1.
Following on we create a dice roll by restricting the range of random numbers to be 1-6.
In the next example we shift the range to start at 1000 instead of zero or one and restrict the upper limit to 1500.
The final example illustrates a method to create numbers larger than the largest number the random variable is capable of producing which is 32,767.
We generate 6 digit random numbers but the same method can be used to produce much larger numbers.
Subscribe: https://www.youtube.com/user/linuxleech?sub_confirmation=1
Blog: http://www.linuxleech.com
Twitter: http://www.twitter.com/linuxleech
Facebook: http://www.facebook.com/linuxleech
Google+: http://www.gplus.to/linuxleech