Test evaluates the expression expr. If the value is true the exit status is null; otherwise the exit
status is non-null. If there are no arguments the exit status is non-null.
The following primitives are used to construct expr.
-rfile True if the file exists (is accessible) and is readable.
-wfile True if the file exists and is writable.
-xfile True if the file exists and has execute permission.
-efile True if the file exists.
-ffile True if the file exists and is a plain file.
-dfile True if the file exists and is a directory.
-sfile True if the file exists and has a size greater than zero.
-tfildes True if the open file whose file descriptor number is fildes (1 by default) is the same file
as /dev/cons.
-Afile True if the file exists and is append-only.
-Lfile True if the file exists and is exclusive-use.
-Tfile True if the file exists and is temporary.
s1=s2 True if the strings s1 and s2 are identical.
s1!=s2 True if the strings s1 and s2 are not identical.
s1 True if s1 is not the null string. (Deprecated.)
-ns1 True if the length of string s1 is non-zero.
-zs1 True if the length of string s1 is zero.
n1-eqn2 True if the integers n1 and n2 are arithmetically equal. Any of the comparisons -ne, -gt,
-ge, -lt, or -le may be used in place of -eq. The (nonstandard) construct -lstring, meaning
the length of string, may be used in place of an integer.
a-ntb True if file a is newer than (modified after) file b.
a-otb True if file a is older than (modified before) file b.
f-oldert True if file f is older than (modified before) time t. If t is a integer followed by the
letters y(years), M(months), d(days), h(hours), m(minutes), or s(seconds), it represents
current time minus the specified time. If there is no letter, it represents seconds since
epoch. You can also concatenate mixed units. For example, 3d12h means three days and twelve
hours ago.
These primaries may be combined with the following operators:
! unary negation operator
-o binary or operator
-a binary and operator; higher precedence than -o(expr) parentheses for grouping.
The primitives -b, -u, -g, and -s return false; they are recognized for compatibility with POSIX.
Notice that all the operators and flags are separate arguments to test. Notice also that parentheses and
equal signs are meaningful to rc and must be enclosed in quotes.