ЗАПИСИ
НОЯБРЬ 14, 2014

Screen Shot 2014 11 13 at 23.00.36 Lottery numbers generator script (bash) %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8

Привет,

Решил вот сгенерировать скриптец на баше и поучаствовать в национальной лотерее Великобритании.

#!/bin/bash
  1.  
  2. # Print usage info
  3. function usage() {
  4.   echo "Usage: $0 "
  5.   echo " * lotto   — Lotto"
  6.   echo " * eurom   — Euro Millions"
  7.   echo " * tball   — Thunderball"
  8.   echo " * hotpick — Lotto Hotpicks"
  9.   echo "More info about UK National Lottery visit https://www.national-lottery.co.uk/games/lotto"
  10. }
  11.  
  12. # Check input params
  13. if [ -z "$1" ]; then
  14.   usage
  15.   exit 1
  16. fi
  17.  
  18. type=$1
  19.  
  20. # Generate random number from 1 up to {limit} and print it
  21. function gen_num() {
  22.   limit=$1
  23.   echo -n $[1 + $[ RANDOM % $limit ]]" "
  24. }
  25.  
  26. # Main app
  27. echo -n "Your lucky numbers for $type are: "
  28. case $type in
  29. lotto)
  30.   for i in {1..6}; do gen_num 59; done
  31.   ;;
  32. eurom)
  33.   for i in {1..5}; do gen_num 50; done
  34.   echo -n "+ lucky stars "
  35.   for i in {1..2}; do gen_num 11; done
  36.   ;;
  37. tball)
  38.   for i in {1..5}; do gen_num 39; done
  39.   echo -n "+ thunderball "
  40.   for i in {1..1}; do gen_num 14; done
  41.   ;;
  42. hotpick)
  43.   for i in {1..5}; do gen_num 49; done
  44.   ;;
  45. *)
  46.   usage
  47.   ;;
  48. esac
  49.  
  50. echo ""
  51. echo "Good luck icon smile Lottery numbers generator script (bash) %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8 "

Нет комметрариев