What does -a
mean in the below line.
if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]
What does -a
mean in the below line.
if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]
In shell script test (open brace) it means "and," so if the file system var does not equal xyz AND does not equal abc, the test succeeds.
It means logical and operator.
If both the operands are true then condition would be true otherwise it would be false.
In your case the condition in the if
will be true when variable $FILE_SYSTEM
is not xyz
and is not abc
.
man test
EXPRESSION1 -a EXPRESSION2
both EXPRESSION1 and EXPRESSION2 are true
An equivalent to
if [ "$x" != "a" -a "$x" != "b" ]; then
do_one_thing
else
do_other_thing
fi
is
case "$x" in
a|b) do_other_thing ;;
*) do_one_thing ;;
esac