1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man1b / test.1b
blob8e474073fd719fcafd65bce93990d0c2bdbe2b5a
1 '\" te
2 .\"  Copyright (c) 1996 Sun Microsystems, Inc - All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH TEST 1B "Apr 1, 1996"
7 .SH NAME
8 test \- condition evaluation command
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fB/usr/ucb/test\fR \fIexpression\fR
13 .fi
15 .LP
16 .nf
17  \fIexpression\fR
18 .fi
20 .SH DESCRIPTION
21 .sp
22 .LP
23 \fBtest\fR evaluates the expression \fIexpression\fR and, if its value is true,
24 sets  \fB0\fR (true) exit status; otherwise, a non-zero (false) exit status is
25 set. \fBtest\fR also sets a non-zero exit status if there are no arguments.
26 When permissions are tested, the effective user \fBID\fR of the process is
27 used.
28 .sp
29 .LP
30 All operators, flags, and brackets (brackets used as shown in the second
31 \fBSYNOPSIS\fR line) must be separate arguments to the \fBtest\fR command;
32 normally these items are separated by spaces.
33 .SH USAGE
34 .SS "Primitives"
35 .sp
36 .LP
37 The following primitives are used to construct \fIexpression\fR:
38 .sp
39 .ne 2
40 .na
41 \fB\fB-r\fR \fIfilename\fR\fR
42 .ad
43 .RS 16n
44 True if \fIfilename\fR exists and is readable.
45 .RE
47 .sp
48 .ne 2
49 .na
50 \fB\fB-w\fR \fIfilename\fR\fR
51 .ad
52 .RS 16n
53 True if \fIfilename\fR exists and is writable.
54 .RE
56 .sp
57 .ne 2
58 .na
59 \fB\fB-x\fR \fIfilename\fR\fR
60 .ad
61 .RS 16n
62 True if \fIfilename\fR exists and is executable.
63 .RE
65 .sp
66 .ne 2
67 .na
68 \fB\fB-f\fR \fIfilename\fR\fR
69 .ad
70 .RS 16n
71 True if \fIfilename\fR exists and is a regular file. Alternatively, if
72 \fB/usr/bin/sh\fR users specify \fB/usr/ucb\fR before \fB/usr/bin\fR in their
73 \fBPATH\fR environment variable, then \fBtest\fR will return true if
74 \fIfilename\fR exists and is (\fBnot\(mia\(midirectory\fR). This is also the
75 default for \fB/usr/bin/csh\fR users.
76 .RE
78 .sp
79 .ne 2
80 .na
81 \fB\fB-d\fR \fIfilename\fR\fR
82 .ad
83 .RS 16n
84 True if \fIfilename\fR exists and is a directory.
85 .RE
87 .sp
88 .ne 2
89 .na
90 \fB\fB-c\fR \fIfilename\fR\fR
91 .ad
92 .RS 16n
93 True if \fIfilename\fR exists and is a character special file.
94 .RE
96 .sp
97 .ne 2
98 .na
99 \fB\fB-b\fR \fIfilename\fR\fR
101 .RS 16n
102 True if \fIfilename\fR exists and is a block special file.
106 .ne 2
108 \fB\fB-p\fR \fIfilename\fR\fR
110 .RS 16n
111 True if \fIfilename\fR exists and is a named pipe (fifo).
115 .ne 2
117 \fB\fB-u\fR \fIfilename\fR\fR
119 .RS 16n
120 True if \fIfilename\fR exists and its set-user- \fBID\fR bit is set.
124 .ne 2
126 \fB\fB-g\fR \fIfilename\fR\fR
128 .RS 16n
129 True if \fIfilename\fR exists and its set-group- \fBID\fR bit is set.
133 .ne 2
135 \fB\fB-k\fR \fIfilename\fR\fR
137 .RS 16n
138 True if \fIfilename\fR exists and its sticky bit is set.
142 .ne 2
144 \fB\fB-s\fR \fIfilename\fR\fR
146 .RS 16n
147 True if \fIfilename\fR exists and has a size greater than zero.
151 .ne 2
153 \fB\fB-t\fR[ \fIfildes\fR ]\fR
155 .RS 16n
156 True if the open file whose file descriptor number is \fIfildes\fR (1 by
157 default) is associated with a terminal device.
161 .ne 2
163 \fB\fB-z\fR \fIs1\fR\fR
165 .RS 16n
166 True if the length of string \fIs1\fR is zero.
170 .ne 2
172 \fB\fB-n\fR \fIs1\fR\fR
174 .RS 16n
175 True if the length of the string \fIs1\fR is non-zero.
179 .ne 2
181 \fB\fIs1\fR\fB = \fR\fIs2\fR\fR
183 .RS 16n
184 True if strings \fIs1\fR and \fIs2\fR are identical.
188 .ne 2
190 \fB\fIs1\fR\fB != \fR\fIs2\fR\fR
192 .RS 16n
193 True if strings \fIs1\fR and \fIs2\fR are \fInot\fR identical.
197 .ne 2
199 \fB\fIs1\fR\fR
201 .RS 16n
202 True if \fIs1\fR is \fInot\fR the null string.
206 .ne 2
208 \fB\fIn1\fR\fB \(mieq \fR\fIn2\fR\fR
210 .RS 16n
211 True if the integers \fIn1\fR and \fIn2\fR are algebraically equal. Any of the
212 comparisons \fB\(mine\fR, \fB\(migt\fR, \fB\(mige\fR, \fB\(milt\fR, and
213 \fB\(mile\fR may be used in place of \fB\(mieq\fR\&.
216 .SS "Operators"
219 These primaries may be combined with the following operators:
221 .ne 2
223 \fB\fB!\fR\fR
225 .RS 16n
226 Unary negation operator.
230 .ne 2
232 \fB\fB-a\fR\fR
234 .RS 16n
235 Binary \fIand\fR operator.
239 .ne 2
241 \fB\fB-o\fR\fR
243 .RS 16n
244 Binary \fIor\fR operator (\fB-a\fR has higher precedence than \fB-o\fR).
248 .ne 2
250 \fB(\fIexpression\fR)\fR
252 .RS 16n
253 Parentheses for grouping. Notice also that parentheses are meaningful to the
254 shell and, therefore, must be quoted.
257 .SH SEE ALSO
260 \fBfind\fR(1), \fBsh\fR(1), \fBattributes\fR(5)
261 .SH NOTES
264 The \fBnot\(mia\(midirectory\fR alternative to the \fB-f\fR option is a
265 transition aid for \fBBSD\fR applications and may not be supported in future
266 releases.
269 If you test a file you own (the \fB-r\fR \fB,\fR \fB-w\fR \fB,\fR or \fB-x\fR
270 tests), but the permission tested does not have the \fIowner\fR bit set, a
271 non-zero (false) exit status will be returned even though the file may have the
272 \fIgroup\fR or \fIother\fR bit set for that permission. The correct exit status
273 will be set if you are super-user.
276 The \fB=\fR and \fB!=\fR operators have a higher precedence than the \fB-r\fR
277 through \fB-n\fR operators, and \fB=\fR and \fB!=\fR always expect arguments;
278 therefore, \fB=\fR and \fB!=\fR cannot be used with the \fB-r\fR through
279 \fB-n\fR operators.
282 If more than one argument follows the \fB-r\fR through \fB-n\fR operators, only
283 the first argument is examined; the others are ignored, unless a \fB-a\fR or a
284 \fB-o\fR is the second argument.