- 🐚作者简介:花神庙码农(专注于Linux、WLAN、TCP/IP、Python等技术方向)
- 🐳博客主页:花神庙码农 ,地址:https://blog.csdn.net/qxhgd
- 🌐系列专栏:Linux技术
- 📰如觉得博主文章写的不错或对你有所帮助的话,还望大家三连支持一下呀!!! 👉关注✨、点赞👍、收藏📂、评论。
- 如需转载请参考转载须知!!
[qxhgd@localhost]$ root@sds ~]# echo $RANDOM
[qxhgd@localhost]$ echo $(($RANDOM%11))
[qxhgd@localhost]$ echo $(($RANDOM%9+2))
#!/bin/bash
RANDOM=$$
for i in 'seq 10'
do
echo $RANDOM
done
R=$(($RANDOM%Y))
DIV=$((Y+1))
R=$(($RANDOM%$DIV))
DIFF=$((Y-X+1))
R=$(($(($RANDOM%$DIFF))+X))
od -An -N1 -i /dev/random #(0 – 255)
od -An -N2 -i /dev/random #(0 – 65535)
od -An --format=dI ~/random_number
cat /dev/random | tr -dc '0-9' | head -c 4
dd if=/dev/urandom of=~/random_number count=4 bs=1
rand=$((0x$(hexdump -n 1 -ve '"%x"' /dev/random) % 100))
BEGIN {print rand()}
function randint(n)
{
return int(n * rand())
}
for i in $(seq 1 5) ; do
awk -v seed=$RANDOM 'BEGIN{srand(seed);print rand()}'
done
shuf -i LO-HI [OPTION]
shuf -i MIN-MAX -n COUNT
其中,MIN为最小值,MAX为最大值,COUNT为生成随机数的数目。
[qxhgd@localhost]$ shuf -i 0-100 -n1
76
[qxhgd@localhost]$ shuf -i 0-100 -n 1
76
# Where 0 is the start (inclusive), .01 is the increment, and 1 is the end (inclusive).
seq 0 .01 1 | shuf | head -n1
如本文对你有些许帮助,欢迎大佬加关注、评论、点赞,有关必回关