码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本:随机抽取任意数量的学生且无重复

时间:2018-10-20 13:36:52      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:输入   exp   ==   bin   bash   read   ===   expr   赵鹏   

=====================================================
随机抽取学生终极版本!!

#!/bin/bash

touch ./temp

read -p "输入抽取人数" C
while [ sort temp | uniq | wc -l != $C ]

do

echo expr $RANDOM % 15 >> temp

done

Z=$(sort temp | uniq)
echo $Z

jw=(‘居思涵‘ ‘李月‘ ‘李鑫‘ ‘唐伟宏‘ ‘王大高‘ ‘纪平‘ ‘陈磊‘ ‘赵鹏凯‘ ‘聂田蔚‘ ‘张政‘ ‘刘宏杰‘ ‘黄辉‘ ‘郑文‘ ‘靖儿‘ ‘啊莉‘ )

for v in ${Z[@]}
do
echo ${jw[$v]}
done

rm temp

===================================================================================

shell脚本:随机抽取任意数量的学生且无重复

标签:输入   exp   ==   bin   bash   read   ===   expr   赵鹏   

原文地址:http://blog.51cto.com/13490688/2306732

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!