views:

75

answers:

2

Can anyone tell me what -a means in unix. Please see the following code:

if [ "$x"  = "$x" -a "y" -eq 0 ]  ; then
echo $x
else 
echo $y 
+8  A: 

it means "and". -o is "or".

From man bash

expr1 -a expr2
                     True if both expr1 and expr2 are true.
Personman
+3  A: 

Quoting 4.1 Bourne Shell Builtins (i.e. the manual, online, with anchors) :

test
[
    Evaluate a conditional expression expr. Each operator and operand must be a separate argument.
    Expressions are composed of the primaries described below in Bash Conditional Expressions.
    test does not accept any options, nor does it accept and ignore an argument of -- as signifying the end of options.
...
expr1 -a expr2
    True if both expr1 and expr2 are true.

Pascal MARTIN