What's Linux test -a command test for?
I am not sure why the info
page doesn't have it, but running help test
in bash
gives the answer:
...
File operators:
-a FILE True if file exists.
...
So it is simply an "existence" test, no other permissions/attributes checked.
If you're running test
or [
in bash
, it's actually probably the built-in version, and not the coreutils
version in /usr/bin
:
$ type test
test is a shell builtin
$ type [
[ is a shell builtin
That said, it does appear that the coreutils version implements both -a
and -e
, with exactly the same behavior. Maybe -a
is not reflected in the manpage because it's not standard, so maybe it was added later and that person neglected to update the manpage accordingly. But I can't say I know the history behind why it was added (or even what the a
is supposed to be short for).