Last active
December 23, 2015 18:49
-
-
Save camkidman/6678573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./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