貼多個香港**彩的生成器

貼多個香港**彩的生成器

小弟寫的,用他沒中一次  

#! /bin/bash
# marksix genertor, Usage: $0 [ [option] argument ]
#  twf_cc@yahoo.com.hk

output=""
base_array=({1..49})
length=${#base_array[@]}
argument=$1
howmany=${argument:-6}
usage="Usage:\t${0##*/} [[option] number of picks](default 6)"
message_to_user="Number of picks should not be greater than $length"
out_of_range=66
non_numberic_argument=65

  if [[ $howmany =~ [^0-9]+ ]]
    then
      echo -e "$usage" >&2 ; exit $non_numberic_argument
  elif [ $howmany -gt $length ]
    then
      echo "$message_to_user" >&2 ; exit $out_of_range
  fi

  for (( i=1 ; i<=howmany ; i++ ))
    do
      pick=${base_array[$(( RANDOM % length ))]}
      output="$output $pick"
      resize_array=($(echo ${base_array[@]} | sed "s/ $pick//"))
      base_array=(${resize_array[@]})
      length=${#base_array[@]}
    done

  sort_result=$( printf '%s\n' $output | sort -n )
  echo -e ${sort_result//\n/" "}      
journalist
6 he cai? 有意思
繁体? 不是大陆人士?

      
come from HK       
journalist
难得. 欢迎 HK man (or woman?)       
man , 電腦用我老婆的名,       
journalist