#!/bin/bash
PH=(KD 6S TC 3D) #playerhand
TCIP=(AH) #topcard in play
A=( "${TCIP[@]::1}" ) # A
B=( "${TCIP[@]:1}" ) # H
C=8
for e in ${PH[@]}; do
if [[ $e =~ $A|$B|$C ]]; then
echo "$e " >> /home/cogiz/validcards.txt
else
echo "0" >> /home/cogiz/validcards.txt
fi
done
In the above code, if ${PH[@]}
is scanned for an A,H, or 8 but none of those are found and results are all 0's. How could I then issue a separate command for that situation?
Thank you in advance for any suggestions.
Cogiz