Sometimes, we are programming some script in Bash …. and we need (for some reason) to generate some random number.
For that you can program an entire application (or function ...) yes, but ... curiously our system has already done that 😀
In a terminal, type the following and press [enter]:
echo $ RANDOM
... a number will appear, they do the same thing again and another number appears, and so on 🙂
What it does is show you a random number (any) between 0 and 32768 (integer, that is, without a comma).
If you need it to be a random number, but between 0 and ... let's say 100, you can put that limit on it 😀
echo $ (($ RANDOM% 100))
The same, another example ... if you want it to be a number between 0 and 29 it would be:
echo $ (($ RANDOM% 29))
Is it understood not? 😀
If they will use it in a bash script they are doing, to assign the generated value (a random number) to a variable it would be:
VARIABLE = `echo $ (($ RANDOM))`
Well, this is it, I don't know about you ... but I know that it will be useful to me at some point hahaha.