Random Number Variable in BASH - Linux Commands @linuxleech
Random Number Variable in BASH - Linux Commands  @linuxleech
Uploaded April 2019 | Updated September 2026, 16 hours ago
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: youtube.com/user/linuxleech?sub_confirmation=1

Blog: linuxleech.com
Twitter: twitter.com/linuxleech
Facebook: facebook.com/linuxleech
Google+: gplus.to/linuxleech
Random Number Variable in BASH - Linux CommandsTee Command in Linux - with examplesBASH Shell commands file ( commands for linux )Use a Mouse with GNU Screen Terminal Multiplexer - Commands for LinuxVirtualbox 6 Performance Trick to Get More Video MemoryLinux Leech Live StreamBASH Shell commands wildcards ( commands for Linux )Dual booting Ubuntu and WindowsHow to use GNU SCREEN - the Terminal Multiplexer - linuxpdf to textHow to use aliases in BASHVirtualbox boot from USB key
Linux Leech |

Random Number Variable in BASH - Linux Commands

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER