Reputation: 145
The program is meant to create a random number and check if it is lesser than, greater than or equal to the number that the user inputs while the count is less than 3.
#!/bin/sh
ranNum=$(($RANDOM % (2 - 1)))
ranNum=$((1 + $ranNum))
c=1
echo "The entity with the greatest number wins"
while [ $c -lt 3 ]
do
echo "Enter a number"
read usrIn
if ["$usrIn" -gt "$ranNum"]
then
echo "You won"
((c++))
if ["$usrIn" -lt "$ranNum"]
then
echo "You lost"
((c++))
else
echo "Its a tie"
((c++))
break
fi
done
When I run the code in the shell I get 2 errors returned:
line 24: syntax error near unexpected token done'
line 24:
done'
I'm not sure what's wrong with the syntax of my code or where to go from here.
Upvotes: 1
Views: 78