Commit | Line | Data |
---|---|---|
8a6fda3c | 1 | .\" @(#)test.1 6.1 (Berkeley) %G% |
301e682c | 2 | .\" |
8a6fda3c | 3 | .TH TEST 1 "" |
301e682c KM |
4 | .AT 3 |
5 | .SH NAME | |
6 | test \- condition command | |
7 | .SH SYNOPSIS | |
8 | .B test | |
9 | expr | |
10 | .SH DESCRIPTION | |
11 | .I test | |
12 | evaluates the expression | |
13 | .IR expr , | |
14 | and if its value is true then returns zero exit status; otherwise, a | |
15 | non zero exit status is returned. | |
16 | .I test | |
17 | returns a non zero exit if there are no arguments. | |
18 | .PP | |
19 | The following primitives are used to construct | |
20 | .IR expr . | |
21 | .TP 9n | |
22 | .BR \-r " file" | |
23 | true if the file exists and is readable. | |
24 | .TP | |
25 | .BR \-w " file" | |
26 | true if the file exists and is writable. | |
27 | .TP | |
28 | .BR \-f " file" | |
29 | true if the file exists and is not a directory. | |
30 | .TP | |
31 | .BR \-d " file" | |
32 | true if the file exists exists and is a directory. | |
33 | .TP | |
34 | .BR \-s " file" | |
35 | true if the file exists and has a size greater than zero. | |
36 | .TP | |
37 | .BR \-t " [ fildes ]" | |
38 | true if the open file whose file descriptor number is | |
39 | .I fildes | |
40 | (1 by default) | |
41 | is associated with a terminal device. | |
42 | .TP | |
43 | .BR \-z " s1" | |
44 | true if the length of string | |
45 | .I s1 | |
46 | is zero. | |
47 | .TP | |
48 | .BR \-n " s1" | |
49 | true if the length of the string | |
50 | .I s1 | |
51 | is nonzero. | |
52 | .TP | |
53 | .RB s1 " = " s2 | |
54 | true | |
55 | if the strings | |
56 | .I s1 | |
57 | and | |
58 | .I s2 | |
59 | are equal. | |
60 | .TP | |
61 | .RB s1 " != " s2 | |
62 | true | |
63 | if the strings | |
64 | .I s1 | |
65 | and | |
66 | .I s2 | |
67 | are not equal. | |
68 | .TP | |
69 | s1 | |
70 | true if | |
71 | .I s1 | |
72 | is not the null string. | |
73 | .TP | |
74 | .RB n1 " \-eq " n2 | |
75 | true if the integers | |
76 | .I n1 | |
77 | and | |
78 | .I n2 | |
79 | are algebraically equal. | |
80 | Any of the comparisons | |
81 | .BR \-ne , | |
82 | .BR \-gt , | |
83 | .BR \-ge , | |
84 | .BR \-lt , | |
85 | or | |
86 | .BR \-le | |
87 | may be used in place of | |
88 | .BR \-eq . | |
89 | .PP | |
90 | These primaries may be combined with the | |
91 | following operators: | |
92 | .TP | |
93 | .B ! | |
94 | unary negation operator | |
95 | .TP | |
96 | .B \-a | |
97 | binary | |
98 | .I and | |
99 | operator | |
100 | .TP | |
101 | .B \-o | |
102 | binary | |
103 | .I or | |
104 | operator | |
105 | .TP | |
106 | .BR "( " "expr" " )" | |
107 | parentheses for grouping. | |
108 | .PP | |
109 | .B \-a | |
110 | has higher precedence than | |
111 | .B \-o. | |
112 | Notice that all the operators and flags are separate | |
113 | arguments to | |
114 | .IR test . | |
115 | Notice also that parentheses are meaningful | |
116 | to the Shell and must be escaped. | |
117 | .SH "SEE ALSO" | |
118 | sh(1), find(1) |