TEST(1) UNIX Programmer's Manual TEST(1)
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
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
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
true if the open file whose file descriptor number
is _
\bf_
\bi_
\bl_
\bd_
\be_
\bs (1 by default) is associated with a ter-
-
\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.
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-
!
\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
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
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
Printed 7/9/88 September 22, 1987 2