Quick question regarding if statement

Hi,
I'm trying to write an if statement that will check the USER parm against some text but I'm not quite sure how to use the or switch in the statement.. Can anyone help me out?...

If someone could also let me know when to use ( or [ in the statement.. Can never figure that out...

if (( $USER != "user1" || "user2" || "user3" || "user4" ))
then
  print ""
  print "Incorrect username passed in"
  print ""
  print  "Please check the spelling of $USER..."
  print ""
  exit 1
fi

Thanks,
Jaz

I think it's an AND you need, not an OR?

if [ "$USER" != "user1" -a "$USER" != "user2" -a "$USER" != "user3" -a ... ]

Alternatively, you can use a case statement:

case "$USER" in
 user1|user2|user3|...)  echo "do something";;
 *) echo "do something else"
esac

I never see any reason to use ( over [

Which shell? What are the exact patterns you're checking against?

Sorry, using ksh...

I'm just passing in a parm (ie a username) through command line at the minute.. Trying to test this out first...

Wasn't sure if ( and [ had different results.. Whats the logic behind using double [[ or ((?

All (, ((, [ and [[ have different meanings. You'll find their descriptions in your shell man pages.
I suppose you're looking for the case construct (see scottn's post above).

Thanks for your help guys..

if [ "$USER" != "user1" -a "$USER" != "user2" -a "$USER" != "user3" -a ... ] 

works fine..

I wanted the script to exit out if none of the users were matched..

use if-else-fi

else 
  exit

Or update from scottn's code:

case "$USER" in
 user1|user2|user3|...)  echo "do something";;
 *) exit;;
esac