1 #!/bin/bash 2 #__author__:lushenle 3 #description:Generaye 10 random numbers and sort 4 #Version:0.0.1 5 # 6 declare -a nums 7 declare -i t 8 for i in {0..9};do 9 nums[$i]=$RANDOM 10 echo ${nums[$i]} 11 done 12 13 for ((i=0;i<${#nums[@]};i++));do 14 for ((j=${#nums[@]}-1;j>i;j--));do 15 if [[ ${nums[j]} -lt ${nums[j-1]} ]];then 16 t=${nums[j]} 17 nums[j]=${nums[j-1]} 18 nums[j-1]=$t 19 fi 20 done 21 done 22 echo ${nums[@]}