TEST(1B) | BSD Compatibility Package Commands | TEST(1B) |
test - condition evaluation command
/usr/ucb/test expression
expression
test evaluates the expression expression and, if its value is true, sets 0 (true) exit status; otherwise, a non-zero (false) exit status is set. test also sets a non-zero exit status if there are no arguments. When permissions are tested, the effective user ID of the process is used.
All operators, flags, and brackets (brackets used as shown in the second SYNOPSIS line) must be separate arguments to the test command; normally these items are separated by spaces.
The following primitives are used to construct expression:
-r filename
-w filename
-x filename
-f filename
-d filename
-c filename
-b filename
-p filename
-u filename
-g filename
-k filename
-s filename
-t[ fildes ]
-z s1
-n s1
s1 = s2
s1 != s2
s1
n1 −eq n2
These primaries may be combined with the following operators:
!
-a
-o
(expression)
The not−a−directory alternative to the -f option is a transition aid for BSD applications and may not be supported in future releases.
If you test a file you own (the -r , -w , or -x tests), but the permission tested does not have the owner bit set, a non-zero (false) exit status will be returned even though the file may have the group or other bit set for that permission. The correct exit status will be set if you are super-user.
The = and != operators have a higher precedence than the -r through -n operators, and = and != always expect arguments; therefore, = and != cannot be used with the -r through -n operators.
If more than one argument follows the -r through -n operators, only the first argument is examined; the others are ignored, unless a -a or a -o is the second argument.
April 1, 1996 | OmniOS |