source: vendor/bash/3.1/examples/scripts/randomcard.bash

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 409 bytes
Line 
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#
7declare -i i=0
8
9# load the deck
10for 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
15done
16
17# and print a random card
18echo ${card[RANDOM%52]}
Note: See TracBrowser for help on using the repository browser.