TEST(1) DOMAIN/IX SYS5 TEST(1)
NAME
test - condition evaluation command
USAGE
test expr
[ expr ]
DESCRIPTION
Test evaluates the expression expr and, if its value is
true, returns a zero (true) exit status. If the value is
not true, or if no expr arguments are specified, a non-zero
(false) exit status is returned.
EXPR STRUCTURE
The following primitives are used to construct expr:
-r file True if file exists and is readable.
-w file True if file exists and is writable.
-x file True if file exists and is executable.
-f file True if file exists and is a regular file.
-d file True if file exists and is a directory.
-l file True if file exists and is a soft link.
-c file True if file exists and is a character special
file.
-b file True if file exists and is a block special file.
-p file True if file exists and is a named pipe (FIFO).
-u file True if file exists and its set-user-ID bit is
set.
-g file True if file exists and its set-group-ID bit is
set.
-k file True if file exists and its sticky bit is set.
-s file True if file exists and it has a size greater than
zero.
-t [ fildes ]
True if the open file whose file descriptor number
is fildes (1 by default) is associated with a ter-
minal device.
Printed 12/4/86 TEST-1
TEST(1) DOMAIN/IX SYS5 TEST(1)
-z s1 True if the length of string s1 is zero.
-n s1 True if the length of the string s1 is non-zero.
s1 = s2 True if strings s1 and s2 are identical.
s1 != s2 True if strings s1 and s2 are not identical.
s1 True if s1 is not the null string.
n1 -eq n2 True if the integers n1 and n2 are algebraically
equal. Any of the comparisons -ne, -gt, -ge, -lt,
and -le may be used in place of -eq.
These primitives may be combined with the following opera-
tors:
! Unary negation operator.
-a Binary and operator.
-o Binary or operator (-a has higher precedence than
-o).
( expr ) Parentheses for grouping.
Notice that all the operators and flags are separate argu-
ments to test. Notice also that parentheses are meaningful
to the Shell and, therefore, must be escaped.
CAUTIONS
In the second form of the command, [ expr ], the square
brackets must be delimited by blanks. Although DOMAIN/IX
recognizes this form of the command, others may not.
RELATED INFORMATION
find(1), sh(1).
TEST-2 Printed 12/4/86