工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago)、bash
#!/bin/bash
#
xm=(`cat name.txt`)
for i in ${xm[@]}
do
xb=$(($RANDOM%${#xm[@]}))
echo -n "${#xm[@]} "
echo ${xm[$xb]}
unset xm[$xb]
xm=(`echo ${xm[@]} `)
done
注释:取出一个,删除一个,重新赋值
转载于:https://blog.51cto.com/8776055/1834951