BSD 4_4_Lite2 development
[unix-history] / usr / share / man / cat1 / [.0
CommitLineData
32424d04
C
1TEST(1) BSD Reference Manual TEST(1)
2
3N\bNA\bAM\bME\bE
4 t\bte\bes\bst\bt - condition evaluation utility
5
6S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
7 t\bte\bes\bst\bt _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn
8
9D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
10 The t\bte\bes\bst\bt utility evaluates the expression and, if it evaluates to true,
11 returns a zero (true) exit status; otherwise it returns 1 (false). If
12 there is no expression, test also returns 1 (false).
13
14 All operators and flags are separate arguments to the t\bte\bes\bst\bt utility.
15
16 The following primaries are used to construct expression:
17
18 -\b-b\bb _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is a block special file.
19
20 -\b-c\bc _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is a character special file.
21
22 -\b-d\bd _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is a directory.
23
24 -\b-e\be _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists (regardless of type).
25
26 -\b-f\bf _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is a regular file.
27
28 -\b-g\bg _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and its set group ID flag is set.
29
30 -\b-h\bh _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is a symbolic link.
31
32 -\b-n\bn _\bs_\bt_\br_\bi_\bn_\bg True if the length of _\bs_\bt_\br_\bi_\bn_\bg is nonzero.
33
34 -\b-p\bp _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be is a named pipe (FIFO).
35
36 -\b-r\br _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be _\be_\bx_\bi_\bs_\bt_\bs _\ba_\bn_\bd _\bi_\bs _\br_\be_\ba_\bd_\ba_\bb_\bl_\be_\b.
37
38 -\b-s\bs _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and has a size greater than zero.
39
40 -\b-t\bt _\b[_\bf_\bi_\bl_\be_\b__\bd_\be_\bs_\bc_\br_\bi_\bp_\bt_\bo_\br_\b]
41 True if the file whose file descriptor number is
42 _\bf_\bi_\bl_\be_\b__\bd_\be_\bs_\bc_\br_\bi_\bp_\bt_\bo_\br (default 1) is open and is associated with
43 a terminal.
44
45 -\b-u\bu _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and its set user ID flag is set.
46
47 -\b-w\bw _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is writable. True indicates only
48 that the write flag is on. The file is not writable on a
49 read-only file system even if this test indicates true.
50
51 -\b-x\bx _\bf_\bi_\bl_\be True if _\bf_\bi_\bl_\be exists and is executable. True indicates only
52 that the execute flag is on. If _\bf_\bi_\bl_\be is a directory, true
53 indicates that _\bf_\bi_\bl_\be can be searched.
54
55 -\b-z\bz _\bs_\bt_\br_\bi_\bn_\bg True if the length of _\bs_\bt_\br_\bi_\bn_\bg is zero.
56
57 _\bs_\bt_\br_\bi_\bn_\bg True if _\bs_\bt_\br_\bi_\bn_\bg is not the null string.
58
59 _\bs_\b1 =\b= _\bs_\b2 True if the strings _\bs_\b1 and _\bs_\b2 are identical.
60
61 _\bs_\b1 !\b!=\b= _\bs_\b2 True if the strings _\bs_\b1 and _\bs_\b2 are not identical.
62
63 _\bn_\b1 -\b-e\beq\bq _\bn_\b2 True if the integers _\bn_\b1 and _\bn_\b2 are algebraically equal.
64
65 _\bn_\b1 -\b-n\bne\be _\bn_\b2 True if the integers _\bn_\b1 and _\bn_\b2 are not algebraically equal.
66
67
68 _\bn_\b1 -\b-g\bgt\bt _\bn_\b2 True if the integer _\bn_\b1 is algebraically greater than the
69 integer _\bn_\b2.
70
71 _\bn_\b1 -\b-g\bge\be _\bn_\b2 True if the integer _\bn_\b1 is algebraically greater than or
72 equal to the integer _\bn_\b2.
73
74 _\bn_\b1 -\b-l\blt\bt _\bn_\b2 True if the integer _\bn_\b1 is algebraically less than the inte-
75 ger _\bn_\b2.
76
77 _\bn_\b1 -\b-l\ble\be _\bn_\b2 True if the integer _\bn_\b1 is algebraically less than or equal
78 to the integer _\bn_\b2.
79
80 These primaries can be combined with the following operators:
81
82 !\b! _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn True if _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn is false.
83
84 _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b1 -\b-a\ba _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b2
85 True if both _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b1 and _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b2 are true.
86
87 _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b1 -\b-o\bo _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b2
88 True if either _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b1 or _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\b2 are true.
89
90 (\b(_\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn)\b) True if expression is true.
91
92 The -\b-a\ba operator has higher precedence than the -\b-o\bo operator.
93
94G\bGR\bRA\bAM\bMM\bMA\bAR\bR A\bAM\bMB\bBI\bIG\bGU\bUI\bIT\bTY\bY
95 The t\bte\bes\bst\bt grammar is inherently ambiguous. In order to assure a degree of
96 consistency, the cases described in the IEEE Std1003.2 (``POSIX''), sec-
97 tion D11.2/4.62.4, standard are evaluated consistently according to the
98 rules specified in the standards document. All other cases are subject
99 to the ambiguity in the command semantics.
100
101R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
102 The t\bte\bes\bst\bt utility exits with one of the following values:
103
104 0 expression evaluated to true.
105
106 1 expression evaluated to false or expression was missing.
107
108 >1 An error occurred.
109
110S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
111 The t\bte\bes\bst\bt function is expected to be IEEE Std1003.2 (``POSIX'') compati-
112 ble.
113
1144.4BSD May 31, 1993 2