-a test in shell script

I need clarification in -a test.

If say, in test -a left expression is not present but the right expression is present, do the shell will consider the left expression true and evaluate the right expression?

For example:

if [[ -a ${file} ]]
      then
      rm -f ${file}
fi

Is this test condition is true?

Help appreciated!! Thanks

cheers,
Devaraj Takhellambam

Thanks for fast response. But if omitted expression is always false then the test I have written is always remains false!! Which I supposed is not correct..

Youtr test condition is true.

If the file exists then the test will be executed

I am not sure what you are trying to achieve here. Read

cheers,
Devaraj Takhellambam

Your code is perfect , -a is used to check for the file existence and return true
if the file exists otherwise false.

Further to abubacker who is 100% correct.

The test within double square brackets [[...]] are evaluated according to the syntax for Conditional Expressions. This is described in the man pages for your shell. In that context the "-a" means "True if file exists".

Tests within single square brackets [..] are evaluated according to the rules for the "test" command. In that context "-a" means AND.

There is much overlap between the syntax for Conditional Expressions and "test" but they are not interchangeable.

Here is used -f = regular file exist. [[ -a maybe not work in all shells.
Maybe -e is better as -a ? What you are exactly testing ?

if test -f "$file" ; then
   some
fi
# is exactly same as
if  [   -f "$file" ] ; then
   some
fi
# and you can write it also
test -f $file && some

test and [ is same builtin command (usually). [ is command, not "bracket". But if you use command [ then last argument must be ] :).

Or use [[ (Conditional Expression).