Issue
I apologize if my title question is too broad. I am trying to generate a variable that is a random multiple of 3 between a certain range.
randomNumber= Multiple of 3 between 45 and 72
Solution
Bash has a builtin RANDOM
(0 ~ 32767) var. If you have Bash 5.1+, there's also SRANDOM
(0 ~ 4294967295).
[Bash-5.2] % echo $(( 3 * (15 + RANDOM % 10) ))
51
[Bash-5.2] % echo $(( 3 * (15 + RANDOM % 10) ))
57
[Bash-5.2] % echo $(( 3 * (15 + RANDOM % 10) ))
48
Answered By - pynexj Answer Checked By - Robin (WPSolving Admin)