Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "Please input the data file that you want to use"
  4.  
  5. read filename
  6. for number in $(cat $filename)
  7. do
  8.  
  9.     i=0
  10.     while [ "$i" -lt 5 ]
  11.     do
  12.         echo "Guess the number"
  13.         read  curr
  14.         if [ "$curr" == "Exit" ] || [ "$curr" == "exit" ]
  15.         then
  16.             exit 10
  17.         fi
  18.  
  19.         if [ "$number" -eq "$curr" ]
  20.         then
  21.             echo "Yes you got it. We are moving on the next number"
  22.             break;
  23.         elif [ "$number" -lt "$curr" ]
  24.         then
  25.             echo "Your number is too high"
  26.         elif [ "$number" -gt "$curr" ]
  27.         then
  28.             echo "Your number is too low"
  29.         fi
  30.         i=$(($i+1))
  31.     done
  32.     if [ "$i" -eq 5 ]
  33.     then
  34.         echo "Sorry you did not guess the number. We are moving to the next number"
  35.     fi
  36.  
  37. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement