#!/bin/bash RANGE=10 rand=$(($RANDOM%$RANGE)) thisFlag=1 tries=1 while [ $thisFlag -eq 1 ] do echo "Guess a number between zero and ten " read num if [ $num -eq $rand ]; then echo "Got it!" thisFlag=0 else if [ $tries -gt 3 ]; then echo "The number is $rand" thisFlag=0 else echo "Sorry. Try again" fi fi tries=$(($tries+1)) done