Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

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 le exists.
-b file TRUE if le exists and is a block special le.
-c file TRUE if le exists and is a character special le.
-d file TRUE if le exists and is a directory.
-e file TRUE if le exists.
-f file TRUE if le exists and is a regular le.
-g file TRUE if le exists and its set-group ID bit is set.
-k file TRUE if le exists and its sticky bit is set.
-n string1 TRUE if the length of string1 is nonzero.
-p file TRUE if le exists and is a named pipe (FIFO).
-r file TRUE if le exists and has read permission.
-s file TRUE if le exists and has a size greater than 0 (zero).
-t [file_descriptor]
TRUE if the open le with le descriptor number le_descriptor (1 by default)
is associated with a terminal device.
-u file TRUE if le exists and its set-user ID bit is set.
-w file TRUE if le exists and has write permission.
-x file TRUE if le exists and has execute permission. If le 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.
910 Hewlett-Packard Company 527188-007