Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. CheckCorrection()
  4. {
  5.   rm input.txt
  6.   if [ $2 = "mobile" ]
  7.   then
  8.     echo $1>>input.txt
  9.     if [ $(grep -ci -rv [a-z] input.txt) = 1 ]
  10.     then
  11.      result="correct"
  12.      else
  13.      result="incorrect.please repeat"
  14.     fi
  15.   fi
  16.  
  17.   if [ $2 = "email" ]
  18.   then
  19.     echo $1>>input.txt
  20.     if [ $(grep -ci -rv '/\A[^@]+@([^@\.]+\.)+[^@\.]+\z/' input.txt) = 1 ]
  21.     then
  22.      result="correct"
  23.      else
  24.      result="incorrect.please repeat"
  25.     fi
  26. fi
  27. }
  28.  
  29. echo "Введите $4 :"
  30. read value
  31. CheckCorrection $value $2
  32. while [ "$result" != "correct" ]
  33. do
  34. echo $result
  35. read value
  36. CheckCorrection $value $2
  37. done
  38. echo "Success"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement