Skip to content

Instantly share code, notes, and snippets.

@camkidman
Last active December 23, 2015 18:49
Show Gist options
  • Save camkidman/6678573 to your computer and use it in GitHub Desktop.
Save camkidman/6678573 to your computer and use it in GitHub Desktop.
#!/bin/bash
#guesssing game script
i=0
r=$[ ( $RANDOM % 100 ) + 1 ];
echo "Welcome to The Game of Guessing. Please enter a number between 1 and 100."
#Gather INPUT
read INPUT
#make iterations
#while loop for gathering info
while [[ $INPUT -ne $r ]]
do
i=$[i+1]
if [ $r -gt $INPUT ]
then echo "You're too low, guess again!"
read INPUT
elif [ $r -lt $INPUT ]
then echo "You're too high, guess again!"
read INPUT
elif [ $r -eq $INPUT ]
then echo "You're spot on, champ!"
fi
done
@camkidman
Copy link
Author

./guess.sh: line 20: =: command not found
You're too high, guess again!
20
./guess.sh: line 20: =: command not found
You're too low, guess again!
25
./guess.sh: line 20: =: command not found
You're too low, guess again!
30
./guess.sh: line 20: =: command not found
You're too low, guess again!
40
./guess.sh: line 20: =: command not found
You're too low, guess again!
45
./guess.sh: line 20: =: command not found
You're too high, guess again!
43
./guess.sh: line 20: =: command not found
You're too high, guess again!
42
./guess.sh: line 20: =: command not found
You're too high, guess again!
41
./guess.sh: line 20: =: command not found
You're spot on, champ!

./guess.sh: line 20: =: command not found
./guess.sh: line 21: [: 41: unary operator expected
./guess.sh: line 23: [: 41: unary operator expected
./guess.sh: line 25: [: 41: unary operator expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment