Advertisement
Go-Ice

Lab 2_Shell Script

Sep 23rd, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/sh
  2. # myshell.sh
  3.     echo "welcome to use $0"
  4.     echo "your target is $1"
  5.  
  6. Hello(){
  7.  
  8.     echo "welcome to the summoner's rift"
  9. }
  10. Hello;
  11.  
  12. ans=$1
  13. start=1
  14. end=10
  15. dex=1
  16.  
  17. while [ $dex -lt 10 ]; do
  18.     echo "Plese enter a number between $start and $end:"
  19.     read input
  20.    
  21.     if [ $input -gt $end ]; then
  22.         echo "wrong input!"
  23.     elif [ $input -gt $ans ]; then
  24.         end=`expr $input - 1`
  25.     elif [ $input -lt $ans ]; then
  26.         start=`expr $input + 1`
  27.     else
  28.         echo "BINGO!"
  29.         break
  30.     fi
  31.     dex=`expr $dex + 1`
  32. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement