标签:count() cas result (()) 变量 one echo max $$
random 用法
用这个环境变量对26取模即可。
如果想得到4--20范围内的数 : $(($RANDOM%20+4 ))
#!/bin/bash
#RANDOM=$$
PIPS=6
MAX=10000
throw=1
one=0
two=0
three=0
four=0
five=0
five=0
six=0
count()
{
case $1 in
0) let "one=one+1";;
1) let "two=two+1";;
2) let "three=three+1";;
3) let "four=four+1";;
4) let "five=five+1";;
5) let "six=six+1";;
esac
}
while [ $throw -le $MAX ]
do
let "dice=RANDOM % $PIPS"
count $dice
let "throw=throw + 1"
done
echo "The statistics results are as follows:"
echo "one=$one"
echo "two=$two"
echo "three=$three"
echo "four=$four"
echo "five=$five"
echo "six=$six"
标签:count() cas result (()) 变量 one echo max $$
原文地址:http://www.cnblogs.com/sxwen/p/8000513.html