add .Vx so tmac.andoc will call tmac.mdoc-old
[unix-history] / usr / src / bin / test / test.1
CommitLineData
daacd5f0 1.\" @(#)test.1 6.3 (Berkeley) %G%
301e682c 2.\"
8a6fda3c 3.TH TEST 1 ""
301e682c
KM
4.AT 3
5.SH NAME
6test \- condition command
7.SH SYNOPSIS
8.B test
9expr
10.SH DESCRIPTION
11.I test
12evaluates the expression
13.IR expr ,
14and if its value is true then returns zero exit status; otherwise, a
15non zero exit status is returned.
16.I test
17returns a non zero exit if there are no arguments.
18.PP
19The following primitives are used to construct
20.IR expr .
21.TP 9n
22.BR \-r " file"
23true if the file exists and is readable.
24.TP
25.BR \-w " file"
26true if the file exists and is writable.
27.TP
28.BR \-f " file"
29true if the file exists and is not a directory.
30.TP
31.BR \-d " file"
3d0acf53 32true if the file exists and is a directory.
301e682c
KM
33.TP
34.BR \-s " file"
35true if the file exists and has a size greater than zero.
36.TP
37.BR \-t " [ fildes ]"
38true if the open file whose file descriptor number is
39.I fildes
40(1 by default)
41is associated with a terminal device.
42.TP
43.BR \-z " s1"
44true if the length of string
45.I s1
46is zero.
47.TP
48.BR \-n " s1"
49true if the length of the string
50.I s1
51is nonzero.
52.TP
53.RB s1 " = " s2
54true
55if the strings
56.I s1
57and
58.I s2
59are equal.
60.TP
61.RB s1 " != " s2
62true
63if the strings
64.I s1
65and
66.I s2
67are not equal.
68.TP
69s1
70true if
71.I s1
72is not the null string.
73.TP
74.RB n1 " \-eq " n2
75true if the integers
76.I n1
77and
78.I n2
79are algebraically equal.
80Any of the comparisons
81.BR \-ne ,
82.BR \-gt ,
83.BR \-ge ,
84.BR \-lt ,
85or
86.BR \-le
87may be used in place of
88.BR \-eq .
89.PP
90These primaries may be combined with the
91following operators:
92.TP
93.B !
94unary negation operator
95.TP
96.B \-a
97binary
98.I and
99operator
100.TP
101.B \-o
102binary
103.I or
104operator
105.TP
106.BR "( " "expr" " )"
107parentheses for grouping.
108.PP
109.B \-a
110has higher precedence than
111.B \-o.
112Notice that all the operators and flags are separate
113arguments to
114.IR test .
115Notice also that parentheses are meaningful
116to the Shell and must be escaped.
117.SH "SEE ALSO"
118sh(1), find(1)