shell random number comparison

. 1 #! / Bin / the bash
 2 A = $ (expr $ the RANDOM% 100 ) # generates random numbers one to one hundred of
 . 3  echo $ A # print random number
 . 4 B = 0 
. 5  the while  to true 
. 6  do 
. 7          the let B ++
 . 8          echo " ! $ b comparison of the times " 
. 9          Read -p " Please enter the number of a random number 1-100: " NUM
 10          IF [$ NUM -gt 100 ]; the then
 . 11                  echo " input error, please re-enter!! " 
12 is                  Continue 
13          elif [$ NUM -le100 ]; the then
 14                  IF [$ NUM - lt $ A]; the then
 15                          echo " Sorry, small " 
16                  elif [$ NUM - gt $ A]; the then
 . 17                          echo " Sorry, big " 
18 is                  elif [$ NUM - A $ EQ]; the then
 . 19                          echo " Congratulations, equal to the number of two, the award-winning " 
20 is                          BREAK 
21 is                  Fi
 22 is          Fi
 23 is DONE

 

Guess you like

Origin www.cnblogs.com/Zrecret/p/11961594.html