linux脚本 随机数

来源:互联网 发布:软件回归测试 编辑:程序博客网 时间:2024/04/30 04:04
#!/bin/bash


#$RANDOM 5 bit random number
#random one parameter integer
random()
{
    systemRandom=$RANDOM;
    myRandom=$(($systemRandom%$1));
    echo $myRandom;
}


out=$(random 3);
if [ $out -eq 0 ] ; then
    echo $out;
elif [ $out -eq 1 ] ; then
    echo $out;
elif [ $out -eq 2 ] ; then
    echo $out;
elif [ $out -eq 3 ] ; then
    echo $out;
fi


 
for (( i = 0; i < 10 ; i ++ ))
do
    echo $i , $(random 10);
done

0 0
原创粉丝点击