0

How to generate five 2- digit random number?

My code is generating 5 random numbers, but it is also generating 1- digit random number. Here is my code: for i in {1..5} do echo $(( ( RANDOM% 99 )+100 )) done

14th Feb 2020, 6:37 PM
Prithvi
3 ответов
+ 1
I'm not familiar with shellscript, but looking at how you do it, it looks like C rand() call. In C, the following generates random number between 10 and 99 (two digits). Perhaps you can try it with shellscript too. rand() % 90 + 10;
15th Feb 2020, 6:07 AM
Ipang
+ 1
Thank you Ipang. Even I tried the same solution after a few researches.
15th Feb 2020, 6:29 AM
Prithvi
+ 1
Good luck Prithvi Keep trying ... 💪
15th Feb 2020, 6:35 AM
Ipang