[root@centos7 ~]
arr=()
length=${#arr[@]}
while [ "${length}" -lt 6 ]
do
s=$[$RANDOM%33+1]
if [[ ! "${arr[@]}" =~ "${s}" ]]
then
arr["${length}"]=$s
let length+=1
else
echo '存在'> /dev/null
fi
done
for ((i=0; i<${#arr[@]}; i++))
do
for ((j=0; j<${#arr[@]}-1; j++))
do
if [[ ${arr[j]} -gt ${arr[j+1]} ]]
then
min=${arr[j+1]}
max=${arr[j]}
arr[j]=$min
arr[j+1]=$max
fi
done
done
echo "^[[1;31m红色球:${arr[@]}^[[0m"
echo "^[[1;34m蓝色球:$[$RANDOM%16+1]^[[0m"
[root@centos7 ~]
红色球:10 11 12 17 26 32
蓝色球:13
插入颜色字符
1 切换至插入模式
2 按ctrl+v+[ 三个键,显示^[
3 后续输入颜色信息,如:^[[1;31m红色球:${arr[@]}^[[0m
4 切换至扩展命令模式,保存退出