LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   CASE statement (https://www.linuxquestions.org/questions/linux-newbie-8/case-statement-4175411269/)

oracledb0101 06-13-2012 02:17 PM

CASE statement
 
Code:

case $GROUP_NAME in
        "HR" )
                echo "Primary"  >> $log
        ;;
        "ERP")
                if  $DEPT="ACCOUNTING";  then
                        echo "Secondary" >> $log
              else
              echo "The EXCEPTION DOES NOT WORK" >> $log
                fi
                ;;
        *)
esac

Above is my CASE statement and the exception doesn't see to work if $DEPT is something else rather than "ACCOUNTING", it seems it's on process the "IF" statement even $DEPT is not even in "ACCOUNTING"

Thanks

Ser Olmy 06-13-2012 02:58 PM

The syntax of your if expression is wrong. Try:
Code:

if  [ "$DEPT" == "ACCOUNTING" ];  then

oracledb0101 06-13-2012 03:13 PM

thanks

Ser Olmy 06-13-2012 03:15 PM

Huh? If DEPT is not a variable, then what is it?

It doesn't make much sense to compare the text string "DEPT" to the text string "ACCOUNTING".


All times are GMT -5. The time now is 08:13 PM.