kk.
kk.

Reputation: 687

What does '-a' do in Unix Shell scripting

What does -a mean in the below line.

if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]

Upvotes: 2

Views: 692

Answers (4)

glenn jackman
glenn jackman

Reputation: 246992

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

Upvotes: 1

codaddict
codaddict

Reputation: 455192

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.

Upvotes: 5

ghostdog74
ghostdog74

Reputation: 342591

man test

 EXPRESSION1 -a EXPRESSION2
              both EXPRESSION1 and EXPRESSION2 are true

Upvotes: 5

Explosion Pills
Explosion Pills

Reputation: 191769

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.

Upvotes: 2

Related Questions