This file is indexed.

/usr/share/doc/zsh-common/html/Conditional-Expressions.html is in zsh-doc 5.0.2-3ubuntu6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on December 21, 2012 by texi2html 1.82
texi2html was written by: 
            Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>zsh: 12. Conditional Expressions</title>

<meta name="description" content="zsh: 12. Conditional Expressions">
<meta name="keywords" content="zsh: 12. Conditional Expressions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Conditional-Expressions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Prompt-Expansion.html#Prompt-Expansion" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Prompt-Expansion.html#Prompt-Expansion" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<a name="Conditional-Expressions-1"></a>
<h1 class="chapter">12. Conditional Expressions</h1>
<a name="index-conditional-expressions"></a>
<a name="index-expressions_002c-conditional"></a>
<p>A <em>conditional expression</em> is used with the <tt>[[</tt>
compound command to test attributes of files and to compare strings.
Each expression can be constructed from one or more
of the following unary or binary expressions:
</p>
<dl compact="compact">
<dt> <tt>-a</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists.
</p>
</dd>
<dt> <tt>-b</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a block special file.
</p>
</dd>
<dt> <tt>-c</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a character special file.
</p>
</dd>
<dt> <tt>-d</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a directory.
</p>
</dd>
<dt> <tt>-e</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists.
</p>
</dd>
<dt> <tt>-f</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a regular file.
</p>
</dd>
<dt> <tt>-g</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and has its setgid bit set.
</p>
</dd>
<dt> <tt>-h</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a symbolic link.
</p>
</dd>
<dt> <tt>-k</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and has its sticky bit set.
</p>
</dd>
<dt> <tt>-n</tt> <var>string</var></dt>
<dd><p>true if length of <var>string</var> is non-zero.
</p>
</dd>
<dt> <tt>-o</tt> <var>option</var></dt>
<dd><p>true if option named <var>option</var> is on.  <var>option</var>
may be a single character, in which case it is a single letter option name.
(See <a href="Options.html#Specifying-Options">Specifying Options</a>.)
</p>
</dd>
<dt> <tt>-p</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a FIFO special file (named pipe).
</p>
</dd>
<dt> <tt>-r</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is readable by current process.
</p>
</dd>
<dt> <tt>-s</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and has size greater than zero.
</p>
</dd>
<dt> <tt>-t</tt> <var>fd</var></dt>
<dd><p>true if file descriptor number <var>fd</var>
is open and associated with a terminal device.
(note: <var>fd</var> is not optional)
</p>
</dd>
<dt> <tt>-u</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and has its setuid bit set.
</p>
</dd>
<dt> <tt>-w</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is writable by current process.
</p>
</dd>
<dt> <tt>-x</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is executable by current process.
If <var>file</var> exists and is a directory, then the current process
has permission to search in the directory.
</p>
</dd>
<dt> <tt>-z</tt> <var>string</var></dt>
<dd><p>true if length of <var>string</var> is zero.
</p>
</dd>
<dt> <tt>-L</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a symbolic link.
</p>
</dd>
<dt> <tt>-O</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is owned by the effective user ID of this process.
</p>
</dd>
<dt> <tt>-G</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and its group matches
the effective group ID of this process.
</p>
</dd>
<dt> <tt>-S</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and is a socket.
</p>
</dd>
<dt> <tt>-N</tt> <var>file</var></dt>
<dd><p>true if <var>file</var> exists and its access time is
not newer than its modification time.
</p>
</dd>
<dt> <var>file1</var> <tt>-nt</tt> <var>file2</var></dt>
<dd><p>true if <var>file1</var> exists and is newer than <var>file2</var>.
</p>
</dd>
<dt> <var>file1</var> <tt>-ot</tt> <var>file2</var></dt>
<dd><p>true if <var>file1</var> exists and is older than <var>file2</var>.
</p>
</dd>
<dt> <var>file1</var> <tt>-ef</tt> <var>file2</var></dt>
<dd><p>true if <var>file1</var> and <var>file2</var> exist and refer to the same file.
</p>
</dd>
<dt> <var>string</var> <tt>=</tt> <var>pattern</var></dt>
<dt> <var>string</var> <tt>==</tt> <var>pattern</var></dt>
<dd><p>true if <var>string</var> matches <var>pattern</var>.
The &lsquo;<tt>==</tt>&rsquo; form is the preferred one.  The &lsquo;<tt>=</tt>&rsquo; form is for
backward compatibility and should be considered obsolete.
</p>
</dd>
<dt> <var>string</var> <tt>!=</tt> <var>pattern</var></dt>
<dd><p>true if <var>string</var> does not match <var>pattern</var>.
</p>
</dd>
<dt> <var>string</var> <tt>=~</tt> <var>regexp</var></dt>
<dd><p>true if <var>string</var> matches the regular expression
<var>regexp</var>.  If the option <tt>RE_MATCH_PCRE</tt> is set
<var>regexp</var> is tested as a PCRE regular expression using
the <tt>zsh/pcre</tt> module, else it is tested as a POSIX
extended regular expression using the <tt>zsh/regex</tt> module.
Upon successful match, some variables will be updated; no variables
are changed if the matching fails.
</p>
<p>If the option <tt>BASH_REMATCH</tt> is not set the scalar parameter
<tt>MATCH</tt> is set to the substring that matched the pattern and
the integer parameters <tt>MBEGIN</tt> and <tt>MEND</tt> to the index of the start
and end, respectively, of the match in <var>string</var>, such that if
<var>string</var> is contained in variable <tt>var</tt> the expression
&lsquo;${var[$MBEGIN,$MEND]}&rsquo; is identical to &lsquo;$MATCH&rsquo;.  The setting
of the option <tt>KSH_ARRAYS</tt> is respected.  Likewise, the array
<tt>match</tt> is set to the substrings that matched parenthesised
subexpressions and the arrays <tt>mbegin</tt> and <tt>mend</tt> to the indices of
the start and end positions, respectively, of the substrings within
<var>string</var>.  The arrays are not set if there were no parenthesised
subexpresssions.  For example, if the string &lsquo;<tt>a short string</tt>&rsquo; is matched
against the regular expression &lsquo;<tt>s(...)t</tt>&rsquo;, then (assuming the
option <tt>KSH_ARRAYS</tt> is not set) <tt>MATCH</tt>, <tt>MBEGIN</tt>
and <tt>MEND</tt> are &lsquo;<tt>short</tt>&rsquo;, 3 and 7, respectively, while <tt>match</tt>,
<tt>mbegin</tt> and <tt>mend</tt> are single entry arrays containing
the strings &lsquo;<tt>hor</tt>&rsquo;, &lsquo;<tt>4</tt>&rsquo; and &lsquo;<tt>6</tt>, respectively.
</p>
<p>If the option <tt>BASH_REMATCH</tt> is set the array
<tt>BASH_REMATCH</tt> is set to the substring that matched the pattern
followed by the substrings that matched parenthesised
subexpressions within the pattern.
</p>
</dd>
<dt> <var>string1</var> <tt>&lt;</tt> <var>string2</var></dt>
<dd><p>true if <var>string1</var> comes before <var>string2</var>
based on ASCII value of their characters.
</p>
</dd>
<dt> <var>string1</var> <tt>&gt;</tt> <var>string2</var></dt>
<dd><p>true if <var>string1</var> comes after <var>string2</var>
based on ASCII value of their characters.
</p>
</dd>
<dt> <var>exp1</var> <tt>-eq</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically equal to <var>exp2</var>.
Note that for purely numeric comparisons use of the
<tt>((</tt><var>...</var><tt>))</tt> builtin described in
<a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation">Arithmetic Evaluation</a> is more convenient than
conditional expressions.
</p>
</dd>
<dt> <var>exp1</var> <tt>-ne</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically not equal to <var>exp2</var>.
</p>
</dd>
<dt> <var>exp1</var> <tt>-lt</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically less than <var>exp2</var>.
</p>
</dd>
<dt> <var>exp1</var> <tt>-gt</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically greater than <var>exp2</var>.
</p>
</dd>
<dt> <var>exp1</var> <tt>-le</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically less than or equal to <var>exp2</var>.
</p>
</dd>
<dt> <var>exp1</var> <tt>-ge</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> is numerically greater than or equal to <var>exp2</var>.
</p>
</dd>
<dt> <tt>(</tt> <var>exp</var> <tt>)</tt></dt>
<dd><p>true if <var>exp</var> is true.
</p>
</dd>
<dt> <tt>!</tt> <var>exp</var></dt>
<dd><p>true if <var>exp</var> is false.
</p>
</dd>
<dt> <var>exp1</var> <tt>&amp;&amp;</tt> <var>exp2</var></dt>
<dd><p>true if <var>exp1</var> and <var>exp2</var> are both true.
</p>
</dd>
<dt> <var>exp1</var> <tt>||</tt> <var>exp2</var></dt>
<dd><p>true if either <var>exp1</var> or <var>exp2</var> is true.
</p>
</dd>
</dl>

<p>Normal shell expansion is performed on the <var>file</var>, <var>string</var> and
<var>pattern</var> arguments, but the result of each expansion is constrained to
be a single word, similar to the effect of double quotes.
Filename generation is not performed on any form of argument to conditions.
However, pattern metacharacters are active for the <var>pattern</var> arguments;
the patterns are the same as those used for filename generation, see
<a href="Expansion.html#Filename-Generation">Filename Generation</a>, but there is no special behaviour
of &lsquo;<tt>/</tt>&rsquo; nor initial dots, and no glob qualifiers are allowed.
</p>
<p>In each of the above expressions, if
<var>file</var> is of the form &lsquo;<tt>/dev/fd/</tt><var>n</var>&rsquo;,
where <var>n</var> is an integer,
then the test applied to the open file whose
descriptor number is <var>n</var>,
even if the underlying system does not support
the <tt>/dev/fd</tt> directory.
</p>
<p>In the forms which do numeric comparison, the expressions <var>exp</var>
undergo arithmetic expansion as if they were enclosed in <tt>$((...))</tt>.
</p>
<p>For example, the following:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[[ ( -f foo || -f bar ) &amp;&amp; $report = y* ]] &amp;&amp; print File exists.
</pre></td></tr></table>

<p>tests if either file <tt>foo</tt> or file <tt>bar</tt> exists, and if so, if the
value of the parameter <tt>report</tt> begins with &lsquo;<tt>y</tt>&rsquo;; if the complete
condition is true, the message &lsquo;<tt>File exists.</tt>&rsquo; is printed.
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Prompt-Expansion.html#Prompt-Expansion" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="zsh.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Peter Stephenson</em> on <em>December 21, 2012</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
 </font>
 <br>

</p>
</body>
</html>