Pattern for case

Hello Experts,

I need to create a case structure, wherein I must chk the input to match 2 values: PSDEV and PSSIT. I would like to do this using a single pattern.

I ve tried:

case
    PS['SIT''DEV'])
        echo "here"
        ;;
    *)
        echo "there"
        ;;
esac

Idk exactly how should I write the pattern to match. Should it be something like: PS[\(SIT\)\(DEV\)]

The basic requirement is to chk if the input is one of the valid values and perform something if it is one of them. Pls do tell me if there is a more efficient way to achieve this than "case"

Thank You.

Regards,
HKansal

I would keep it simple and just use:

  PSSIT | PSDEV )

another way - others may not like it:

#!/bin/ksh

pat='PS'
if [[ "${pat}" = @(PS(DEV|SIT)) ]]; then
   echo 'here'
else
   echo 'there'
fi

Hello,

Thanks for the help:)

For the time being I would use what Tony said.

Now this is what I like about this place, vgersh99 has given me a new thing to learn, ty.
@vgersh99: could you please explain the condition evaluated by if.. what is it that "pat" is actually being compared to?

Although I've got 1 solution but I am reluctant in marking the thread as solved as I still want to know the way I wanted to do it:). Just expecting more out of everything.

Thank You.

Regards,
HKansal

if you do 'man ksh' and search for 'File Name generation':

     A pattern-list is a list of one or more  patterns  separated
     from  each  other with a |. Composite patterns can be formed
     with one or more of the following:

     ?(pattern-list)
           Optionally matches any one of the given patterns.

     *(pattern-list)
           Matches zero or more occurrences  of  the  given  pat-
           terns.

     +(pattern-list)
           Matches one or more occurrences of the given patterns.

     @(pattern-list)
           Matches exactly one of the given patterns.

     !(pattern-list)
           Matches anything, except one of the given patterns.

Hello,

I have posted the final script under the initial thread :here:

Thank You.

Regards,
HKansal