validation not working in a case statement

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

validation not working in a case statement

hemantjsr
I’m writing a shell script which takes input from user and creates .csv file. In shell script I’m using case statement for taking input as well as validation.
In first case statement I’m taking mobile number and do the validation (e.g mobile no is 10 digits and start between 1 to 9. Same thing I’m doing 2nd and 3rd statement

case $mobile in  
     [1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) echo "Mobile = $mobile" ;; #1st case
         *) echo "INCORRECT Mob.. "
case $custtype in
     [1-3]) echo "customer type= $custtype";;                                                   #2nd case
         *) echo "customer typ=$custtype incorrect customer type"
case $date in
     [0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]) echo "You have entered =$date";;  #3rd case
     *) echo "DATE=$date is incorrect"
exit 255;;
esac

Please guide where I’m wrong. Because validation not working in 2nd and 3rd case statement.
Reply | Threaded
Open this post in threaded view
|

Re: validation not working in a case statement

Guru
Administrator
 There is an issue with the case syntax here:

case variable in
  opt1)....;;
  opt2)....;;
esac