A: Repeat until the game is won
1
2
3
4 echo "Welcome to the Guessing Game."
5
6
7 number=$RANDOM
8 guess=0
9
10
11 while [ $guess -ne $number ] ; do
12
13
14 echo "What is your guess?"
15 read guess
16
17
18 echo -n "Your guess of $guess is "
19 if [ $guess -eq $number ] ; then
20 echo "corrent."
21 elif [ $guess -lt $number ] ; then
22 echo "too low."
23 elif [ $guess -gt $number ] ; then
24 echo "too high."
25 fi
26
27 done
Scripting_Bash_Intro/212 A: Repeat until the game is won (last edited 2009-09-08 13:49:28 by MarkSuter)