Shell随机生成几个不重复的随机数


Shell随机生成几个不重复的随机数
 
模拟体育彩票,36选7。 
  www.2cto.com  
要求:随机,7个不重复,1到36这些整数。 
 
#!/bin/bash
 
touch ./temp
>temp
 
while [ `sort temp | uniq | wc -l` != 7 ] 
do
  echo `expr $RANDOM % 36 + 1` >> temp
done
 
sort temp | uniq
 
rm temp

相关内容

    暂无相关文章