Xiaohan talks about Shell environment variables - RANDOM

RANDOM variable

Shell has an environment variable RANDOM, the range is 0-32767.

Xiaohan practical camp

  •  We want to generate a number in the range of 0-25
[root@hya ~]# echo $(($RANDOM%26))
20
  •  Get a number in the range of 1--68:
[root@hya ~]# echo $(($RANDOM%68+1))
47
  • Get a number in the range of 6-87:
[root@hya ~]# echo $(($RANDOM%68+6))
23

 

Guess you like

Origin blog.csdn.net/yeyslspi59/article/details/108645797