SysIII/usr/src/man/man1/test.1

Compare this file to the similar file:
Show the results in this format:

.TH TEST 1
.SH NAME
test \- condition evaluation command
.SH SYNOPSIS
.B test
expr
.br
.B [
expr
.B ]
.SH DESCRIPTION
.I Test\^
evaluates the expression
.I expr\^
and, if its value is true, returns a zero (true) exit status; otherwise, a
non-zero (false) exit status is returned;
.I test\^
also
returns a non-zero exit status if there are no arguments.
The following primitives are used to construct
.IR expr :
.TP 12
.BI \-r " file\^"
true if \fIfile\fR exists and is readable.
.TP
.BI \-w " file\^"
true if \fIfile\fR exists and is writable.
.TP
.BI \-x " file\^"
true if
.I file\^
exists and is executable.
.TP
.BI \-f " file\^"
true if \fIfile\fR exists and is a regular file.
.TP
.BI \-d " file\^"
true if \fIfile\fR exists and is a directory.
.TP
.BI \-c " file\^"
true
if
.I file\^
exists and is a character special file.
.TP
.BI \-b " file\^"
true if
.I file\^
exists and is a block special file.
.TP
.BI \-u " file\^"
true if
.I file\^
exists and its set-user-\c
.SM ID
bit is set.
.TP
.BI \-g " file\^"
true if
.I file\^
exists and its set-group-\c
.SM ID
bit is set.
.TP
.BI \-k " file\^"
true if
.I file\^
exists and its sticky bit is set.
.TP
.BI \-s " file\^"
true if \fIfile\fR exists and has a size greater than zero.
.TP
.BR \-t " [ \fIfildes\fR ]"
true if the open file whose file descriptor number is
.I fildes\^
(1 by default)
is associated with a terminal device.
.TP
.BI \-z " s1\^"
true if the length of string
.I s1\^
is zero.
.TP
.BI \-n " s1\^"
true if the length of the string
.I s1\^
is non-zero.
.TP
.IB s1 " = " s2\^
true
if strings
.I s1\^
and
.I s2\^
are identical.
.TP
.IB s1 " != " s2\^
true
if strings
.I s1\^
and
.I s2\^
are
.I not\^
identical.
.TP
.I s1\^
true if
.I s1\^
is
.I not\^
the null string.
.TP
.IB n1 " \-eq " n2\^
true if the integers
.I n1\^
and
.I n2\^
are algebraically equal.
Any of the comparisons
.BR \-ne ,
.BR \-gt ,
.BR \-ge ,
.BR \-lt ,
and
.BR \-le
may be used in place of
.BR \-eq .
.PP
These primaries may be combined with the
following operators:
.TP  12
.B  !
unary negation operator.
.TP
.B  \-a
binary
.I and\^
operator.
.TP
.B  \-o
binary
.I or\^
operator
.RB ( \-a
has higher precedence than
.BR \-o ).
.TP
.BR "(\| " "expr" " \|)"
parentheses for grouping.
.PP
Notice that all the operators and flags are separate
arguments to
.IR test .
Notice also that parentheses are meaningful
to the shell and, therefore, must be escaped.
.SH "SEE ALSO"
find(1), sh(1).
.SH WARNING
In the second form of the command (i.e., the one that uses
.BR [\|] ,
rather than the word
.IR test ),
the square brackets must be delimited by blanks.