Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
test(1) OSS Shell and Utilities Reference Manual
NAME
test - Evaluates conditional expressions
SYNOPSIS
test expression
[ expression ]
DESCRIPTION
The test command evaluates an expression constructed of functions and operators. If the value
of expression is TRUE, test returns an exit value of 0 (zero); otherwise, it returns a value of 1
(FALSE). The test command also returns an exit value of 1 if there are no arguments.
The alternative form of the command surrounds expression with [](brackets). When you use
this form, you must surround the brackets with spaces.
The test Expressions
All of the listed functions and operators are separate arguments to test.
The following functions are used to construct expression:
-a file TRUE if file exists.
-b file TRUE if file exists and is a block special file.
-c file TRUE if file exists and is a character special file.
-d file TRUE if file exists and is a directory.
-e file TRUE if file exists.
-f file TRUE if file exists and is a regular file.
-g file TRUE if file exists and its set-group ID bit is set.
-k file TRUE if file exists and its sticky bit is set.
-n string1 TRUE if the length of string1 is nonzero.
-p file TRUE if file exists and is a named pipe (FIFO).
-r file TRUE if file exists and has read permission.
-s file TRUE if file exists and has a size greater than 0 (zero).
-t [file_descriptor]
TRUE if the open file with file descriptor number file_descriptor (1 by default)
is associated with a terminal device.
-u file TRUE if file exists and its set-user ID bit is set.
-w file TRUE if file exists and has write permission.
-x file TRUE if file exists and has execute permission. If file is a directory, TRUE
indicates that it can be searched.
-z string1 TRUE if the length of string1 is 0 (zero).
string1 = string2
TRUE if string1 and string2 are identical.
9−10 Hewlett-Packard Company 527188-003