function random()
{
min=$1
max=$2
num=$(date +%s+10#%N)
((retnum=num%max+min))
echo $retnum
}
string=$1
str_length=${#string}
rnd_num=$(random 1 $str_length)
let out_num=rnd_num-1
echo "The random number is [$rnd_num]. The character is '${string:$out_num:1}'"
echo `date +"%Y-%m-%d %H:%M:%S"` begin >>文件路径
echo $RANDOM >>文件路径
shell中有一个环境变量为$RANDOM,实际的取值范围为:0-32767
echo `date +"%Y-%m-%d %H:%M:%S"` '我是中文' $RANDOM >>文件路径
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)