The purpose of this is basically create a deck of cards and randomly draw 1. Right now, it's not even breaking up the strings and reading them into the array. I get both a command not found for the suites
and the denominations
string and then another error for RANDOM
.
Am I writing in the IFS line wrong? I'm brand new to bash scripting and I really appreciate everyone's help =]!
#!/bin/bash
# Count how many elements.
Suites=“Clubs Diamonds Hearts Spades”
Denominations=“2 3 4 5 6 7 8 9 10 Jack Queen King Ace”
# Read into array variable.
IFS=' '
suite=($Suites)
denomination=($Denominations)
# Count how many elements.
num_suites=${#suite[*]}
num_denominations=${#denomination[*]}
echo -n "${denomination[$((RANDOM%num_denominations))]} of "
echo ${suite[$((RANDOM%num_suites))]}
exit 0