Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

test(1) OSS Shell and Utilities Reference Manual
NAME
test - Evaluates conditional expressions
SYNOPSIS
test e xpression
[ 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.
-h file TRUE if file exists and is a symbolic link. This function was used with previous
versions of this program. Use -L instead of -h.
-k file TRUE if file exists and its sticky bit is set.
-L file TRUE if file exists and is a symbolic link.
-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.
910 Hewlett-Packard Company 527188-021