0
#!/bin/bash
h=0
l=0
n=0
reads=0
divider=6
while read user_input; do
    ((reads++))
    [ "$user_input" -eq 1 ] && ((l++))
    [ "$user_input" -eq 2 ] && ((n++))
    [ "$user_input" -eq 3 ] && ((h--))
    if [ "$((reads%52))" -eq 0 -a "$divider" -gt 1 ]; then
        ((divider--))
    fi
    echo "      True Count $(($((h+l))/divider))    High cards $h/120   Null Cards $n/72   Low Cards $l/120"
done
cas
  • 1
  • 7
  • 119
  • 185
Wolfgang Steele
  • 91
  • 1
  • 1
  • 10
  • 4
    See [How to do integer & float calculations, in bash or other languages/frameworks?](https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks) – steeldriver Mar 03 '18 at 00:29

1 Answers1

1

Try this, using

#!/bin/bash
h=0
l=0
reads=0
divider=6
while read user_input; do
    ((reads++))
    ((user_input == 1 && h++))
    ((user_input == 2 && n++))
    ((user_input == 3 && h--))
    if ((reads%52 == 0 && divider > 1)); then
        ((divider--))
    fi
    echo "True Count $(bc <<< "scale=3; ($h+$l)/$divider") High cards $h/120 Null Cards $n/72 Low Cards $l/120"
done
Gilles Quénot
  • 31,569
  • 7
  • 64
  • 82