BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / test.0
TEST(1) UNIX Programmer's Manual TEST(1)
N\bNA\bAM\bME\bE
test - condition command
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
t\bte\bes\bst\bt expr
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
_\bt_\be_\bs_\bt evaluates the expression _\be_\bx_\bp_\br, and if its value is true
then returns zero exit status; otherwise, a non zero exit
status is returned. _\bt_\be_\bs_\bt returns a non zero exit if there
are no arguments.
The following primitives are used to construct _\be_\bx_\bp_\br.
-\b-r\br file true if the file exists and is readable.
-\b-w\bw file true if the file exists and is writable.
-\b-f\bf file true if the file exists and is not a directory.
-\b-d\bd file true if the file exists and is a directory.
-\b-s\bs file true if the file exists and has a size greater than
zero.
-\b-t\bt [ fildes ]
true if the open file whose file descriptor number
is _\bf_\bi_\bl_\bd_\be_\bs (1 by default) is associated with a ter-
minal device.
-\b-z\bz s1 true if the length of string _\bs_\b1 is zero.
-\b-n\bn s1 true if the length of the string _\bs_\b1 is nonzero.
s1 =\b= s2 true if the strings _\bs_\b1 and _\bs_\b2 are equal.
s1 !\b!=\b= s2 true if the strings _\bs_\b1 and _\bs_\b2 are not equal.
s1 true if _\bs_\b1 is not the null string.
n1 -\b-e\beq\bq n2
true if the integers _\bn_\b1 and _\bn_\b2 are algebraically
equal. Any of the comparisons -\b-n\bne\be, -\b-g\bgt\bt, -\b-g\bge\be, -\b-l\blt\bt,
or -\b-l\ble\be may be used in place of -\b-e\beq\bq.
These primaries may be combined with the following opera-
tors:
!\b! unary negation operator
-\b-a\ba binary _\ba_\bn_\bd operator
Printed 7/9/88 September 22, 1987 1
TEST(1) UNIX Programmer's Manual TEST(1)
-\b-o\bo binary _\bo_\br operator
(\b( expr )\b)
parentheses for grouping.
-\b-a\ba has higher precedence than -\b-o\bo.\b. Notice that all the opera-
tors and flags are separate arguments to _\bt_\be_\bs_\bt. Notice also
that parentheses are meaningful to the Shell and must be
escaped.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
sh(1), find(1)
Printed 7/9/88 September 22, 1987 2