Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "Please input the data file that you want to use"
- read filename
- for number in $(cat $filename)
- do
- i=0
- while [ "$i" -lt 5 ]
- do
- echo "Guess the number"
- read curr
- if [ "$curr" == "Exit" ] || [ "$curr" == "exit" ]
- then
- exit 10
- fi
- if [ "$number" -eq "$curr" ]
- then
- echo "Yes you got it. We are moving on the next number"
- break;
- elif [ "$number" -lt "$curr" ]
- then
- echo "Your number is too high"
- elif [ "$number" -gt "$curr" ]
- then
- echo "Your number is too low"
- fi
- i=$(($i+1))
- done
- if [ "$i" -eq 5 ]
- then
- echo "Sorry you did not guess the number. We are moving to the next number"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement