List of 'if' switches anywhere?
Look at the bash manpage (man bash
). The options are specified in the CONDITIONAL EXPRESSIONS
section:
CONDITIONAL EXPRESSIONS
Conditional expressions are used by the [[ compound command and the
test and [ builtin commands to test file attributes and perform string
and arithmetic comparisons. Expressions are formed from the following
unary or binary primaries. If any file argument to one of the pri-
maries is of the form /dev/fd/n, then file descriptor n is checked. If
the file argument to one of the primaries is one of /dev/stdin,
/dev/stdout, or /dev/stderr, file descriptor 0, 1, or 2, respectively,
is checked.
Unless otherwise specified, primaries that operate on files follow sym-
bolic links and operate on the target of the link, rather than the link
itself.
-a file
True if file exists.
... more options ...
It is also explained in the help:
$ help [
[: [ arg... ]
This is a synonym for the "test" builtin, but the last
argument must be a literal `]', to match the opening `['.
Yes. These are called conditional expressions and these are used by the [[
compound command and the test
and [
builtin commands ([
is simply a synonym for test
).
Read section 6.4 Bash Conditional Expressions of the Bash Reference Manual, which contains a list of all these switches and their usage.
They are not switches for the if
statement, but for the test
command ([
is a synonym for the test
builtin). See help test
in bash for a complete list.