1 .\" $NetBSD: test.1,v 1.30 2016/08/12 03:17:41 sevan Exp $
3 .\" Copyright (c) 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the Institute of Electrical and Electronics Engineers, Inc.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" @(#)test.1 8.1 (Berkeley) 5/31/93
41 .Nd condition evaluation utility
53 to true, returns a zero (true) exit status; otherwise
62 All operators and flags are separate arguments to the
66 The following primaries are used to construct
72 exists and is a block special
77 exists and is a character
82 exists and is a directory.
86 exists (regardless of type).
90 exists and is a regular file.
94 exists and its set group ID flag
99 exists and is a symbolic link.
103 exists and its sticky bit is set.
105 True if the length of
111 exists and is a named pipe
116 exists and is readable.
120 exists and has a size greater
122 .It Fl t Ar file_descriptor
123 True if the file whose file descriptor number
126 is open and is associated with a terminal.
130 exists and its set user ID flag
135 exists and is writable.
137 indicates only that the write flag is on.
138 The file is not writable on a read-only file
139 system even if this test indicates true.
143 exists and is executable.
145 indicates only that the execute flag is on.
148 is a directory, true indicates that
152 True if the length of
158 exists and is a symbolic link.
159 This operator is retained for compatibility with previous versions of
161 Do not rely on its existence; use
167 exists and its owner matches the effective user id of this process.
171 exists and its group matches the effective group id of this process.
175 exists and is a socket.
176 .It Ar file1 Fl nt Ar file2
179 exists and is newer than
181 .It Ar file1 Fl ot Ar file2
184 exists and is older than
186 .It Ar file1 Fl ef Ar file2
191 exist and refer to the same file.
197 .It Ar \&s\&1 Cm \&= Ar \&s\&2
203 .It Ar \&s\&1 Cm \&!= Ar \&s\&2
209 .It Ar \&s\&1 Cm \&\*[Lt] Ar \&s\&2
214 based on the ASCII value of their characters.
215 .It Ar \&s\&1 Cm \&\*[Gt] Ar \&s\&2
220 based on the ASCII value of their characters.
221 .It Ar \&n\&1 Fl \&eq Ar \&n\&2
228 .It Ar \&n\&1 Fl \&ne Ar \&n\&2
235 .It Ar \&n\&1 Fl \> Ar \&n\&2
239 greater than the integer
241 .It Ar \&n\&1 Fl \&ge Ar \&n\&2
245 greater than or equal to the integer
247 .It Ar \&n\&1 Fl \< Ar \&n\&2
250 is algebraically less
253 .It Ar \&n\&1 Fl \&le Ar \&n\&2
256 is algebraically less
257 than or equal to the integer
261 These primaries can be combined with the following operators:
263 .It Cm \&! Ar expression
267 .It Ar expression1 Fl a Ar expression2
273 .It Ar expression1 Fl o Ar expression2
279 .It Cm \&( Ar expression Cm \&)
287 operator has higher precedence than the
291 Note that all file tests with the exception of
295 follow symbolic links and thus evaluate the test for the file pointed at.
299 utility exits with one of the following values:
306 evaluated to false or was missing.
313 utility implements a superset of the
324 grammar is inherently ambiguous.
325 In order to assure a degree of consistency, the cases described in
328 are evaluated consistently according to the rules specified in the
330 All other cases are subject to the ambiguity in the command semantics.