SHARE
TWEET

http://redd.it/pii6j

a guest Feb 10th, 2012 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. min=0 max=100
  4.  
  5. while true; do
  6.     guess=$((RANDOM%(max-min+1)+min))
  7.     echo Is your number $guess?
  8.     select choice in Yes Lower Higher; do
  9.         case $choice in
  10.         Yes)
  11.             echo Your number is $guess
  12.             exit 0;;
  13.         Lower)
  14.             max=$guess;;
  15.         Higher)
  16.             min=$guess;;
  17.         esac
  18.         break
  19.     done
  20. done
RAW Paste Data
Want to get better at Bash?
Learn to code Bash in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top