option in if statement

does anyone know what the -a in an if statement is referring to

ex...

if [ ! -a "$INLOG" ]

man "test" will tell you. It tests whether the file in $INLOG variable exists.

that's what I figured. I'm trying to rationalize this syntax...

if [ not and file ] then....

I'm not comprehending the logic here, it's checking for ! (not) what. and checking for file. So where does it say to check the pwd for that file name. What value does ! by itself give back.

It reads "if file does not exist"

a) -a $INLOG returns false
b) ! false is true

Therefore the test succeeds when the file does not exist.

Fun If Fact

My "man test" does not have a "-a" option, but that may depend on my OS. The "man test" on my system says you can test this (and much more):

-e file exists
! -e file doesn't exist
-s file exists and has a size greater than zero
! -s file doesn't exist and/or has a size of zero

You can test many, many situations and this is very handy.

Sometimes you would like to know if a file exists, like so: if [ -e filename ] or if a file does not exist, like so: if [ ! -e filename ].
You could write an if-statement to check if a file exists and give an error if it doesn't, like so:

if [ -e filename ]; then
echo "It's here and I don't want to do anything, because I only want to know if it's NOT here"
else
echo "File's not here!"
fi

But checking for the "not-existance" is sometimes much more efficient, because you might not care about the other situation:

if [ ! -e filename ]; then
echo "ERROR! File's not here!"
fi

It all depends on the function of your if-statement.

Yes, it does depend on your system. My Solaris system shows -a, my AIX does not but it works in both systems.

Yes - and to confuse matters -a can also be used as a binary and operator, e.g.

if [ -a "${myfile}" -a -z "${somestring}" ]; then
...
fi

Take a peek at the Solaris 8 manual page...

Cheers
ZB