Upload Tizen:Base source
[external/bash.git] / examples / scripts / randomcard.bash
1 # The following prints a random card from a card deck.
2 #
3 # cribbed from the ksh93 book, example from page 70
4 #
5 # chet@po.cwru.edu
6 #
7 declare -i i=0
8
9 # load the deck
10 for suit in clubs diamonds hearts spades; do
11         for n in ace 2 3 4 5 6 7 8 9 10 jack queen king; do
12                 card[i]="$n of $suit"
13                 i=i+1           # let is not required with integer variables
14         done
15 done
16
17 # and print a random card
18 echo ${card[RANDOM%52]}