What does '-a' do in Unix Shell scripting
What does -a
mean in the below line.
if [ "${FILE_SYSTE开发者_JAVA技巧M}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]
man test
EXPRESSION1 -a EXPRESSION2
both EXPRESSION1 and EXPRESSION2 are true
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
.
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.
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
精彩评论