How to represent multiple conditions in a shell if statement?

I want to represent multiple conditions like this:

if [ ( $g -eq 1 -a "$c" = "123" ) -o ( $g -eq 2 -a "$c" = "456" ) ]   
then  
    echo abc;  
else  
    echo efg;   
fi  

but when I execute the script, it shows

syntax error at line 15: `[' unexpected,

where line 15 is the one showing if ….

What is wrong with this condition? I guess something is wrong with the ().

8 Answers
8

Leave a Comment