Shell programming exercise: guess the number

Please use Shell programming to write a number guessing game, first generate a random number from 1 to 100, and then the user enters a number, telling the user that the number entered is greater than, less than or equal to the random number, until the user guesses right (the number is equal to the random number) ) To end the program.
Tips:
1) Use the read command to receive user input.
2) The random number can be obtained by directly accessing the built-in system variable RANDOM, and its value is a random number between 0 and 32767.

let a=RANDOM%100+1
x=0
while [ $x -ne $a ]
do
    echo Enter the number you guess:
    read x
done
echo Correct!

Guess you like

Origin blog.csdn.net/COFACTOR/article/details/115255915