Shell script to write a simple price guessing game
[root@localhost ~] # vim game.shemeal RANDOM is an environment variable and randomly outputs a number between 0,32767 each time. Echo "the price of this commodity is between (0-999) yuan, guess the specific price?" While truedolet count++read-p "Please enter the specific price you guessed, and press enter to confirm:" bif [$b-eq $a] then echo "Congratulations, correct answer, the actual price of the goods is ${b}!" Echo "you guessed a total of ${count}!" Exit 0elif [$b-gt $a] then echo "too high!" Else echo "too low!" Fidone save exit, play! [root@localhost] #. The price of game.sh is between (0-999) yuan. Guess the specific price? Please enter the specific price you guessed and press enter to confirm: 500 is too low! Please enter the specific price you guessed and press enter to confirm: 600 is too high! Please enter the specific price you guessed and press enter to confirm: 550 is too low! Please enter the specific price you guessed and press enter to confirm: 570 is too high! Please enter the specific price you guessed and press enter to confirm: 560 is too low! Please enter the specific price you guessed and press enter to confirm: 565 is too low! Please enter the specific price you guessed and press enter to confirm: 566 is too low! Please enter the specific price you guessed and press enter to confirm: 568 Congratulations, correct answer, the actual price of the goods is 568! You guessed a total of 8 times!