The following primitives are used to construct expr .
"\w'n1 \fL-eq n2\fLXX'u" -r " file" True if the file exists (is accessible) and is readable.
0
-w " file" True if the file exists and is writable.
-x " file" True if the file exists and has execute permission.
-e " file True if the file exists.
-f " file" True if the file exists and is a plain file.
-d " file" True if the file exists and is a directory.
-s " file" True if the file exists and has a size greater than zero.
-t " fildes True if the open file whose file descriptor number is fildes (1 by default) is the same file as /dev/cons .
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.)
-n " s1" True if the length of string s1 is non-zero.
-z " s1" True if the length of string s1 is zero.
n1 " -eq " n2 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 -l " string\f1, meaning the length of string , may be used in place of an integer.
These primaries may be combined with the following operators:
"\w'\fL( expr\fL )XX'u" ! unary negation operator
0
-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.
A better way is
.EX if (~ $1 -c) echo OKTest whether .L abc is in the current directory.
test -f abc -o -d abc