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.
ifs but onefiis a good place to start debugging.ifvselifissue and spacing in the test commands,$(($RANDOM % (2 - 1)))will always expand to "0" (because 2-1 is 1, and anything%1 is 0).