用date的纳秒做随机数不严禁

date +%N 产生一个当前时间的纳秒(nanosecond),看上去会比较随机一些
所以也可以用来做随机数

[bash toolbar=”false”]
date +%N | cut -c 7-8 #可以得到一个2位随机数
[/bash]

但如果时间间隔很短的情况下,它可能是增加的。

Leave a Reply

Your email address will not be published. Required fields are marked *