.\" .\" Sccsid @(#)test.1b 1.1 (gritter) 7/2/05 .\" Derived from test(1), Unix 7th edition: .\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" Redistributions of source code and documentation must retain the .\" above copyright notice, this list of conditions and the following .\" disclaimer. .\" Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed or owned by Caldera .\" International, Inc. .\" Neither the name of Caldera International, Inc. nor the names of .\" other contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE .\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH TEST 1B "7/2/05" "Heirloom Toolchest" "BSD System Compatibility" .SH NAME test \- (BSD) condition command .SH SYNOPSIS \fB/usr/ucb/test\fR [\fIexpr\fP] .SH DESCRIPTION .I test evaluates the expression .IR expr , and if its value is true then returns zero exit status; otherwise, a non zero exit status is returned. .I test returns a non zero exit if there are no arguments. .PP The following primitives are used to construct .IR expr : .TP 12n .BR \-r " file" true if the file exists and is readable. .TP .BR \-w " file" true if the file exists and is writable. .TP .BR \-u " file" true if the file exists and has the setuid bit set. .TP .BR \-g " file" true if the file exists and has the setgid bit set. .TP .BR \-k " file" true if the file exists and has the sticky bit set. .TP .BR \-f " file" true if the file exists and is not a directory. .TP .BR \-d " file" true if the file exists and is a directory. .TP .BR \-h " file" true if the file exists and is a symbolic link. .TP .BR \-L " file" true if the file exists and is a symbolic link. .TP .BR \-p " file" true if the file exists and is a named pipe. .TP .BR \-b " file" true if the file exists and is a block device. .TP .BR \-c " file" true if the file exists and is a character device. .TP .BR \-s " file" true if the file exists and has a size greater than zero. .TP .BR \-t " [fildes]" true if the open file whose file descriptor number is .I fildes (1 by default) is associated with a terminal device. .TP .BR \-z " s1" true if the length of string .I s1 is zero. .TP .BR \-n " s1" true if the length of the string .I s1 is nonzero. .TP .RB s1 " = " s2 true if the strings .I s1 and .I s2 are equal. .TP .RB s1 " != " s2 true if the strings .I s1 and .I s2 are not equal. .TP s1 true if .I s1 is not the null string. .TP .RB 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 , or .BR \-le may be used in place of .BR \-eq . .PP These primaries may be combined with the following operators: .TP 12n .B ! unary negation operator .TP .B \-a binary .I and operator .TP .B \-o binary .I or operator .TP .TP .BR "( " "expr" " )" parentheses for grouping. .PP .B \-a has higher precedence than .B \-o. Notice that all the operators and flags are separate arguments to .IR test . Notice also that parentheses are meaningful as command separators and must be escaped.