---
title: "Shell随机生成几个不重复的随机数"
author: "polyahu"
date: "2013-02-04T23:48:46Z"
tags: []
categories: ["编程语言"]
slug: "shell"
draft: false
lastmod: "2013-02-05T10:20:40Z"
id: 1788860
url: "https://polyahu.iteye.com/blog/1788860"
---

模拟体育彩票，36选7。
要求：随机，7个不重复，1到36这些整数。


```Bash

#!/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

```


just for fun... 练习一下shell编程。