linux 系统中如何产生随机数

1、$RANDON, 产生的随机数的范围是0~32767

[root@centos79 test]# echo $RANDOM
6420
[root@centos79 test]# echo $RANDOM
1799

2、产生20个1-100的随机数

[root@centos79 test]# for i in `seq 20`; do expr $RANDOM % 100 + 1 >> a.txt; done
[root@centos79 test]# ls
a.txt
[root@centos79 test]# wc -l a.txt
20 a.txt
[root@centos79 test]# cat a.txt
8
16
13
77
92
89
39
41
12
69
53
1
31
85
2
16
87
7
60
30
原文地址:https://www.cnblogs.com/liujiaxin2018/p/15109947.html