A: Respond with Hint

   1 #!/bin/bash
   2 
   3 ## Starting message
   4 echo "Welcome to the Guessing Game."
   5 
   6 ## Initialize our variables
   7 number=$RANDOM
   8 guess=0
   9 
  10 ## Get the next guess
  11 echo "What is your guess?"
  12 read guess
  13 
  14 ## Respond with the hint
  15 echo -n "Your guess of $guess is "
  16 if [ $guess -eq $number ] ; then
  17     echo "corrent."
  18 elif [ $guess -lt $number ] ; then
  19     echo "too low."
  20 elif [ $guess -gt $number ] ; then
  21     echo "too high."
  22 fi

Scripting_Bash_Intro/210 A: Respond with Hint (last edited 2009-09-08 13:45:27 by MarkSuter)