Print this page
13405 ksh93 update to 2012-08-01: part 4: man page
Change-ID: If0d23a7414155253671c169228cb81ea13abbfc1
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/ksh93.1.man.txt
+++ new/usr/src/man/man1/ksh93.1.man.txt
1 1 KSH93(1) User Commands KSH93(1)
2 2
3 3
4 4
5 5 NAME
6 6 ksh93, rksh93 - Korn Shell, a standard and restricted command and
7 7 programming language
8 8
9 9 SYNOPSIS
10 10 ksh93 [+-abcefhikmnoprstuvxBCD] [-R file] [ +-o option] ...
11 11 [-] [arg ...]
12 12
13 13
14 14 rksh93 [+-abcefhikmnoprstuvxBCD] [-R file] [+-o option] ...
15 15 [-] [arg ...]
16 16
17 17
18 18 DESCRIPTION
19 19 ksh93 is a command and programming language that executes commands read
20 20 from a terminal or a file. rksh93 is a restricted version of the
21 21 command interpreter ksh93. rksh93 is used to set up login names and
22 22 execution environments whose capabilities are more controlled than
23 23 those of the standard shell.
24 24
25 25
26 26 See Invocation for the meaning of arguments to the shell.
27 27
28 28 Definitions
29 29 A metacharacter is defined as one of the following characters:
30 30
31 31 ; & ( ) | < > NEWLINE SPACE TAB
32 32
33 33
34 34
35 35
36 36 A blank is a TAB or a SPACE.
37 37
38 38
39 39 An identifier is a sequence of letters, digits, or underscores starting
40 40 with a letter or underscore. Identifiers are used as components of
41 41 variable names.
42 42
43 43
44 44 A vname is a sequence of one or more identifiers separated by a period
45 45 (.) and optionally preceded by a period (.). vnames are used as
46 46 function and variable names.
47 47
48 48
49 49 A word is a sequence of characters from the character set defined by
50 50 the current locale, excluding non-quoted metacharacters.
51 51
52 52
53 53 A command is a sequence of characters in the syntax of the shell
54 54 language. The shell reads each command and carries out the desired
55 55 action either directly or by invoking separate utilities. A built-in
56 56 command is a command that is carried out by the shell itself without
57 57 creating a separate process. Some commands are built-in purely for
58 58 convenience and are not documented in this manual page. Built-ins that
59 59 cause side effects in the shell environment and built-ins that are
60 60 found before performing a path search (see Execution) are documented in
61 61 this manual page. For historical reasons, some of these built-ins
62 62 behave differently than other built-ins and are called special built-
63 63 ins.
64 64
65 65 Commands
66 66 A simple-command is a list of variable assignments (see Variable
67 67 Assignments) or a sequence of blank-separated words which can be
68 68 preceded by a list of variable assignments. See the Environment section
69 69 of this manual page.
70 70
71 71
72 72 The first word specifies the name of the command to be executed. Except
73 73 as specified in this section, the remaining words are passed as
74 74 arguments to the invoked command. The command name is passed as
75 75 argument 0. See exec(2). The value of a simple-command is its exit
76 76 status. If it terminates normally, its value is 0-255. If it terminates
77 77 abnormally, its value is 256+signum. The name of the signal
78 78 corresponding to the exit status can be obtained by way of the -l
79 79 option of the kill built-in utility.
80 80
81 81
82 82 A pipeline is a sequence of one or more commands separated by |. The
83 83 standard output of each command but the last is connected by a pipe(2)
84 84 to the standard input of the next command. Each command, except
85 85 possibly the last, is run as a separate process. The shell waits for
86 86 the last command to terminate. The exit status of a pipeline is the
87 87 exit status of the last command unless the pipefail option is enabled.
88 88 Each pipeline can be preceded by the reserved word!. This causes the
89 89 exit status of the pipeline to become 0 if the exit status of the last
90 90 command is non-zero, and 1 if the exit status of the last command is 0.
91 91
92 92
93 93 A list is a sequence of one or more pipelines separated by ;, &, |&,
94 94 &&, or |, and optionally terminated by ;, &, or |&. Of these five
95 95 symbols, ;, &, and |& have equal precedence, which is lower than that
96 96 of && and ||. The symbols && and || also have equal precedence.
97 97
98 98
99 99 A semicolon (;) causes sequential execution of the preceding pipeline.
100 100 An ampersand (&) causes asynchronous execution of the preceding
101 101 pipeline, that is, the shell does not wait for that pipeline to finish.
102 102 The symbol |& causes asynchronous execution of the preceding pipeline
103 103 with a two-way pipe established to the parent shell. The standard input
104 104 and output of the spawned pipeline can be written to and read from by
105 105 the parent shell by applying the redirection operators <& and >& with
106 106 arg p to commands and by using -p option of the built-in commands read
107 107 and print. The symbol && (||) causes the list following it to be
108 108 executed only if the preceding pipeline returns a zero (non-zero)
109 109 value. One or more NEWLINEs can appear in a list instead of a
110 110 semicolon, to delimit a command. The first item of the first pipeline
111 111 of a list that is a simple command not beginning with a redirection,
112 112 and not occurring within a while, until, or if list , can be preceded
113 113 by a semicolon. This semicolon is ignored unless the showme option is
114 114 enabled as described with the set built-in.
115 115
116 116
117 117 A command is either a simple-command or one of commands in the
118 118 following list. Unless otherwise stated, the value returned by a
119 119 command is that of the last simple-command executed in the command.
↓ open down ↓ |
119 lines elided |
↑ open up ↑ |
120 120
121 121 for vname [ in word ... ] ;do list ;done
122 122
123 123 Each time a for command is executed, vname is set to the next word
124 124 taken from the in word list. If in word ... is omitted, the for
125 125 command executes the do list once for each positional parameter
126 126 that is set starting from 1. Execution ends when there are no more
127 127 words in the list. See Parameter Expansion.
128 128
129 129
130 - (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done
130 + for (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done
131 131
132 132 The arithmetic expression expr1 is evaluated first. The arithmetic
133 133 expression expr2 is repeatedly evaluated until it evaluates to zero
134 134 and when non-zero, list is executed and the arithmetic expression
135 135 expr3 evaluated. If any expression is omitted, then it behaves as
136 136 if it evaluated to 1. See Arithmetic Evaluation.
137 137
138 138
139 139 select vname [ in word ... ] ;do list ;done
140 140
141 141 A select command prints on standard error (file descriptor 2) the
142 142 set of words, each preceded by a number. If in word... is omitted,
143 143 the positional parameters starting from 1 are used instead. See
144 144 Parameter Expansion. The PS3 prompt is printed and a line is read
145 145 from the standard input. If this line consists of the number of one
146 146 of the listed words, then the value of the variable vname is set to
147 147 the word corresponding to this number. If this line is empty, the
148 148 selection list is printed again. Otherwise the value of the
149 149 variable vname is set to null. The contents of the line read from
150 150 standard input is saved in the variable REPLY. The list is executed
151 151 for each selection until a break or EOF is encountered. If the
152 152 REPLY variable is set to null by the execution of list, the
153 153 selection list is printed before displaying the PS3 prompt for the
154 154 next selection.
155 155
156 156
157 157 case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
158 158
159 159 A case command executes the list associated with the first pattern
160 160 that matches word. The form of the patterns is the same as that
161 161 used for file name generation. See File Name Generation.
162 162
163 163 The ;; operator causes execution of case to terminate. If ;& is
164 164 used in place of ;; the next subsequent list, if any, is executed.
165 165
166 166
167 167 if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi
168 168
169 169 The list following if is executed and, if it returns a zero exit
170 170 status, the list following the first then is executed. Otherwise,
171 171 the list following elif is executed, and, if its value is zero, the
172 172 list following the next then is executed. Failing each successive
173 173 elif list, the else list is executed. If the if list has non-zero
174 174 exit status and there is no else list, then the if command returns
175 175 a zero exit status.
176 176
177 177
178 178 while list ;do list ;done
179 179 until list ;do list ;done
180 180
181 181 A while command repeatedly executes the while list and, if the exit
182 182 status of the last command in the list is zero, executes the do
183 183 list, otherwise the loop terminates. If no commands in the do list
184 184 are executed, then the while command returns a zero exit status,
185 185 until can be used in place of while to negate the loop termination
186 186 test.
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
187 187
188 188
189 189 ((expression))
190 190
191 191 The expression is evaluated using the rules for arithmetic
192 192 evaluation described in this manual page. If the value of the
193 193 arithmetic expression is non-zero, the exit status is 0. Otherwise
194 194 the exit status is 1.
195 195
196 196
197 - (list;)
197 + (list)
198 198
199 199 Execute list in a separate environment. If two adjacent open
200 200 parentheses are needed for nesting, a SPACE must be inserted to
201 201 avoid evaluation as an arithmetic command as described in this
202 202 section.
203 203
204 +
205 + { list;}
206 +
204 207 list is simply executed. Unlike the metacharacters, ( and ), { and
205 208 } are reserved words and must occur at the beginning of a line or
206 209 after a ; to be recognized.
207 210
208 211
209 212 [[ expression ]]
210 213
211 214 Evaluates expression and returns a zero exit status when expression
212 215 is true. See Conditional Expressions for a description of
213 216 expression.
214 217
215 218
216 219 function varname { list ;}
217 220 varname () { list ;}
218 221
219 222 Define a function which is referenced by varname. A function whose
220 - varname contains a . is called a discipline function and the
223 + varname contains a dot (.) is called a discipline function and the
221 224 portion of the varname preceding the last . must refer to an
222 225 existing variable.
223 226
224 227 The body of the function is the list of commands between { and }. A
225 228 function defined with the function varname syntax can also be used
226 229 as an argument to the . special built-in command to get the
227 230 equivalent behavior as if the varname() syntax were used to define
228 231 it. See Functions.
229 232
230 233
234 + namespace identifier { list };
235 +
236 + Defines or uses the name space identifier and runs the commands in
237 + list in this name space. See Name Spaces.
238 +
239 +
231 240 time [ pipeline ]
232 241
233 242 If pipeline is omitted, the user and system time for the current
234 243 shell and completed child processes is printed on standard error.
235 244 Otherwise, pipeline is executed and the elapsed time as well as the
236 245 user and system time are printed on standard error. The TIMEFORMAT
237 246 variable can be set to a format string that specifies how the
238 247 timing information should be displayed. See Shell Variables for a
239 248 description of the TIMEFORMAT variable.
240 249
241 250
242 251
243 252 The following reserved words are recognized as reserved only when they
244 253 are the first word of a command and are not quoted:
254 +
245 255 case
246 256 do
247 257 done
248 258 else
249 259 elif
250 260 esac
251 261 for
252 262 fi
253 263 function
254 264 if
255 265 select
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
256 266 then
257 267 time
258 268 until
259 269 while
260 270 { }
261 271 [[ ]]
262 272 !
263 273
264 274 Variable Assignments
265 275 One or more variable assignments can start a simple command or can be
266 - arguments to the typeset, export, or readonly special built-in
276 + arguments to the typeset, enum, export, or readonly special built-in
267 277 commands. The syntax for an assignment is of the form:
268 278
269 279 varname=word
270 280 varname[word]=word
271 281
272 282 No space is permitted between varname and the = or between = and
273 - word.
283 + word. The variable varname is unset before the assignment.
274 284
275 285
276 286 varname=(assignlist)
277 287
278 288 No space is permitted between varname and the =. An assignlist can
279 289 be one of the following:
280 290
281 291 word ...
282 292
283 293 Indexed array assignment.
284 294
285 295
286 296 [word]=word ...
287 297
288 298 Associative array assignment. If prefixed by typeset -a,
289 299 creates an indexed array instead.
290 300
291 301
292 302 assignment ...
293 303
294 304 Compound variable assignment. This creates a compound variable
295 305 varname with sub-variables of the form varname.name, where name
296 306 is the name portion of assignment. The value of varname
297 307 contains all the assignment elements. Additional assignments
298 308 made to sub-variables of varname are also displayed as part of
299 309 the value of varname. If no assignments are specified, varname
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
300 310 is a compound variable allowing subsequence child elements to
301 311 be defined.
302 312
303 313
304 314 typeset [options] assignment ...
305 315
306 316 Nested variable assignment. Multiple assignments can be
307 317 specified by separating each of them with a ;. The previous
308 318 value is unset before the assignment.
309 319
320 +
321 + . filename
322 +
323 + Include the assignment commands contained in filename.
324 +
310 325 In addition, a += can be used in place of the = to signify adding
311 326 to or appending to the previous value. When += is applied to an
312 327 arithmetic type, word is evaluated as an arithmetic expression and
313 328 added to the current value. When applied to a string variable, the
314 329 value defined by word is appended to the value. For compound
315 330 assignments, the previous value is not unset and the new values are
316 331 appended to the current ones provided that the types are
317 332 compatible.
318 333
334 + The right hand side of a variable assignment undergoes all the
335 + expansion listed below except word splitting, brace expansion, and
336 + file name generation. When the left hand side is an assignment is
337 + a compound variable and the right hand is the name of a compound
338 + variable, the compound variable on the right will be copied or
339 + appended to the compound variable on the left.
319 340
341 +
342 +
320 343 Comments
321 344 A word beginning with # causes that word and all the following
322 345 characters up to a NEWLINE to be commented, or ignored.
323 346
324 347 Aliasing
325 348 The first word of each command is replaced by the text of an alias if
326 349 an alias for this word has been defined. An alias name consists of any
327 350 number of characters excluding metacharacters, quoting characters, file
328 351 expansion characters, parameter expansion characters, command
329 - substitution characters, and =. The replacement string can contain any
330 - valid shell script including the metacharacters listed in the Commands
331 - section. The first word of each command in the replaced text, other
332 - than any that are in the process of being replaced, are tested for
333 - aliases. If the last character of the alias value is a BLANK then the
334 - word following the alias is also checked for alias substitution.
352 + substitution characters, the characters / and =. The replacement string
353 + can contain any valid shell script including the metacharacters listed
354 + in the Commands section. The first word of each command in the replaced
355 + text, other than any that are in the process of being replaced, are
356 + tested for aliases. If the last character of the alias value is a BLANK
357 + then the word following the alias is also checked for alias
358 + substitution.
335 359
336 360
337 361 Aliases can be used to redefine built-in commands but cannot be used to
338 362 redefine the reserved words listed in the Commands section. Aliases can
339 363 be created and listed with the alias command and can be removed with
340 364 the unalias command.
341 365
342 366
343 367 Aliasing is performed when scripts are read, not while they are
344 368 executed. For an alias to take effect, the alias definition command has
345 369 to be executed before the command which references the alias is read.
346 370 The following aliases are compiled into the shell but can be unset or
347 371 redefined:
348 372
349 373 autoload='typeset -fu'
350 374 command='command '
375 + compound='typeset -C'
351 376 fc=hist
352 377 float='typeset -lE'
353 378 functions='typeset -f'
354 379 hash='alias -t --'
355 380 history='hist -l'
356 381 integer='typeset -li'
357 382 nameref='typeset -n'
358 383 nohup='nohup '
359 384 r='hist -s'
360 385 redirect='command exec'
361 386 source='command .'
362 387 stop='kill -s STOP'
363 388 suspend='kill -s STOP $$'
364 389 times='{ { time;} 2>&1;}'
365 390 type='whence -v'
366 391
367 392
368 393
369 394 Tilde Substitution
370 395 After alias substitution is performed, each word is checked to see if
371 396 it begins with an unquoted tilde (~). For tilde substitution, word also
372 397 refers to the word portion of parameter expansion. See Parameter
373 398 Expansion.
374 399
375 400
376 401 If it does, the word up to a / is checked to see if it matches a user
377 402 name in the password database. If a match is found, the ~ and the
378 403 matched login name are replaced by the login directory of the matched
379 404 user. If no match is found, the original text is left unchanged. A ~ by
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
380 405 itself, or in front of a /, is replaced by $HOME. A ~ followed by a +
381 406 or - is replaced by the value of $PWD and $OLDPWD respectively.
382 407
383 408
384 409 In addition, when expanding a variable assignment, tilde substitution
385 410 is attempted when the value of the assignment begins with a ~, and when
386 411 a ~ appears after a colon (:). The : also terminates a ~ login name.
387 412
388 413 Command Substitution
389 414 The standard output from a command enclosed in parentheses preceded by
390 - a dollar sign ($) or a pair of grave accents (``) can be used as part
391 - or all of a word. Trailing NEWLINEs are removed. In the second
392 - (obsolete) form, the string between the quotes is processed for special
393 - quoting characters before the command is executed. See Quoting.
415 + a dollar sign ( $(list) ), or in a brace group preceded by a dollar
416 + sign ( ${ list;} ), or in a pair of grave accents (``) can be used as
417 + part or all of a word. Trailing NEWLINEs are removed. In the second
418 + case, the { and } are treated as a reserved words so that { must be
419 + followed by a blank and } must appear at the beginning of the line or
420 + follow a ;. In the third (obsolete) form, the string between the quotes
421 + is processed for special quoting characters before the command is
422 + executed. See Quoting.
394 423
395 424
396 425 The command substitution $(cat file) can be replaced by the equivalent
397 426 but faster $(<file). The command substitution $(n<#) expands to the
398 - current byte offset for file descriptor n.
427 + current byte offset for file descriptor n. Except for the second form,
428 + the command list is run in a subshell so that no side effects are
429 + possible. For the second form, the final } will be recognized as a
430 + reserved word after any token.
399 431
400 432 Arithmetic Substitution
401 433 An arithmetic expression enclosed in double parentheses preceded by a
402 434 dollar sign ( $((arithmetic_expression))) is replaced by the value of
403 435 the arithmetic expression within the double parentheses.
404 436
405 437 Process Substitution
406 - Process substitution is only available on versions of the UNIX
407 - operating system that support the /dev/fd directory for naming open
408 - files.
409 -
410 -
411 438 Each command argument of the form <(list) or >(list) runs process list
412 439 asynchronously connected to some file in /dev/fd. The name of this file
413 440 becomes the argument to the command. If the form with > is selected
414 441 then writing on this file provides input for list. If < is used, then
415 442 the file passed as an argument contains the output of the list process.
416 443
417 444
418 445 For example,
419 446
420 447 paste <(cut -f1 file1) <(cut -f3 file2) | tee \
421 448 >(process1) >(process2)
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
422 449
423 450
424 451
425 452
426 453 cuts fields 1 and 3 from the files file1 and file2 respectively, pastes
427 454 the results together, and sends it to the processes process1 and
428 455 process2. It also displays the results to the standard output. The
429 456 file, which is passed as an argument to the command, is a UNIX pipe(2).
430 457 Programs that expect to lseek(2) on the file do not work.
431 458
459 + Process substitution of the form <(list) can also be used with the <
460 + redirection operator which causes the output of list to be standard
461 + input or the input for whatever file descriptor is specified.
462 +
432 463 Parameter Expansion
433 464 A parameter is a variable, one or more digits, or any of the characters
434 465 *, @, #, ?, -, $, and !. A variable is denoted by a vname. To create a
435 466 variable whose vname contains a ., a variable whose vname consists of
436 467 everything before the last . must already exist. A variable has a value
437 468 and zero or more attributes. Variables can be assigned values and
438 469 attributes by using the typeset special built-in command. The
439 470 attributes supported by the shell are described later with the typeset
440 471 special built-in command. Exported variables pass values and attributes
441 472 to the environment.
442 473
443 474
444 475 The shell supports both indexed and associative arrays. An element of
445 476 an array variable is referenced by a subscript. A subscript for an
446 477 indexed array is denoted by an arithmetic expression, (see Arithmetic
447 - Evaluation), between a [ and a ]. Use set -A vname value ... to assign
448 - values to an indexed array. The value of all subscripts must be in the
449 - range of 0 through 1,048,575. Indexed arrays do not need to be
450 - declared. Any reference to a variable with a valid subscript is legal
451 - and an array is created if necessary.
478 + Evaluation), between a [ and a ]. To assign values to an indexed
479 + array, use vname=(value ...) or set -A vname value ... . The value of
480 + all subscripts must be in the range of 0 through 4,194,303. A negative
481 + subscript is treated as an offset from the maximum current index +1 so
482 + that -1 refers to the last element. Indexed arrays can be declared
483 + with the -a option to typeset. Indexed arrays need not be declared. Any
484 + reference to a variable with a valid subscript is legal and an array
485 + will be created if necessary.
452 486
453 487
454 488 An associative array is created with the -A option to typeset. A
455 489 subscript for an associative array is denoted by a string enclosed
456 490 between [ and ].
457 491
458 492
459 493 Referencing any array without a subscript is equivalent to referencing
460 494 the array with subscript 0.
461 495
462 496
463 497 The value of a variable can be assigned by:
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
464 498
465 499 vname=value [vname=value] ...
466 500
467 501
468 502
469 503
470 504 or
471 505
472 506 vname[subscript]=value [vname[subscript]=value] ...
473 507
508 + Note that no space is allowed before or after the =.
474 509
510 + Attributes assigned by the typeset special built-in command apply to
511 + all elements of the array. An array element can be a simple variable,
512 + a compound variable or an array variable. An element of an indexed
513 + array can be either an indexed array or an associative array. An
514 + element of an associative array can also be either. To refer to an
515 + array element that is part of an array element, concatenate the
516 + subscript in brackets. For example, to refer to the foobar element of
517 + an associative array that is defined as the third element of the
518 + indexed array, use ${vname[3][foobar]}
475 519
476 520
477 - No space is allowed before or after the =. A nameref is a variable that
478 - is a reference to another variable. A nameref is created with the -n
479 - attribute of typeset. The value of the variable at the time of the
480 - typeset command becomes the variable that is referenced whenever the
481 - nameref variable is used. The name of a nameref cannot contain a dot
482 - (.). When a variable or function name contains a ., and the portion of
483 - the name up to the first . matches the name of a nameref, the variable
484 - referred to is obtained by replacing the nameref portion with the name
485 - of the variable referenced by the nameref. If a nameref is used as the
486 - index of a for loop, a name reference is established for each item in
487 - the list. A nameref provides a convenient way to refer to the variable
488 - inside a function whose name is passed as an argument to a function.
489 - For example, if the name of a variable is passed as the first argument
490 - to a function, the command
521 + A nameref is a variable that is a reference to another variable. A
522 + nameref is created with the -n attribute of typeset. The value of the
523 + variable at the time of the typeset command becomes the variable that
524 + is referenced whenever the nameref variable is used. The name of a
525 + nameref cannot contain a dot (.). When a variable or function name
526 + contains a dot (.) and the portion of the name up to the first .
527 + matches the name of a nameref, the variable referred to is obtained by
528 + replacing the nameref portion with the name of the variable referenced
529 + by the nameref. If a nameref is used as the index of a for loop, a name
530 + reference is established for each item in the list. A nameref provides
531 + a convenient way to refer to the variable inside a function whose name
532 + is passed as an argument to a function. For example, if the name of a
533 + variable is passed as the first argument to a function, the command
491 534
492 535 typeset -n var=$1
493 536
494 537
495 538
496 539
497 540 inside the function causes references and assignments to var to be
498 541 references and assignments to the variable whose name has been passed
499 - to the function. If either of the floating point attributes, -E, or -F,
542 + to the function. If any of the floating point attributes, -E,-F or -X,
500 543 or the integer attribute, -i, is set for vname, then the value is
501 544 subject to arithmetic evaluation as described in this manual page.
502 545 Positional parameters, parameters denoted by a number, can be assigned
503 546 values with the set special built-in command. Parameter $0 is set from
504 - argument zero when the shell is invoked. The character $ is used to
505 - introduce substitutable parameters.
547 + argument zero when the shell is invoked.
506 548
549 + The character $ is used to introduce substitutable parameters.
550 +
507 551 ${parameter}
508 552
509 553 The shell reads all the characters from ${ to the matching } as
510 554 part of the same word even if it contains braces or metacharacters.
511 555 The value, if any, of the parameter is substituted. The braces are
512 556 required when parameter is followed by a letter, digit, or
513 - underscore that is not to be interpreted as part of its name, when
514 - the variable name contains a ., or when a variable is subscripted.
515 - If parameter is one or more digits then it is a positional
516 - parameter. A positional parameter of more than one digit must be
517 - enclosed in braces. If parameter is * or @, then all the positional
518 - parameters, starting with $1, are substituted and separated by a
519 - field separator character. If an array vname with subscript * or @
520 - is used, then the value for each of the elements is substituted,
521 - separated by the first character of the value of IFS.
557 + underscore that is not to be interpreted as part of its name or
558 + when the variable name contains a dot (.). The braces are also
559 + required when a variable is subscripted unless it is part of an
560 + Arithmetic Expression or a Conditional Expression. If parameter is
561 + one or more digits then it is a positional parameter. A positional
562 + parameter of more than one digit must be enclosed in braces. If
563 + parameter is * or @, then all the positional parameters, starting
564 + with $1, are substituted and separated by a field separator
565 + character. If an array vname with last subscript * or @ is used, or
566 + for index arrays of the form sub1 .. sub2 is used, then the value
567 + for each of the elements between sub1 and sub2 inclusive (or all
568 + elements for * and @) is substituted, separated by the first
569 + character of the value of IFS.
522 570
523 571
524 572 ${#parameter}
525 573
526 574 If parameter is * or @, the number of positional parameters is
527 575 substituted. Otherwise, the length of the value of the parameter is
528 576 substituted.
529 577
530 578
531 579 ${#vname[*]}
532 580 ${#vname[@]}
533 581
534 582 The number of elements in the array vname is substituted.
535 583
584 + ${@vname}
536 585
586 + Expands to the type name or attributes of the variable referred to
587 + by vname. See Type Variables.
588 +
589 +
537 590 ${!vname}
538 591
539 592 Expands to the name of the variable referred to by vname. This is
540 593 vname except when vname is a name reference.
541 594
542 595
543 596 ${!vname[subscript]}
544 597
545 - Expands to name of the subscript unless subscript is * or @. When
546 - subscript is *, the list of array subscripts for vname is
547 - generated. For a variable that is not an array, the value is 0 if
548 - the variable is set. Otherwise it is null. When subscript is @, it
549 - is the same as $ {vname[*]}, except that when used in double
550 - quotes, each array subscript yields a separate argument.
598 + Expands to name of the subscript unless subscript is * or @, or of
599 + the form sub1 .. sub2. When subscript is *, the list of array
600 + subscripts for vname is generated. For a variable that is not an
601 + array, the value is 0 if the variable is set, otherwise it is null.
602 + When subscript is @, it is the same as $ {vname[*]}, except that
603 + when used in double quotes, each array subscript yields a separate
604 + argument. When subscript is of the form sub1 .. sub2 it expands to
605 + the list of subscripts between sub1 and sub2 inclusive using the
606 + same quoting rules as @.
551 607
552 608
553 609 ${!prefix*}
554 610
555 611 Expands to the names of the variables whose names begin with
556 612 prefix.
557 613
558 614
559 615 ${parameter:-word}
560 616
561 617 If parameter is set and is non-null then substitute its value.
562 618 Otherwise substitute word.
563 619
564 - word is not evaluated unless it is to be used as the substituted
565 - string.
566 620
567 - In the following example, pwd is executed only if d is not set or
568 - is NULL:
569 -
570 - print ${d:-$(pwd)}
571 -
572 -
573 - If the colon (: ) is omitted from the expression, the shell only
574 - checks whether parameter is set or not.
575 -
576 -
577 621 ${parameter:=word}
578 622
579 623 If parameter is not set or is null, set it to word. The value of
580 624 the parameter is then substituted. Positional parameters cannot be
581 625 assigned to in this way.
582 626
583 - word is not evaluated unless it is to be used as the substituted
584 - string.
585 627
586 - In the following example, pwd is executed only if d is not set or
587 - is NULL:
588 -
589 - print ${d:-$(pwd)}
590 -
591 -
592 - If the colon (:) is omitted from the expression, the shell only
593 - checks whether parameter is set or not.
594 -
595 -
596 628 ${parameter:?word}
597 629
598 630 If parameter is set and is non-null, substitute its value.
599 631 Otherwise, print word and exit from the shell , if the shell is not
600 632 interactive. If word is omitted then a standard message is printed.
601 633
602 - word is not evaluated unless it is to be used as the substituted
603 - string.
604 634
605 - In the following example, pwd is executed only if d is not set or
606 - is NULL:
607 -
608 - print ${d:-$(pwd)}
609 -
610 -
611 - If the colon (: ) is omitted from the expression, the shell only
612 - checks whether parameter is set or not.
613 -
614 -
615 635 ${parameter:+word}
616 636
617 637 If parameter is set and is non-null, substitute word. Otherwise
618 638 substitute nothing.
619 639
620 - word is not evaluated unless it is to be used as the substituted
621 - string.
640 + In the above, word is not evaluated unless it is to be used as the
641 + substituted string. In the following example, pwd is executed only if d
642 + is not set or is NULL:
622 643
623 - In the following example, pwd is executed only if d is not set or
624 - is NULL:
644 + print ${d:-$(pwd)}
625 645
626 - print ${d:-$(pwd)}
627 646
647 + If the colon (:) is omitted from the expression, the shell only checks
648 + whether parameter is set or not.
628 649
629 - If the colon (:) is omitted from the expression, the shell only
630 - checks whether parameter is set or not.
631 650
632 -
633 651 ${parameter:offset:length}
634 652 ${parameter:offset}
635 653
636 654 Expands to the portion of the value of parameter starting at the
637 655 character (counting from 0) determined by expanding offset as an
638 656 arithmetic expression and consisting of the number of characters
639 657 determined by the arithmetic expression defined by length.
640 658
641 659 In the second form, the remainder of the value is used. A negative
642 660 offset counts backwards from the end of parameter.
643 661
644 662 One or more BLANKs is required in front of a minus sign to prevent
645 663 the shell from interpreting the operator as :-. If parameter is *
646 664 or @, or is an array name indexed by * or @, then offset and length
647 665 refer to the array index and number of elements respectively. A
648 666 negative offset is taken relative to one greater than the highest
649 667 subscript for indexed arrays. The order for associative arrays is
650 668 unspecified.
651 669
652 670
653 671 ${parameter#pattern}
654 672 ${parameter##pattern}
655 673
656 674 If the shell pattern matches the beginning of the value of
657 675 parameter, then the value of this expansion is the value of the
658 676 parameter with the matched portion deleted. Otherwise the value of
659 677 this parameter is substituted. In the first form the smallest
660 678 matching pattern is deleted and in the second form the largest
661 679 matching pattern is deleted. When parameter is @, *, or an array
662 680 variable with subscript @ or *, the substring operation is applied
663 681 to each element in turn.
664 682
665 683
666 684 ${parameter%pattern}
667 685 ${parameter%%pattern}
668 686
669 687 If the shell pattern matches the end of the value of parameter,
670 688 then the value of this expansion is the value of the parameter with
671 689 the matched part deleted. Otherwise substitute the value of
672 690 parameter. In the first form the smallest matching pattern is
673 691 deleted, and in the second form the largest matching pattern is
674 692 deleted. When parameter is @, *, or an array variable with
675 693 subscript @ or *, the substring operation is applied to each
676 694 element in turn.
677 695
678 696
679 697 ${parameter/pattern/string}
680 698 ${parameter//pattern/string}
681 699 ${parameter/#pattern/string}
682 700 ${parameter/%pattern/string}
683 701
684 702 Expands parameter and replaces the longest match of pattern with
685 703 the specified string. Each occurrence of \n in string is replaced
686 704 by the portion of parameter that matches the nth sub-pattern.
687 705
688 706 When string is null, the pattern is deleted and the / in front of
689 707 string can be omitted. When parameter is @, *, or an array variable
690 708 with subscript @ or *, the substitution operation is applied to
691 709 each element in turn. In this case, the string portion of word is
692 710 re-evaluated for each element.
693 711
694 712 In the first form, only the first occurrence of pattern is
695 713 replaced.
696 714
697 715 In the second form, each match for pattern is replaced by the
698 716 specified string.
699 717
700 718 The third form restricts the pattern match to the beginning of the
701 719 string.
702 720
703 721 The fourth form restricts the pattern match to the end of the
704 722 string.
705 723
706 724
707 725
708 726 The following parameters are automatically set by the shell:
709 727
710 728 #
711 729 The number of positional parameters in decimal.
712 730
713 731
714 732 -
715 733 Options supplied to the shell on invocation or by
716 734 the set command.
717 735
718 736
719 737 ?
720 738 The decimal value returned by the last executed
721 739 command.
722 740
723 741
724 742 $
725 743 The process number of this shell.
726 744
727 745
728 746 _
729 747 Initially, the value of _ is the absolute pathname
730 748 of the shell or script being executed as passed in
↓ open down ↓ |
88 lines elided |
↑ open up ↑ |
731 749 the environment. It is subsequently assigned the
732 750 last argument of the previous command.
733 751
734 752 This parameter is not set for commands which are
735 753 asynchronous. This parameter is also used to hold
736 754 the name of the matching MAIL file when checking for
737 755 mail.
738 756
739 757
740 758 !
741 - The process number of the last background command
742 - invoked or the most recent job put in the background
743 - with the bg built-in command.
759 + The process id or the pool name and job number of
760 + the last background command invoked or the most
761 + recent job put in the background with the bg built-
762 + in command. Background jobs started in a named pool
763 + with be in the form pool.number where pool is the
764 + pool name and number is the job number within that
765 + pool.
744 766
745 767
746 768 .sh.command
747 769 When processing a DEBUG trap, this variable contains
748 770 the current command line that is about to run.
749 771
750 772
751 773 .sh.edchar
752 774 This variable contains the value of the keyboard
753 775 character (or sequence of characters if the first
754 776 character is an ESC, ASCII 033) that has been
755 777 entered when processing a KEYBD trap. If the value
756 778 is changed as part of the trap action, then the new
757 779 value replaces the key (or key sequence) that caused
758 780 the trap. See the Key Bindings section of this
759 781 manual page.
760 782
761 783
762 784 .sh.edcol
763 785 The character position of the cursor at the time of
764 786 the most recent KEYBD trap.
765 787
766 788
767 789 .sh.edmode
768 790 The value is set to ESC when processing a KEYBD trap
769 791 while in vi insert mode. Otherwise, .sh.edmode is
770 792 null when processing a KEYBD trap. See the vi
771 793 Editing Mode section of this manual page.
772 794
773 795
774 796 .sh.edtext
775 797 The characters in the input buffer at the time of
776 798 the most recent KEYBD trap. The value is null when
777 799 not processing a KEYBD trap.
778 800
779 801
780 802 .sh.file
781 803 The pathname of the file than contains the current
782 804 command.
783 805
784 806
785 807 .sh.fun
786 808 The name of the current function that is being
787 809 executed.
788 810
789 811
790 812 .sh.match
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
791 813 An indexed array which stores the most recent match
792 814 and sub-pattern matches after conditional pattern
793 815 matches that match and after variables expansions
794 816 using the operators #, %, or /. The 0th element
795 817 stores the complete match and the ith element stores
796 818 the ith sub-match. The .sh.match variable is unset
797 819 when the variable that has expanded is assigned a
798 820 new value.
799 821
800 822
823 + .sh.math
824 + Used for defining arithmetic functions (see
825 + Arithmetic evaluation) and stores the list of user-
826 + defined arithmetic functions.
827 +
828 +
801 829 .sh.name
802 830 Set to the name of the variable at the time that a
803 831 discipline function is invoked.
804 832
805 833
806 834 .sh.subscript
807 835 Set to the name subscript of the variable at the
808 836 time that a discipline function is invoked.
809 837
810 838
811 839 .sh.subshell
812 840 The current depth for sub-shells and command
813 841 substitution.
814 842
815 843
816 844 .sh.value
817 845 Set to the value of the variable at the time that
818 846 the set or append discipline function is invoked.
847 + When a user-defined arithmetic function is invoked,
848 + the value of .sh.value is saved and .sh.value is set
849 + to long double precision floating point. .sh.value
850 + is restored when the function returns.
819 851
820 852
821 853 .sh.version
822 854 Set to a value that identifies the version of this
823 855 shell.
824 856
825 857
826 858 LINENO
827 859 The current line number within the script or
828 860 function being executed.
829 861
830 862
831 863 OLDPWD
832 864 The previous working directory set by the cd
833 865 command.
834 866
835 867
836 868 OPTARG
837 869 The value of the last option argument processed by
838 870 the getopts built-in command.
839 871
840 872
841 873 OPTIND
842 874 The index of the last option argument processed by
843 875 the getopts built-in command.
844 876
845 877
846 878 PPID
847 879 The process number of the parent of the shell.
848 880
849 881
850 882 PWD
851 883 The present working directory set by the cd command.
852 884
853 885
854 886 RANDOM
855 887 Each time this variable is referenced, a random
856 888 integer, uniformly distributed between 0 and 32767,
857 889 is generated. The sequence of random numbers can be
858 890 initialized by assigning a numeric value to RANDOM.
859 891
860 892
861 893 REPLY
862 894 This variable is set by the select statement and by
863 895 the read built-in command when no arguments are
864 896 supplied.
865 897
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
866 898
867 899 SECONDS
868 900 Each time this variable is referenced, the number of
869 901 seconds since shell invocation is returned. If this
870 902 variable is assigned a value, then the value
871 903 returned upon reference is the value that was
872 904 assigned plus the number of seconds since the
873 905 assignment.
874 906
875 907
908 + SHLVL
909 + An integer variable the is incremented each time the
910 + shell is invoked and is exported. If SHLVL is not
911 + in the environment when the shell is invoked, it is
912 + set to 1.
876 913
914 +
915 +
877 916 The following variables are used by the shell:
878 917
879 918 CDPATH
880 919 Defines the search path for the cd command.
881 920
882 921
883 922 COLUMNS
884 923 Defines the width of the edit window for the shell edit
885 924 modes and for printing select lists.
886 925
887 926
888 927 EDITOR
889 928 If the VISUAL variable is not set, the value of this
890 929 variable is checked for the patterns as described with
891 930 VISUAL and the corresponding editing option is turned on.
892 931
893 932 See the set command in the Special Command section of
894 933 this manual page.
895 934
896 935
897 936 ENV
898 937 Performs parameter expansion, command substitution, and
899 938 arithmetic substitution on the value to generate the
900 939 pathname of the script that is executed when the shell is
901 940 invoked. This file is typically used for alias and
902 941 function definitions. The default value is $HOME/.kshrc.
903 942
904 943 See the Invocation section of this manual page.
905 944
906 945 ENV is not set by the shell.
907 946
908 947
909 948 FCEDIT
910 949 Obsolete name for the default editor name for the hist
911 950 command. FCEDIT is not used when HISTEDIT is set.
912 951
913 952 The shell specifies a default value to FCEDIT.
914 953
915 954
916 955 FIGNORE
917 956 A pattern that defines the set of file names that is
918 957 ignored when performing file name matching.
919 958
920 959
921 960 FPATH
922 961 The search path for function definitions. The directories
923 962 in this path are searched for a file with the same name
924 963 as the function or command when a function with the -u
925 964 attribute is referenced and when a command is not found.
926 965 If an executable file with the name of that command is
927 966 found, then it is read and executed in the current
928 967 environment. Unlike PATH, the current directory must be
929 968 represented explicitly by dot (.) rather than by adjacent
930 969 colon (:) characters or a beginning or ending colon (:).
931 970
932 971
933 972 HISTCMD
934 973 The number of the current command in the history file.
935 974
936 975
937 976 HISTEDIT
938 977 The name for the default editor name for the hist
939 978 command.
940 979
941 980
942 981 HISTFILE
943 982 If this variable is set when the shell is invoked, the
944 983 value is the pathname of the file that is used to store
945 984 the command history. See the Command Re-entry section of
946 985 this manual page.
947 986
948 987
949 988 HISTSIZE
950 989 If this variable is set when the shell is invoked, then
951 990 the number of previously entered commands that are
952 991 accessible by this shell is greater than or equal to this
953 992 number. The default is 512.
954 993
955 994
956 995 HOME
957 996 The default argument (home directory) for the cd command.
958 997
959 998 HOME is not set by the shell. HOME is set by login(1).
960 999
961 1000
962 1001 IFS
963 1002 Internal field separators, normally SPACE, TAB, and
964 1003 NEWLINE that are used to separate the results of command
965 1004 substitution or parameter expansion and to separate
966 1005 fields with the built-in command read. The first
967 1006 character of the IFS variable is used to separate
968 1007 arguments for the "$*" substitution. See the Quoting
969 1008 section of this manual page.
970 1009
971 1010 Each single occurrence of an IFS character in the string
972 1011 to be split, that is not in the issspace character class,
973 1012 and any adjacent characters in IFS that are in the
974 1013 issspace character class, delimit a field. One or more
↓ open down ↓ |
88 lines elided |
↑ open up ↑ |
975 1014 characters in IFS that belong to the issspace character
976 1015 class, delimit a field. In addition, if the same issspace
977 1016 character appears consecutively inside IFS, this
978 1017 character is treated as if it were not in the issspace
979 1018 class, so that if IFS consists of two tab characters,
980 1019 then two adjacent tab characters delimit a null field.
981 1020
982 1021 The shell specifies a default value to IFS.
983 1022
984 1023
1024 + JOBMAX
1025 + This variable defines the maximum number running
1026 + background jobs that can run at a time. When this limit
1027 + is reached, the shell will wait for a job to complete
1028 + before staring a new job.
1029 +
1030 +
985 1031 LANG
986 1032 This variable determines the locale category for any
987 1033 category not specifically selected with a variable
988 1034 starting with LC_ or LANG.
989 1035
990 1036
991 1037 LC_ALL
992 1038 This variable overrides the value of the LANG variable
993 1039 and any other LC_ variable.
994 1040
995 1041
996 1042 LC_COLLATE
997 1043 This variable determines the locale category for
998 1044 character collation information.
999 1045
1000 1046
1001 1047 LC_CTYPE
1002 1048 This variable determines the locale category for
1003 1049 character handling functions. It determines the
1004 1050 character classes for pattern matching. See the File Name
1005 1051 Generation section of this manual page.
1006 1052
1007 1053
1008 1054 LC_NUMERIC
1009 1055 This variable determines the locale category for the
1010 1056 decimal point character.
1011 1057
1012 1058
1013 1059 LINES
1014 1060 If this variable is set, the value is used to determine
1015 1061 the column length for printing select lists. Select lists
1016 1062 prints vertically until about two-thirds of LINES lines
1017 1063 are filled.
1018 1064
1019 1065
1020 1066 MAIL
1021 1067 If this variable is set to the name of a mail file and
1022 1068 the MAILPATH variable is not set, then the shell informs
1023 1069 the user of arrival of mail in the specified file.
1024 1070
1025 1071 MAIL is not set by the shell. On some systems, MAIL is
1026 1072 set by login(1).
1027 1073
1028 1074
1029 1075 MAILCHECK
1030 1076 Specifies how often in seconds the shell checks for
1031 1077 changes in the modification time of any of the files
1032 1078 specified by the MAILPATH or MAIL variables. The default
1033 1079 value is 600 seconds. When the time has elapsed the shell
1034 1080 checks before issuing the next prompt.
1035 1081
1036 1082 The shell specifies a default value to MAILCHECK.
1037 1083
1038 1084
1039 1085 MAILPATH
1040 1086 A colon ( : ) separated list of file names. If this
1041 1087 variable is set, then the shell informs the user of any
1042 1088 modifications to the specified files that have occurred
1043 1089 within the last MAILCHECK seconds. Each file name can be
1044 1090 followed by a ? and a message that is printed. The
1045 1091 message undergoes parameter expansion, command
1046 1092 substitution, and arithmetic substitution with the
1047 1093 variable $_ defined as the name of the file that has
1048 1094 changed. The default message is you have mail in $_.
1049 1095
1050 1096
1051 1097 PATH
1052 1098 The search path for commands. Except in .profile, users
1053 1099 cannot change PATH if executing under rksh93. See the
1054 1100 Execution section of this manual page.
1055 1101
1056 1102 The shell specifies a default value to PATH.
1057 1103
1058 1104
1059 1105 PS1
1060 1106 The value of this variable is expanded for parameter
1061 1107 expansion, command substitution, and arithmetic
1062 1108 substitution to define the primary prompt string which by
1063 1109 default is $. The character ! in the primary prompt
1064 1110 string is replaced by the command number. Two successive
1065 1111 occurrences of ! produces a single ! when the prompt
1066 1112 string is printed. See the Command Re-entry section of
1067 1113 this manual page.
1068 1114
1069 1115 The shell specifies a default value to PS1.
1070 1116
1071 1117
1072 1118 PS2
1073 1119 Secondary prompt string, by default, >.
1074 1120
1075 1121 The shell specifies a default value to PS2.
1076 1122
1077 1123
1078 1124 PS3
1079 1125 Selection prompt string used within a select loop, by
1080 1126 default #?.
1081 1127
1082 1128 The shell specifies a default value to PS3.
1083 1129
1084 1130
1085 1131 PS4
1086 1132 The value of this variable is expanded for parameter
1087 1133 evaluation, command substitution, and arithmetic
1088 1134 substitution and precedes each line of an execution
1089 1135 trace. By default, PS4 is +. When PS4 is unset, the
1090 1136 execution trace prompt is also + .
1091 1137
1092 1138 The shell specifies a default value to PS4.
1093 1139
1094 1140
1095 1141 SHELL
1096 1142 The pathname of the shell is kept in the environment. At
1097 1143 invocation, if the basename of this variable is rsh,
1098 1144 rksh, rksh93, or krsh, the shell becomes restricted.
1099 1145
1100 1146 SHELL is not set by the shell. On some systems, SHELL is
1101 1147 set by login(1).
1102 1148
1103 1149
1104 1150 TIMEFORMAT
1105 1151 The value of this parameter is used as a format string
1106 1152 specifying how the timing information for pipelines
1107 1153 prefixed with the time reserved word should be displayed.
1108 1154 The % character introduces a format sequence that is
1109 1155 expanded to a time value or other information.
1110 1156
1111 1157 The format sequences and their meanings are as follows.
1112 1158
1113 1159 %%
1114 1160
1115 1161 A literal %.
1116 1162
1117 1163
1118 1164 %[p][l]R
1119 1165
1120 1166 The elapsed time in seconds.
1121 1167
1122 1168
1123 1169 %[p][l]U
1124 1170
1125 1171 The number of CPU seconds spent in user mode.
1126 1172
1127 1173
1128 1174 %[p][l]S
1129 1175
1130 1176 The number of CPU seconds spent in system mode.
1131 1177
1132 1178
1133 1179 %P
1134 1180
1135 1181 The CPU percentage, computed as (U + S) / R.
1136 1182
1137 1183 The braces denote optional portions. The optional p is a
1138 1184 digit specifying the precision, the number of fractional
1139 1185 digits after a decimal point. A value of 0 causes no
1140 1186 decimal point or fraction to be output. At most three
1141 1187 places after the decimal point can be displayed. Values
1142 1188 of p greater than 3 are treated as 3. If p is not
1143 1189 specified, the value 3 is used.
1144 1190
1145 1191 The optional l specifies a longer format, including hours
1146 1192 if greater than zero, minutes, and seconds of the form
1147 1193 HHhMMmSS.FFs. The value of p determines whether or not
1148 1194 the fraction is included.
1149 1195
1150 1196 All other characters are output without change and a
1151 1197 trailing NEWLINE is added. If unset, the default value,
1152 1198 $'\nreal\t%2lR\nuser\t%2lU\nsys%2lS', is used. If the
1153 1199 value is null, no timing information is displayed.
1154 1200
1155 1201
1156 1202 TMOUT
1157 1203 If set to a value greater than zero, TMOUT is the default
1158 1204 time-out value for the read built-in command. The select
1159 1205 compound command terminates after TMOUT seconds when
1160 1206 input is from a terminal. Otherwise, the shell terminates
1161 1207 if a line is not entered within the prescribed number of
1162 1208 seconds while reading from a terminal. The shell can be
1163 1209 compiled with a maximum bound for this value which cannot
1164 1210 be exceeded.
1165 1211
1166 1212 The shell specifies a default value to TMOUT.
1167 1213
1168 1214
1169 1215 VISUAL
1170 1216 If the value of this variable matches the pattern
1171 1217 *[Vv][Ii]*, then the vi option is turned on. See Special
1172 1218 Commands. If the value matches the pattern *gmacs* , the
1173 1219 gmacs option is turned on. If the value matches the
1174 1220 pattern *macs*, then the emacs option is turned on. The
1175 1221 value of VISUAL overrides the value of EDITOR.
1176 1222
1177 1223
1178 1224 Field Splitting
1179 1225 After parameter expansion and command substitution, the results of
1180 1226 substitutions are scanned for the field separator characters (those
1181 1227 found in IFS) and split into distinct fields where such characters are
1182 1228 found. Explicit null fields ("" or '') are retained. Implicit null
1183 1229 fields, those resulting from parameters that have no values or command
1184 1230 substitutions with no output, are removed.
1185 1231
1186 1232
1187 1233 If the braceexpand (-B) option is set, each of the fields resulting
1188 1234 from IFS are checked to see if they contain one or more of the brace
1189 1235 patterns. Valid brace patterns: {*,*}, {l1..l2} , {n1..n2},
1190 1236 {n1..n2%fmt} {n1..n2 ..n3}, or {n1..n2 ..n3%fmt} , where * represents
1191 1237 any character, l1,l2 are letters and n1,n2,n3 are signed numbers and
1192 1238 fmt is a format specified as used by printf. In each case, fields are
1193 1239 created by prepending the characters before the { and appending the
1194 1240 characters after the } to each of the strings generated by the
1195 1241 characters between the { and }. The resulting fields are checked to see
1196 1242 if they have any brace patterns.
1197 1243
1198 1244
1199 1245 In the first form, a field is created for each string between { and ,,
1200 1246 between , and ,, and between , and }. The string represented by * can
1201 1247 contain embedded matching { and } without quoting. Otherwise, each {
1202 1248 and } with * must be quoted.
1203 1249
1204 1250
1205 1251 In the second form, l1 and l2 must both be either upper case or both be
1206 1252 lower case characters in the C locale. In this case a field is created
1207 1253 for each character from l1 through l2.
1208 1254
1209 1255
1210 1256 In the remaining forms, a field is created for each number starting at
1211 1257 n1. This continues until it reaches n2 and increments n1 by n3. The
1212 1258 cases where n3 is not specified behave as if n3 were 1 if n1<=n2, and
1213 1259 -1 otherwise. In forms which specify %fmt, any format flags, widths and
1214 1260 precisions can be specified and fmt can end in any of the specifiers
1215 1261 cdiouxX. For example, {a,z}{1..5..3%02d}{b..c}x expands to the 8
1216 1262 fields, a01bx, a01cx, a04bx, a04cx, z01bx, z01cx, z04bx, and z04cx.
1217 1263
1218 1264 File Name Generation
1219 1265 Following splitting, each field is scanned for the characters *, ?, (,
1220 1266 and [, unless the -f option has been set. If one of these characters
1221 1267 appears, then the word is regarded as a pattern.
1222 1268
1223 1269
1224 1270 Each file name component that contains any pattern character is
1225 1271 replaced with a lexicographically sorted set of names that matches the
1226 1272 pattern from that directory. If no file name is found that matches the
1227 1273 pattern, then that component of the file name is left unchanged unless
1228 1274 the pattern is prefixed with ~(N) in which case it is removed. If
1229 1275 FIGNORE is set, then each file name component that matches the pattern
1230 1276 defined by the value of FIGNORE is ignored when generating the matching
1231 1277 file names. The names . and .. are also ignored. If FIGNORE is not set,
1232 1278 the character . at the start of each file name component is ignored
1233 1279 unless the first character of the pattern corresponding to this
1234 1280 component is the character . itself. For other uses of pattern matching
1235 1281 the / and . are not specially treated.
1236 1282
1237 1283 *
1238 1284 Match any string, including the null string. When used for
1239 1285 file name expansion, if the globstar option is on, two
1240 1286 adjacent *s by themselves match all files and zero or more
1241 1287 directories and subdirectories. If the two adjacent *s are
1242 1288 followed by a /, only directories and subdirectories match.
↓ open down ↓ |
248 lines elided |
↑ open up ↑ |
1243 1289
1244 1290
1245 1291 ?
1246 1292 Matches any single character.
1247 1293
1248 1294
1249 1295 [...]
1250 1296 Match any one of the enclosed characters. A pair of
1251 1297 characters separated by - matches any character lexically
1252 1298 between the pair, inclusive. If the first character
1253 - following the opening [ is a !, any character not enclosed
1254 - is matched. A - can be included in the character set by
1255 - putting it as the first or last character. Within [ and ],
1256 - character classes can be specified with the syntax [:class:]
1257 - where class is one of the following classes defined in the
1258 - ANSI-C standard:
1299 + following the opening [ is a ! or ^, any character not
1300 + enclosed is matched. A - can be included in the character
1301 + set by putting it as the first or last character. Within [
1302 + and ], character classes can be specified with the syntax
1303 + [:class:] where class is one of the following classes
1304 + defined in the ANSI-C standard:
1259 1305
1260 1306 alnum alpha blank cntrl digit graph
1261 1307 lower print punct space upper
1262 1308 word xdigit
1263 1309
1264 1310
1265 1311 word is equivalent to alnum plus the character _. Within [
1266 1312 and ], an equivalence class can be specified with the syntax
1267 1313 [=c=] which matches all characters with the same primary
1268 1314 collation weight (as defined by the current locale) as the
1269 1315 character c. Within [ and ], [.symbol.] matches the
1270 1316 collating symbol symbol.
1271 1317
1272 1318
1273 1319
1274 1320 A pattern-list is a list of one or more patterns separated from each
1275 1321 other with an & or |. An & signifies that all patterns must be matched
1276 1322 whereas | requires that only one pattern be matched. Composite patterns
1277 1323 can be formed with one or more of the following sub-patterns:
1278 1324
1279 1325 ?(pattern-list)
1280 1326 Optionally matches any one of the specified
1281 1327 patterns.
1282 1328
1283 1329
1284 1330 *(pattern-list)
1285 1331 Matches zero or more occurrences of the specified
1286 1332 patterns.
1287 1333
1288 1334
1289 1335 +(pattern-list)
1290 1336 Matches one or more occurrences of the specified
1291 1337 patterns.
1292 1338
1293 1339
1294 1340 {n(pattern-list)
1295 1341 Matches n occurrences of the specified patterns.
1296 1342
1297 1343
1298 1344 {m,n(pattern-list)
1299 1345 Matches from m to n occurrences of the specified
1300 1346 patterns. If m is omitted, 0 is used. If n is
1301 1347 omitted at least m occurrences are matched.
1302 1348
1303 1349
1304 1350 @(pattern-list)
1305 1351 Matches exactly one of the specified patterns.
1306 1352
1307 1353
1308 1354 !(pattern-list)
1309 1355 Matches anything except one of the specified
1310 1356 patterns.
1311 1357
1312 1358
1313 1359
1314 1360 By default, each pattern, or sub-pattern matches the longest string
1315 1361 possible consistent with generating the longest overall match. If more
1316 1362 than one match is possible, the one starting closest to the beginning
1317 1363 of the string is chosen. However, for each of the compound patterns a
1318 1364 - can be inserted in front of the ( to cause the shortest match to the
1319 1365 specified pattern-list to be used.
1320 1366
1321 1367
1322 1368 When pattern-list is contained within parentheses, the backslash
1323 1369 character \ is treated specially even when inside a character class.
1324 1370 All ANSI-C character escapes are recognized and match the specified
1325 1371 character. In addition the following escape sequences are recognized:
1326 1372
1327 1373 \d
1328 1374 Matches any character in the digit class.
1329 1375
1330 1376
1331 1377 \D
1332 1378 Matches any character not in the digit class.
1333 1379
1334 1380
1335 1381 \s
1336 1382 Matches any character in the space class.
1337 1383
1338 1384
1339 1385 \S
1340 1386 Matches any character not in the space class.
1341 1387
1342 1388
1343 1389 \w
1344 1390 Matches any character in the word class.
1345 1391
1346 1392
1347 1393 \W
1348 1394 Matches any character not in the word class.
1349 1395
1350 1396
1351 1397
1352 1398 A pattern of the form %(pattern-pairs) is a sub-pattern that can be
1353 1399 used to match nested character expressions. Each pattern-pair is a two
1354 1400 character sequence which cannot contain & or |. The first pattern-pair
1355 1401 specifies the starting and ending characters for the match. Each
1356 1402 subsequent pattern-pair represents the beginning and ending characters
1357 1403 of a nested group that is skipped over when counting starting and
1358 1404 ending character matches. The behavior is unspecified when the first
1359 1405 character of a pattern-pair is alphanumeric except for the following:
1360 1406
1361 1407 D
1362 1408 Causes the ending character to terminate the search for this
1363 1409 pattern without finding a match.
1364 1410
1365 1411
1366 1412 E
1367 1413 Causes the ending character to be interpreted as an escape
1368 1414 character.
1369 1415
1370 1416
1371 1417 L
1372 1418 Causes the ending character to be interpreted as a quote character
1373 1419 causing all characters to be ignored when looking for a match.
1374 1420
1375 1421
1376 1422 Q
1377 1423 Causes the ending character to be interpreted as a quote character
1378 1424 causing all characters other than any escape character to be
1379 1425 ignored when looking for a match.
1380 1426
1381 1427
1382 1428
1383 1429 %({}Q"E\), matches characters starting at { until the matching } is
1384 1430 found not counting any { or } that is inside a double quoted string or
1385 1431 preceded by the escape character \. Without the {} this pattern matches
1386 1432 any C language string.
1387 1433
↓ open down ↓ |
119 lines elided |
↑ open up ↑ |
1388 1434
1389 1435 Each sub-pattern in a composite pattern is numbered, starting at 1, by
1390 1436 the location of the ( within the pattern. The sequence \n, where n is a
1391 1437 single digit and \n comes after the nth. sub-pattern, matches the same
1392 1438 string as the sub-pattern itself.
1393 1439
1394 1440
1395 1441 A pattern can contain sub-patterns of the form ~(options:pattern-list),
1396 1442 where either options or :pattern-list can be omitted. Unlike the other
1397 1443 compound patterns, these sub-patterns are not counted in the numbered
1398 - sub-patterns. If options is present, it can consist of one or more of
1399 - the following:
1444 + sub-patterns. :pattern-list must be omitted for options F, G, N and V
1445 + below. If options is present, it can consist of one or more of the
1446 + following:
1400 1447
1401 1448 +
1402 1449 Enable the following options. This is the default.
1403 1450
1404 1451
1405 1452 -
1406 1453 Disable the following options.
1407 1454
1408 1455
1409 1456 E
1410 1457 The remainder of the pattern uses extended regular expression
1411 1458 syntax like the egrep(1) command.
1412 1459
1413 1460
1414 1461 F
1415 1462 The remainder of the pattern uses fgrep(1) expression syntax.
1416 1463
1417 1464
1418 1465 g
1419 1466 File the longest match (greedy).
1420 1467
1421 1468 This is the default.
1422 1469
1423 1470
1424 1471 G
1425 1472 The remainder of the pattern uses basic regular expression syntax
1426 1473 like the grep(1) command.
1427 1474
1428 1475
1429 1476 i
1430 1477 Treat the match as case insensitive.
1431 1478
1432 1479
1433 1480 K
1434 1481 The remainder of the pattern uses shell pattern syntax.
1435 1482
1436 1483 This is the default.
1437 1484
1438 1485
1439 1486 l
1440 1487 Left anchor the pattern.
1441 1488
1442 1489 This is the default for K style patterns.
1443 1490
1444 1491
1445 1492 N
1446 1493 This is ignored. However, when it is the first letter and is used
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
1447 1494 with file name generation, and no matches occur, the file pattern
1448 1495 expands to the empty string.
1449 1496
1450 1497
1451 1498 r
1452 1499 Right anchor the pattern.
1453 1500
1454 1501 This is the default for K style patterns.
1455 1502
1456 1503
1504 + X
1505 + The remainder of the pattern uses augmented regular expression
1506 + syntax.
1457 1507
1458 - If both options and :pattern-list are specified, then the options apply
1459 - only to pattern-list. Otherwise, these options remain in effect until
1460 - they are disabled by a subsequent ~(...) or at the end of the sub-
1461 - pattern containing ~(...).
1462 1508
1463 - Quoting
1464 - Each of the metacharacters listed in the Definitions has a special
1465 - meaning to the shell.
1509 + P
1510 + The remainder of the pattern uses perl(1) regular expression
1511 + syntax. Not all perl regular expression syntax is currently
1512 + implemented.
1466 1513
1467 - g
1468 - File the longest match (greedy). This is the default.
1469 1514
1515 + V
1516 + The remainder of the pattern uses System V regular expression
1517 + syntax.
1470 1518
1471 - i
1472 - Treat the match as case insensitive.
1473 1519
1474 1520
1475 -
1476 1521 If both options and :pattern-list are specified, then the options apply
1477 - only to pattern-list. Otherwise, the options remain in effect until
1522 + only to pattern-list. Otherwise, these options remain in effect until
1478 1523 they are disabled by a subsequent ~(...) or at the end of the sub-
1479 1524 pattern containing ~(...).
1480 1525
1481 -
1526 + Quoting
1482 1527 Each of the metacharacters listed in the Definitions section of this
1483 1528 manual page has a special meaning to the shell and causes termination
1484 1529 of a word unless quoted. A character can be quoted, that is, made to
1485 1530 stand for itself, by preceding it with a backslash (\). The pair
1486 1531 \NEWLINE is removed. All characters enclosed between a pair of single
1487 1532 quote marks ('') that is not preceded by a $ are quoted. A single quote
1488 1533 cannot appear within the single quotes. A single quoted string preceded
1489 1534 by an unquoted $ is processed as an ANSI-C string except for the
1490 1535 following:
1491 1536
1492 1537 \0
1493 1538 Causes the remainder of the string to be ignored.
1494 1539
1495 1540
1496 1541 \cx
1497 1542 Expands to the character CTRL-x.
1498 1543
1499 1544
1500 1545 \C[.name.]
1501 1546 Expands to the collating element name.
1502 1547
1503 1548
1504 1549 \e
1505 1550 Equivalent to the escape character (ASCII 033),
1506 1551
1507 1552
1508 1553 \E
1509 1554 Equivalent to the escape character (ASCII 033),
1510 1555
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
1511 1556
1512 1557
1513 1558 Inside double quote marks (""), parameter and command substitution
1514 1559 occur and \ quotes the characters \, `, ", and $. A $ in front of a
1515 1560 double quoted string is ignored in the C or POSIX locale, and might
1516 1561 cause the string to be replaced by a locale specific string otherwise.
1517 1562 The meaning of $* and $@ is identical when not quoted or when used as a
1518 1563 variable assignment value or as a file name. However, when used as a
1519 1564 command argument, "$*" is equivalent to "$1d$2d...", where d is the
1520 1565 first character of the IFS variable, whereas "$@" is equivalent to "$1"
1521 - "$2" .... Inside grave quote marks (``), \fR quotes the characters \,
1522 - `, and $. If the grave quotes occur within double quotes, then \ also
1566 + "$2" .... Inside grave quote marks (``), \ quotes the characters \, `,
1567 + and $. If the grave quotes occur within double quotes, then \ also
1523 1568 quotes the character ".
1524 1569
1525 1570
1526 1571 The special meaning of reserved words or aliases can be removed by
1527 1572 quoting any character of the reserved word. The recognition of function
1528 1573 names or built-in command names cannot be altered by quoting them.
1529 1574
1530 1575 Arithmetic Evaluation
1531 1576 The shell performs arithmetic evaluation for arithmetic substitution,
1532 1577 to evaluate an arithmetic command, to evaluate an indexed array
1533 1578 subscript, and to evaluate arguments to the built-in commands shift and
1534 1579 let. Arithmetic evaluation is also performed on argument operands of
1535 1580 the built-in command printf that correspond to numeric format
1536 1581 specifiers in the format operand. See printf(1). Evaluations are
1537 1582 performed using double precision floating point arithmetic or long
1538 1583 double precision floating point for systems that provide this data
1539 1584 type. Floating point constants follow the ANSI-C programming language
1540 - floating point conventions. Integer constants follow the ANSI-C
1541 - programming language integer constant conventions although only single
1542 - byte character constants are recognized and character casts are not
1543 - recognized. Constants can be of the form [base#]n where base is a
1544 - decimal number between two and sixty-four representing the arithmetic
1545 - base and n is a number in that base. The digits greater than 9 are
1546 - represented by the lower case letters, the upper case letters, @, and _
1547 - respectively. For bases less than or equal to 36, upper and lower case
1548 - characters can be used interchangeably.
1585 + floating point conventions. The floating point constants Nan and Inf
1586 + can be used to represent "not a number" and infinity respectively.
1587 + Integer constants follow the ANSI-C programming language integer
1588 + constant conventions although only single byte character constants are
1589 + recognized and character casts are not recognized. Constants can be of
1590 + the form [base#]n where base is a decimal number between two and sixty-
1591 + four representing the arithmetic base and n is a number in that base.
1592 + The digits greater than 9 are represented by the lower case letters,
1593 + the upper case letters, @, and _ respectively. For bases less than or
1594 + equal to 36, upper and lower case characters can be used
1595 + interchangeably.
1549 1596
1550 1597
1551 1598 An arithmetic expression uses the same syntax, precedence, and
1552 1599 associativity of expression as the C language. All the C language
1553 1600 operators that apply to floating point quantities can be used. In
1554 1601 addition, the operator ** can be used for exponentiation. It has higher
1555 1602 precedence than multiplication and is left associative. When the value
1556 1603 of an arithmetic variable or subexpression can be represented as a long
1557 1604 integer, all C language integer arithmetic operations can be performed.
1558 1605 Variables can be referenced by name within an arithmetic expression
1559 1606 without using the parameter expansion syntax. When a variable is
1560 1607 referenced, its value is evaluated as an arithmetic expression.
1561 1608
1562 1609
1563 1610 Any of the following math library functions that are in the C math
1564 1611 library can be used within an arithmetic expression:
1565 1612
1566 - abs acos acosh asin asinh atan atan2 atanh cbrt
1567 - copysign cos cosh erf erfc exp exp2 expm1 fabs
1568 - fdim finite floor fma fmax fmod hypot ilogb
1569 - int isinf isnan lgamma log log2 logb
1570 - nearbyint nextafter nexttoward pow remainder
1571 - rint round sin sinh sqrt tan tanh tgamma trunc
1613 + rint round sin sinh sqrt tan tanh tgamma trunc abs acos
1614 + acosh asin asinh atan atan2 atanh cbrt ceil copysign cos
1615 + cosh erf erfc exp exp2 expm1 fabs fpclassify fdim finite
1616 + floor fma fmax fmin fmod hypot ilogb int isfinite sinf isnan
1617 + isnormal issubnormal issubor- dered iszero j0 j1 jn lgamma
1618 + log log10 log2 logb nearbyint nextafter nexttoward pow
1619 + remainder rint round scanb signbit sin sinh sqrt tan tanh
1620 + tgamma trunc y0 y1 yn
1572 1621
1573 1622
1574 1623
1575 1624
1625 + In addition, arithmetic functions can be defined as shell functions
1626 + with a variant of the function name syntax:
1627 +
1628 + function .sh.math.name ident ... { list ;}
1629 + where name is the function name used in the arithmetic expression
1630 + and each identified ident is a name reference to the long double
1631 + precision floating point argument. The value of .sh.value when the
1632 + function returns is the value of this function. User defined
1633 + functions can take up to 3 arguments and override C math library
1634 + functions.
1635 +
1636 +
1637 +
1576 1638 An internal representation of a variable as a double precision floating
1577 - point can be specified with the -E [n] or -F [n] option of the typeset
1578 - special built-in command. The -E option causes the expansion of the
1579 - value to be represented using scientific notation when it is expanded.
1580 - The optional option argument n defines the number of significant
1581 - figures. The -F option causes the expansion to be represented as a
1582 - floating decimal number when it is expanded. The optional option
1583 - argument n defines the number of places after the decimal point in this
1584 - case.
1639 + point can be specified with the -E [n], -F [n], or -X [n] options of
1640 + the typeset special built-in command. The -E option causes the
1641 + expansion of the value to be represented using scientific notation when
1642 + it is expanded. The optional option argument n defines the number of
1643 + significant figures. The -F option causes the expansion to be
1644 + represented as a floating decimal number when it is expanded. The
1645 + optional option argument n defines the number of places after the
1646 + decimal point in this case. The -X option causes the expansion to be
1647 + represented using the %a format defined by ISO C-99. The optional
1648 + option argument n defines the number of places after the decimal (or
1649 + radix) point in this case.
1585 1650
1586 1651
1652 +
1587 1653 An internal integer representation of a variable can be specified with
1588 1654 the -i [n] option of the typeset special built-in command. The optional
1589 1655 option argument n specifies an arithmetic base to be used when
1590 1656 expanding the variable. If you do not specify an arithmetic base, base
1591 1657 10 is used.
1592 1658
1593 1659
1594 1660 Arithmetic evaluation is performed on the value of each assignment to a
1595 - variable with the -E, -F, or -i option. Assigning a floating point
1661 + variable with the -E, -F, -X or -i option. Assigning a floating point
1596 1662 number to a variable whose type is an integer causes the fractional
1597 1663 part to be truncated.
1598 1664
1599 1665 Prompting
1600 1666 When used interactively, the shell prompts with the value of PS1 after
1601 1667 expanding it for parameter expansion, command substitution, and
1602 1668 arithmetic substitution, before reading a command. In addition, each
1603 1669 single ! in the prompt is replaced by the command number. A !! is
1604 1670 required to place ! in the prompt. If at any time a NEWLINE is typed
1605 1671 and further input is needed to complete a command, then the secondary
1606 1672 prompt, that is, the value of PS2, is issued.
1607 1673
1608 1674 Conditional Expressions
1609 1675 A conditional expression is used with the [[ compound command to test
1610 1676 attributes of files and to compare strings. Field splitting and file
1611 1677 name generation are not performed on the words between [[ and ]].
1612 1678
1613 1679
1614 1680 Each expression can be constructed from one or more of the following
1615 1681 unary or binary expressions:
1616 1682
1617 1683 -a file
1618 1684 True, if file exists.
1619 1685
1620 1686 This option is the same as -e. This option is
1621 1687 obsolete.
1622 1688
1623 1689
1624 1690 -b file
1625 1691 True, if file exists and is a block special file.
1626 1692
1627 1693
1628 1694 -c file
1629 1695 True, if file exists and is a character special
1630 1696 file.
1631 1697
1632 1698
1633 1699 -d file
1634 1700 True, if file exists and is a directory.
1635 1701
1636 1702
1637 1703 -e file
1638 1704 True, if file exists.
1639 1705
1640 1706
1641 1707 -f file
1642 1708 True, if file exists and is an ordinary file.
1643 1709
1644 1710
1645 1711 -g file
1646 1712 True, if file exists and it has its setgid bit
1647 1713 set.
1648 1714
1649 1715
1650 1716 -G file
1651 1717 True, if file exists and its group matches the
1652 1718 effective group id of this process.
1653 1719
1654 1720
1655 1721 -h file
1656 1722 True, if file exists and is a symbolic link.
1657 1723
1658 1724
1659 1725 -k file
1660 1726 True, if file exists and it has its sticky bit
1661 1727 set.
1662 1728
1663 1729
1664 1730 -L file
1665 1731 True, if file exists and is a symbolic link.
1666 1732
1667 1733
1668 1734 -n string
1669 1735 True, if length of string is non-zero.
1670 1736
1671 1737
1672 1738 -N file
1673 1739 True, if file exists and the modification time is
1674 1740 greater than the last access time.
1675 1741
1676 1742
1677 1743 -o option
1678 1744 True, if option named option is on.
1679 1745
1680 1746
1681 1747 -o ?option
1682 1748 True, if option named option is a valid option
1683 1749 name.
1684 1750
1685 1751
1686 1752 -O file
1687 1753 True, if file exists and is owned by the effective
1688 1754 user id of this process.
1689 1755
1690 1756
↓ open down ↓ |
85 lines elided |
↑ open up ↑ |
1691 1757 -p file
1692 1758 True, if file exists and is a FIFO special file or
1693 1759 a pipe.
1694 1760
1695 1761
1696 1762 -r file
1697 1763 True, if file exists and is readable by current
1698 1764 process.
1699 1765
1700 1766
1767 + -R name
1768 + True if variable name is a name reference.
1769 +
1770 +
1701 1771 -s file
1702 1772 True, if file exists and has size greater than
1703 1773 zero.
1704 1774
1705 1775
1706 1776 -S file
1707 1777 True, if file exists and is a socket.
1708 1778
1709 1779
1710 1780 -t fildes
1711 1781 True, if file descriptor number fildes is open and
1712 1782 associated with a terminal device.
1713 1783
1714 1784
1715 1785 -u file
1716 1786 True, if file exists and it has its setuid bit
1717 1787 set.
1718 1788
1719 1789
1790 + -v name
1791 + True, if variable name is a valid variable name
1792 + and is set.
1793 +
1794 +
1720 1795 -w file
1721 1796 True, if file exists and is writable by current
1722 1797 process.
1723 1798
1724 1799
1725 1800 -x file
1726 1801 True, if file exists and is executable by current
1727 1802 process. If file exists and is a directory, then
1728 1803 true if the current process has permission to
1729 1804 search in the directory.
1730 1805
1731 1806
1732 1807 -z string
1733 1808 True, if length of string is zero.
1734 1809
1735 1810
1736 1811 file1 -ef file2
1737 1812 True, if file1 and file2 exist and refer to the
1738 1813 same file.
1739 1814
1740 1815
1741 1816 file1 -nt file2
1742 1817 True, if file1 exists and file2 does not, or file1
1743 1818 is newer than file2.
1744 1819
1745 1820
1746 1821 file1 -ot file2
1747 1822 True, if file2 exists and file1 does not, or file1
1748 1823 is older than file2.
1749 1824
1750 1825
1751 1826 string
1752 1827 True, if string is not null.
1753 1828
1754 1829
1755 1830 string == pattern
1756 1831 True, if string matches pattern. Any part of
1757 1832 pattern can be quoted to cause it to be matched as
1758 1833 a string. With a successful match to pattern, the
1759 1834 .sh.match array variable contains the match and
1760 1835 sub-pattern matches.
1761 1836
1762 1837
1763 1838 string = pattern
1764 1839 Same as ==, but is obsolete.
1765 1840
1766 1841
1767 1842 string != pattern
1768 1843 True, if string does not match pattern. When the
1769 1844 string matches the pattern the .sh.match array
1770 1845 variable contains the match and sub-pattern
1771 1846 matches.
1772 1847
1773 1848
1774 1849 string =~ ere
1775 1850 True if string matches the pattern ~(E)ere where
1776 1851 ere is an extended regular expression.
1777 1852
1778 1853
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
1779 1854 string1 < string2
1780 1855 True, if string1 comes before string2 based on
1781 1856 ASCII value of their characters.
1782 1857
1783 1858
1784 1859 string1 > string2
1785 1860 True, if string1 comes after string2 based on
1786 1861 ASCII value of their characters.
1787 1862
1788 1863
1789 -
1790 - In each of the following expressions, if file is of the form /dev/fd/n,
1864 + In each of the above expressions, if file is of the form /dev/fd/n,
1791 1865 where n is an integer, the test is applied to the open file whose
1792 - descriptor number is n. The following obsolete arithmetic comparisons
1793 - are supported:
1866 + descriptor number is n.
1794 1867
1868 +
1869 + The following obsolete arithmetic comparisons are also supported:
1870 +
1795 1871 exp1 -eq exp2
1796 1872 True, if exp1 is equal to exp2.
1797 1873
1798 1874
1799 1875 exp1 -ge exp2
1800 1876 True, if exp1 is greater than or equal to exp2.
1801 1877
1802 1878
1803 1879 exp1 -gt exp2
1804 1880 True, if exp1 is greater than exp2.
1805 1881
1806 1882
1807 1883 exp1 -le exp2
1808 1884 True, if exp1 is less than or equal to exp2.
1809 1885
1810 1886
1811 1887 exp1 -lt exp2
1812 1888 True, if exp1 is less than exp2.
1813 1889
1814 1890
1815 1891 exp1 -ne exp2
1816 1892 True, if exp1 is not equal to exp2.
1817 1893
1818 1894
1819 1895
1820 1896 A compound expression can be constructed from these primitives by using
1821 1897 any of the following, listed in decreasing order of precedence:
1822 1898
1823 1899 (expression)
1824 1900 True, if expression is true. Used to
1825 1901 group expressions.
1826 1902
1827 1903
1828 1904 ! expression
1829 1905 True, if expression is false.
1830 1906
1831 1907
1832 1908 expression1 && expression2
1833 1909 True, if expression1 and expression2 are
1834 1910 both true.
1835 1911
1836 1912
1837 1913 expression1 || expression2
1838 1914 True, if either expression1 or
1839 1915 expression2 is true.
1840 1916
1841 1917
1842 1918 Input and Output
1843 1919 Before a command is executed, its input and output can be redirected
1844 1920 using a special notation interpreted by the shell. The following can
1845 1921 appear anywhere in a simple command or can precede or follow a command
1846 1922 and are not passed on to the invoked command. Command substitution,
1847 1923 parameter expansion, and arithmetic substitution occur before word or
1848 1924 digit is used except as noted in this section. File name generation
1849 1925 occurs only if the shell is interactive and the pattern matches a
1850 1926 single file. Field splitting is not performed.
1851 1927
1852 1928
1853 1929 In each of the following redirections, if file is of the form
1854 1930 /dev/sctp/host/port, /dev/tcp/host/port, or /dev/udp/host/port, where
1855 1931 host is a hostname or host address, and port is a service specified by
1856 1932 name or an integer port number, then the redirection attempts to make a
1857 1933 tcp, sctp or udp connection to the corresponding socket.
1858 1934
1859 1935
1860 1936 No intervening space is allowed between the characters of redirection
1861 1937 operators.
1862 1938
1863 1939 <word
1864 1940 Use file word as standard input (file descriptor 0).
1865 1941
1866 1942
1867 1943 >word
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
1868 1944 Use file word as standard output (file descriptor 1). If
1869 1945 the file does not exist then it is created. If the file
1870 1946 exists, and the noclobber option is on, this causes an
1871 1947 error. Otherwise, it is truncated to zero length.
1872 1948
1873 1949
1874 1950 >|word
1875 1951 Same as >, except that it overrides the noclobber option.
1876 1952
1877 1953
1954 + >;word
1955 + Write output to a temporary file. If the command
1956 + completes successfully rename it to word, otherwise,
1957 + delete the temporary file. >;word cannot be used with
1958 + the exec(2) built-in.
1959 +
1960 +
1878 1961 >>word
1879 1962 Use file word as standard output. If the file exists,
1880 1963 then output is appended to it (by first seeking to the
1881 1964 end-of-file). Otherwise, the file is created.
1882 1965
1883 1966
1884 1967 <>word
1885 1968 Open file word for reading and writing as standard input.
1886 1969
1887 1970
1888 1971 <<[-]word
1889 1972 The shell input is read up to a line that is the same as
1890 1973 word after any quoting has been removed, or to an end-of-
1891 1974 file. No parameter substitution, command substitution,
1892 1975 arithmetic substitution or file name generation is
1893 1976 performed on word. The resulting document, called a here-
1894 1977 document, becomes the standard input. If any character of
1895 1978 word is quoted, then no interpretation is placed upon the
1896 1979 characters of the document. Otherwise, parameter
1897 1980 expansion, command substitution, and arithmetic
1898 1981 substitution occur, \NEWLINE is ignored, and \ must be
1899 1982 used to quote the characters \, $, `. If - is appended to
1900 1983 <<, then all leading tabs are stripped from word and from
1901 1984 the document. If # is appended to <<, then leading SPACEs
1902 1985 and TABs are stripped off the first line of the document
1903 1986 and up to an equivalent indentation is stripped from the
1904 1987 remaining lines and from word. A tab stop is assumed to
1905 1988 occur at every 8 columns for the purposes of determining
1906 1989 the indentation.
1907 1990
1908 1991
1909 1992 <<<word
1910 1993 A short form of here document in which word becomes the
1911 1994 contents of the here-document after any parameter
1912 1995 expansion, command substitution, and arithmetic
1913 1996 substitution occur.
1914 1997
1915 1998
1916 1999 <&digit
1917 2000 The standard input is duplicated from file descriptor
1918 2001 digit, and similarly for the standard output using
1919 2002 >&digit. See dup(2).
1920 2003
1921 2004
1922 2005 <&digit-
1923 2006 The file descriptor specified by digit is moved to
1924 2007 standard input. Similarly for the standard output using
1925 2008 >&digit-.
1926 2009
1927 2010
1928 2011 <&-
1929 2012 The standard input is closed. Similarly for the standard
1930 2013 output using >&-.
1931 2014
1932 2015
1933 2016 <&p
1934 2017 The input from the co-process is moved to standard input.
1935 2018
1936 2019
1937 2020 >&p
1938 2021 The output to the co-process is moved to standard output.
1939 2022
1940 2023
1941 2024 <#((expr))
1942 2025 Evaluate arithmetic expression expr and position file
1943 2026 descriptor 0 to the resulting value bytes from the start
1944 2027 of the file. The variables CUR and EOF evaluate to the
1945 2028 current offset and end-of-file offset respectively when
1946 2029 evaluating expr.
1947 2030
1948 2031
1949 2032 >#((expr))
1950 2033 The same as <# except applies to file descriptor 1.
1951 2034
1952 2035
1953 2036 <#pattern
1954 2037 Seek forward to the beginning of the next line containing
1955 2038 pattern.
1956 2039
1957 2040
1958 2041 <##pattern
1959 2042 The same as <#, except that the portion of the file that
1960 2043 is skipped is copied to standard output.
1961 2044
1962 2045
1963 2046
1964 2047 If one of the redirection operators is preceded by a digit, with no
1965 2048 intervening space, then the file descriptor number referred to is that
1966 2049 specified by the digit (instead of the default 0 or 1). If one of the
1967 2050 redirection operators other than >&- and the ># and <# forms, is
1968 2051 preceded by {varname} with no intervening space, then a file descriptor
1969 2052 number > 10 is selected by the shell and stored in the variable
1970 2053 varname. If >&- or the any of the ># and <# forms is preceded by
1971 2054 {varname} the value of varname defines the file descriptor to close or
1972 2055 position. For example:
1973 2056
1974 2057 ... 2>&1
1975 2058
1976 2059
1977 2060
1978 2061
1979 2062 means file descriptor 2 is to be opened for writing as a duplicate of
1980 2063 file descriptor 1 and
1981 2064
1982 2065 exec [n]<file
1983 2066
1984 2067
1985 2068
1986 2069
1987 2070 means open file for reading and store the file descriptor number in
1988 2071 variable n. The order in which redirections are specified is
1989 2072 significant. The shell evaluates each redirection in terms of the
1990 2073 (file_descriptor, file) association at the time of evaluation. For
1991 2074 example:
1992 2075
1993 2076 ... 1>fname 2>&1
1994 2077
1995 2078
1996 2079
1997 2080
1998 2081 first associates file descriptor 1 with file fname. It then associates
1999 2082 file descriptor 2 with the file associated with file descriptor 1, that
2000 2083 is, fname. If the order of redirections were reversed, file descriptor
2001 2084 2 would be associated with the terminal (assuming file descriptor 1 had
2002 2085 been) and then file descriptor 1 would be associated with file fname.
2003 2086 If a command is followed by & and job control is not active, the
2004 2087 default standard input for the command is the empty file /dev/null.
2005 2088 Otherwise, the environment for the execution of a command contains the
2006 2089 file descriptors of the invoking shell as modified by input and output
2007 2090 specifications.
2008 2091
2009 2092 Environment
2010 2093 The environment is a list of name-value pairs that is passed to an
2011 2094 executed program in the same way as a normal argument list. See
2012 2095 environ(5).
2013 2096
2014 2097
2015 2098 The names must be identifiers and the values are character strings. The
2016 2099 shell interacts with the environment in several ways. On invocation,
2017 2100 the shell scans the environment and creates a variable for each name
2018 2101 found, giving it the corresponding value and attributes and marking it
2019 2102 export. Executed commands inherit the environment. If the user modifies
2020 2103 the values of these variables or creates new ones, using the export or
2021 2104 typeset -x commands, they become part of the environment. The
2022 2105 environment seen by any executed command is thus composed of any name-
2023 2106 value pairs originally inherited by the shell, whose values can be
2024 2107 modified by the current shell, plus any additions which must be noted
2025 2108 in export or typeset -x commands. The environment for any simple-
2026 2109 command or function can be augmented by prefixing it with one or more
2027 2110 variable assignments. A variable assignment argument is a word of the
2028 2111 form identifier=value. Thus:
2029 2112
2030 2113 TERM=450 cmd args
2031 2114
2032 2115
2033 2116
2034 2117
2035 2118 and
2036 2119
2037 2120 (export TERM; TERM=450; cmd args)
2038 2121
2039 2122
2040 2123
2041 2124
2042 2125 are equivalent (as far as the execution of cmd is concerned except for
2043 2126 special built-in commands listed in the Built-Ins section, those that
2044 2127 are preceded with a dagger. If the obsolete -k option is set, all
2045 2128 variable assignment arguments are placed in the environment, even if
2046 2129 they occur after the command name.
2047 2130
2048 2131
2049 2132 The following example first prints a=b c and then c:
2050 2133
2051 2134 echo a=b c
2052 2135 set -k
2053 2136 echo a=b c
2054 2137
2055 2138
2056 2139
2057 2140
2058 2141 This feature is intended for use with scripts written for early
2059 2142 versions of the shell and its use in new scripts is strongly
2060 2143 discouraged.
2061 2144
2062 2145 Functions
2063 2146 For historical reasons, there are two ways to define functions, the
2064 2147 name() syntax and the function name syntax. These are described in the
2065 2148 Commands section of this manual page.
2066 2149
2067 2150
2068 2151 Shell functions are read in and stored internally. Alias names are
2069 2152 resolved when the function is read. Functions are executed like
2070 2153 commands with the arguments passed as positional parameters. See the
2071 2154 Execution section of this manual page for details.
2072 2155
2073 2156
2074 2157 Functions defined by the function name syntax and called by name
2075 2158 execute in the same process as the caller and share all files and
2076 2159 present working directory with the caller. Traps caught by the caller
2077 2160 are reset to their default action inside the function. A trap condition
2078 2161 that is not caught or ignored by the function causes the function to
2079 2162 terminate and the condition to be passed on to the caller. A trap on
2080 2163 EXIT set inside a function is executed in the environment of the caller
2081 2164 after the function completes. Ordinarily, variables are shared between
2082 2165 the calling program and the function. However, the typeset special
2083 2166 built-in command used within a function defines local variables whose
2084 2167 scope includes the current function. They can be passed to functions
2085 2168 that they call in the variable assignment list that precedes the call
2086 2169 or as arguments passed as name references. Errors within functions
2087 2170 return control to the caller.
2088 2171
2089 2172
2090 2173 Functions defined with the name() syntax and functions defined with the
2091 2174 function name syntax that are invoked with the . special built-in are
2092 2175 executed in the caller's environment and share all variables and traps
2093 2176 with the caller. Errors within these function executions cause the
2094 2177 script that contains them to abort.
2095 2178
2096 2179
2097 2180 The special built-in command return is used to return from function
2098 2181 calls.
2099 2182
2100 2183
2101 2184 Function names can be listed with the -f or +f option of the typeset
2102 2185 special built-in command. The text of functions, when available, is
2103 2186 also listed with -f. Functions can be undefined with the -f option of
2104 2187 the unset special built-in command.
2105 2188
2106 2189
2107 2190 Ordinarily, functions are unset when the shell executes a shell script.
2108 2191 Functions that need to be defined across separate invocations of the
2109 2192 shell should be placed in a directory and the FPATH variable should
2110 2193 contain the name of this directory. They can also be specified in the
2111 2194 ENV file.
2112 2195
2113 2196 Discipline Functions
2114 2197 Each variable can have zero or more discipline functions associated
2115 2198 with it. The shell initially understands the discipline names get,
2116 2199 set, append, and unset but on most systems others can be added at run
2117 2200 time via the C programming interface extension provided by the builtin
2118 2201 built-in utility. If the get discipline is defined for a variable, it
2119 2202 is invoked whenever the specified variable is referenced. If the
2120 2203 variable .sh.value is assigned a value inside the discipline function,
2121 2204 the referenced variable is evaluated to this value instead. If the set
2122 2205 discipline is defined for a variable, it is invoked whenever the
2123 2206 specified variable is assigned a value. If the append discipline is
2124 2207 defined for a variable, it is invoked whenever a value is appended to
2125 2208 the specified variable. The variable .sh.value is specified the value
2126 2209 of the variable before invoking the discipline, and the variable is
2127 2210 assigned the value of .sh.value after the discipline completes. If
↓ open down ↓ |
240 lines elided |
↑ open up ↑ |
2128 2211 .sh.value is unset inside the discipline, then that value is unchanged.
2129 2212 If the unset discipline is defined for a variable, it is invoked
2130 2213 whenever the specified variable is unset. The variable is not unset
2131 2214 unless it is unset explicitly from within this discipline function.
2132 2215
2133 2216
2134 2217 The variable .sh.name contains the name of the variable for which the
2135 2218 discipline function is called, .sh.subscript is the subscript of the
2136 2219 variable, and .sh.value contains the value being assigned inside the
2137 2220 set discipline function. For the set discipline, changing .sh.value
2138 - changes the value that gets assigned.
2221 + changes the value that gets assigned. The variable _ is a reference to
2222 + the variable including the subscript if any. For the set discipline,
2223 + changing .sh.value will change the value that gets assigned. Finally,
2224 + the expansion ${ var.name}, when name is the name of a discipline, and
2225 + there is no variable of this name, is equivalent to the command
2226 + substitution ${var.name;}.
2139 2227
2228 +
2229 + Name Spaces
2230 + Commands and functions that are executed as part of the list of a
2231 + namespace command that modify variables or create new ones, create a
2232 + new variable whose name is the name of the name space as given by
2233 + identifier preceded by two dots (..). When a variable whose name is
2234 + name is referenced, it is first searched for using .identifier.name.
2235 + Similarly, a function defined by a command in the namespace list is
2236 + created using the name space name preceded by two dots (..).
2237 +
2238 + When the list of a namespace command contains a namespace command, the
2239 + names of variables and functions that are created consist of the
2240 + variable or function name preceded by the list of identifiers each
2241 + preceded by two dots (..).
2242 +
2243 + Outside of a name space, a variable or function created inside a name
2244 + space can be referenced by preceding it with the name space name.
2245 +
2246 + By default, variables staring with .sh are in the sh name space.
2247 +
2248 +
2249 + Typed Variables
2250 + Typed variables provide a way to create data structure and objects. A
2251 + type can be defined either by a shared library, by the enum built-in
2252 + command described below, or by using the new -T option of the typeset
2253 + built-in command. With the -T option of typeset, the type name,
2254 + specified as an option argument to -T, is set with a compound variable
2255 + assignment that defines the type. Function definitions can appear
2256 + inside the compound variable assignment and these become discipline
2257 + functions for this type and can be invoked or redefined by each
2258 + instance of the type. The function name create is treated specially. It
2259 + is invoked for each instance of the type that is created but is not
2260 + inherited and cannot be redefined for each instance.
2261 +
2262 + When a type is defined a special built-in command of that name is
2263 + added. These built-ins are declaration commands and follow the same
2264 + expansion rules as all the special built-in commands defined below that
2265 + are preceded by a dot (.). These commands can subsequently be used
2266 + inside further type definitions. The man page for these commands can be
2267 + generated by using the --man option or any of the other -- options
2268 + described with getopts. The -r, -a, -A, -h and -S options of typeset
2269 + are permitted with each of these new built-ins.
2270 +
2271 + An instance of a type is created by invoking the type name followed by
2272 + one or more instance names. Each instance of the type is initialized
2273 + with a copy of the sub-variables except for sub-variables that are
2274 + defined with the -s option. Variables defined with -S are shared by all
2275 + instances of the type. Each instance can change the value of any sub-
2276 + variable and can also define new discipline functions of the same names
2277 + as those defined by the type definition as well as any standard
2278 + discipline names. No additional sub-variables can be defined for any
2279 + instance.
2280 +
2281 + When defining a type, if the value of a sub-variable is not set and the
2282 + -r attribute is specified, it causes the sub-variable to be a required
2283 + sub-variable. Whenever an instance of a type is created, all required
2284 + sub-variables must be specified. These sub-variables become readonly in
2285 + each instance.
2286 +
2287 + When unset is invoked on a sub-variable within a type, and the -r
2288 + attribute has not been specified for this field, the value is reset to
2289 + the default value associative with the type. Invoking unset on a type
2290 + instance not contained within another type deletes all sub-variables
2291 + and the variable itself.
2292 +
2293 + A type definition can be derived from another type definition by
2294 + defining the first sub-variable name as _ and defining its type as the
2295 + base type. Any remaining definitions will be additions and
2296 + modifications that apply to the new type. If the new type name is the
2297 + same is that of the base type, the type will be replaced and the
2298 + original type will no longer be accessible.
2299 +
2300 + The typeset command with -T and no option argument or operands will
2301 + write all the type definitions to standard output in a form that that
2302 + can be read in to create all the types.
2303 +
2304 +
2140 2305 Jobs
2141 2306 If the monitor option of the set command is turned on, an interactive
2142 2307 shell associates a job with each pipeline. It keeps a table of current
2143 2308 jobs, printed by the jobs command, and assigns them small integer
2144 2309 numbers. When a job is started asynchronously with &, the shell prints
2145 2310 a line which looks like:
2146 2311
2147 2312 [1] 1234
2148 2313
2149 2314
2150 2315
2151 2316
2152 2317 indicating that the job which was started asynchronously was job number
2153 2318 1 and had one (top-level) process, whose process id was 1234.
2154 2319
2155 2320
2156 2321 If you are running a job and wish to stop it, CTRL-z sends a STOP
2157 2322 signal to the current job. The shell normally displays a message that
2158 2323 the job has been stopped, and displays another prompt. You can then
2159 2324 manipulate the state of this job, putting it in the background with the
2160 2325 bg command, or run some other commands and then eventually bring the
2161 2326 job back into the foreground with the foreground command fg. A CTRL-z
2162 2327 takes effect immediately and is like an interrupt in that pending
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
2163 2328 output and unread input are discarded when it is typed.
2164 2329
2165 2330
2166 2331 A job being run in the background stops if it tries to read from the
2167 2332 terminal. Background jobs are normally allowed to produce output, but
2168 2333 this can be disabled by giving the command sttytostop. If you set this
2169 2334 tty option, then background jobs stop when they try to produce output
2170 2335 like they do when they try to read input.
2171 2336
2172 2337
2338 + A job pool is a collection of jobs started with list & associated with
2339 + a name.
2340 +
2341 +
2173 2342 There are several ways to refer to jobs in the shell. A job can be
2174 2343 referred to by the process id of any process of the job or by one of
2175 2344 the following:
2176 2345
2177 2346 %number
2178 2347 The job with the specified number.
2179 2348
2180 2349
2350 + pool
2351 + All the jobs in the job pool named by pool.
2352 +
2353 +
2354 + pool.number
2355 + The job number number in the pool named by pool.
2356 +
2357 +
2181 2358 %string
2182 2359 Any job whose command line begins with string.
2183 2360
2184 2361
2185 2362 %?string
2186 2363 Any job whose command line contains string.
2187 2364
2188 2365
2189 2366 %%
2190 2367 Current job.
2191 2368
2192 2369
2193 2370 %+
2194 2371 Equivalent to %%.
2195 2372
2196 2373
2197 2374 %-
2198 2375 Previous job.
2199 2376
2200 2377
2378 + In addition, unless noted otherwise, wherever a job can be specified,
2379 + the name of a background job pool can be used to represent all the jobs
2380 + in that pool.
2201 2381
2382 +
2383 +
2202 2384 The shell learns immediately whenever a process changes state. It
2203 2385 normally informs you whenever a job becomes blocked so that no further
2204 2386 progress is possible, but only just before it prints a prompt. This is
2205 2387 done so that it does not otherwise disturb your work. The notify option
2206 2388 of the set command causes the shell to print these job change messages
2207 2389 as soon as they occur.
2208 2390
2209 2391
2210 2392 When the monitor option is on, each background job that completes
2211 2393 triggers any trap set for CHLD.
2212 2394
2213 2395
2214 2396 When you try to leave the shell while jobs are running or stopped, you
2215 2397 are warned that You have stopped(running) jobs. You can use the jobs
2216 2398 command to see what they are. If you immediately try to exit again, the
2217 2399 shell does not warn you a second time, and the stopped jobs are
2218 2400 terminated. When a login shell receives a HUP signal, it sends a HUP
2219 2401 signal to each job that has not been disowned with the disown built-in
2220 2402 command.
2221 2403
2222 2404 Signals
2223 2405 The INT and QUIT signals for an invoked command are ignored if the
2224 2406 command is followed by & and the monitor option is not active.
2225 2407 Otherwise, signals have the values inherited by the shell from its
2226 2408 parent. See the trap built-in command.
2227 2409
2228 2410 Execution
2229 2411 Each time a command is read, the substitutions are carried out. If the
2230 2412 command name matches one of the ones in the Special Built-in Commands
2231 2413 section of this manual page, it is executed within the current shell
2232 2414 process. Next, the command name is checked to see if it matches a user
2233 2415 defined function. If it does, the positional parameters are saved and
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
2234 2416 then reset to the arguments of the function call. A function is also
2235 2417 executed in the current shell process. When the function completes or
2236 2418 issues a return, the positional parameter list is restored. For
2237 2419 functions defined with the function name syntax, any trap set on EXIT
2238 2420 within the function is executed. The exit value of a function is the
2239 2421 value of the last command executed. If a command name is not a special
2240 2422 built-in command or a user defined function, but it is one of the
2241 2423 built-in commands, it is executed in the current shell process.
2242 2424
2243 2425
2244 - The shell variable PATH defines the search path for the directory
2245 - containing the command. Alternative directory names are separated by a
2246 - colon (:). The default path is /bin:/usr/bin:, specifying /bin,
2247 - /usr/bin, and the current directory in that order. The current
2248 - directory can be specified by two or more adjacent colons, or by a
2249 - colon at the beginning or end of the path list. If the command name
2250 - contains a slash (/), the search path is not used. Otherwise, each
2251 - directory in the path is searched for an executable file of the
2252 - specified name that is not a directory. If found, and if the shell
2253 - determines that there is a built-in version of a command corresponding
2254 - to a specified pathname, this built-in is invoked in the current
2255 - process. If found, and this directory is also contained in the value of
2256 - the FPATH variable, then this file is loaded into the current shell
2426 + The shell variables PATH and FPATH define the search path for the
2427 + directory containing the command. Alternative directory names are
2428 + separated by a colon (:). The default path is /bin:/usr/bin:,
2429 + specifying /bin, /usr/bin, and the current directory in that order. The
2430 + current directory can be specified by two or more adjacent colons, or
2431 + by a colon at the beginning or end of the path list. If the command
2432 + name contains a slash (/), the search path is not used. Otherwise, each
2433 + directory in the list of directories defined by PATH and FPATH is
2434 + checked in order. If the directory being searched is contained in the
2435 + value of the FPATH variable and contains a file whose name matches the
2436 + command being searched, then this file is loaded into the current shell
2257 2437 environment as if it were the argument to the . command except that
2258 2438 only preset aliases are expanded, and a function of the specified name
2259 - is executed as described in this manual page. If not found, and the
2260 - file .paths is found, and this file contains a line of the form
2261 - FPATH=path where path is an existing directory, and this directory
2262 - contains a file of the specified name, then this file is loaded into
2263 - the current shell environment as if it were the argument to the .
2264 - special built-in command and a function of the specified name is
2265 - executed. Otherwise, if found, a process is created and an attempt is
2266 - made to execute the command using exec(2).
2439 + is executed as described in this manual page.
2267 2440
2268 2441
2269 - When an executable is found, the directory where it is found in is
2270 - searched for a file named .paths. If this file is found and it contains
2271 - a line of the form BUILTIN_LIB=value, the library named by value is
2272 - searched for as if it were an option argument to builtin -f, and if it
2273 - contains a built-in of the specified name this is executed instead of a
2274 - command by this name. Otherwise, if this file is found and it contains
2275 - a line of the form name=value in the first or second line, then the
2276 - environment variable name is modified by prepending the directory
2277 - specified by value to the directory list. If value is not an absolute
2278 - directory, then it specifies a directory relative to the directory that
2279 - the executable was found. If the environment variable name does not
2280 - already exist it is added to the environment list for the specified
2281 - command.
2442 + If this directory is not in FPATH, the shell first determines whether
2443 + there is a built-in version of a command corresponding to a given
2444 + pathname and, if so, it is invoked in the current process. If no built-
2445 + in is found, the shell checks for a file named .paths in this
2446 + directory. If found and there is a line of the form:
2282 2447
2448 + FPATH=path
2283 2449
2450 + where path is an existing directory, then that directory is searched
2451 + immediately after the current directory as if it were found in the
2452 + FPATH variable. If path does not begin with /, it is checked for
2453 + relative to the directory being searched.
2454 +
2455 +
2456 + The .paths file is then checked for a line of the form:
2457 +
2458 + PLUGIN_LIB=libname [ : libname ] ...
2459 +
2460 + Each library named by libname will be searched for as if it were an
2461 + option argument to builtin -f and, if it contains a built-in of the
2462 + specified name, this is executed instead of a command by this name.
2463 +
2464 +
2465 + Any built-in loaded from a library found this way will be associated
2466 + with the directory containing the .paths file so it will only execute
2467 + if not found in an earlier directory.
2468 +
2469 +
2470 + Finally, the directory will be checked for a file of the given name.
2284 2471 If the file has execute permission but is not an a.out file, it is
2285 2472 assumed to be a file containing shell commands. A separate shell is
2286 2473 spawned to read it. All non-exported variables are removed in this
2287 2474 case. If the shell command file doesn't have read permission, and/or if
2288 2475 the setuid and setgid bits are set on the file, then the shell executes
2289 2476 an agent whose job it is to set up the permissions and execute the
2290 - shell with the shell command file passed down as an open file. A
2291 - parenthesized command is executed in a sub-shell without removing non-
2292 - exported variables.
2477 + shell with the shell command file passed down as an open file.
2293 2478
2479 + If the .paths contains a line of the form:
2480 +
2481 + name=value
2482 +
2483 + in the first or second line, then the environment variable name is
2484 + modified by prepending the directory specified by value to the
2485 + directory list. If value is not an absolute directory, then it
2486 + specifies a directory relative to the directory in which the executable
2487 + was found. If the environment variable name does not already exist it
2488 + will be added to the environment list for the specified command.
2489 +
2490 + A parenthesized command is executed in a sub-shell without removing
2491 + non-exported variables.
2492 +
2493 +
2294 2494 Command Re-entry
2295 2495 The text of the last HISTSIZE (default 512) commands entered from a
2296 2496 terminal device is saved in a history file. The file $HOME/.sh_history
2297 2497 is used if the HISTFILE variable is not set or if the file it names is
2298 2498 not writable. A shell can access the commands of all interactive shells
2299 2499 which use the same named HISTFILE. The built-in command hist is used to
2300 2500 list or edit a portion of this file. The portion of the file to be
2301 2501 edited or listed can be selected by number or by giving the first
2302 2502 character or characters of the command. A single command or range of
2303 2503 commands can be specified. If you do not specify an editor program as
2304 2504 an argument to hist then the value of the variable HISTEDIT is used. If
2305 2505 HISTEDIT is unset, the obsolete variable FCEDIT is used. If FCEDIT is
2306 2506 not defined, then /bin/ed is used. The edited commands are printed and
2307 2507 executed again upon leaving the editor unless you quit without writing.
2308 2508 The -s option (and in obsolete versions, the editor name -) is used to
2309 2509 skip the editing phase and to re-execute the command. In this case a
2310 2510 substitution parameter of the form old=newcan be used to modify the
2311 2511 command before execution. For example, with the preset alias r, which
2312 2512 is aliased to 'hist -s', typing `r bad=good c' re-executes the most
2313 2513 recent command which starts with the letter c, replacing the first
2314 2514 occurrence of the string bad with the string good.
2315 2515
2316 2516 Inline Editing Options
2317 2517 Normally, each command line entered from a terminal device is simply
2318 2518 typed followed by a NEWLINE (RETURN or LINE FEED). If either the emacs,
2319 2519 gmacs, or vi option is active, the user can edit the command line. To
2320 2520 be in either of these edit modes set the corresponding option. An
2321 2521 editing option is automatically selected each time the VISUAL or EDITOR
2322 2522 variable is assigned a value ending in either of these option names.
2323 2523
2324 2524
2325 2525 The editing features require that the user's terminal accept RETURN as
2326 2526 carriage return without line feed and that a SPACE must overwrite the
2327 2527 current character on the screen.
2328 2528
2329 2529
2330 2530 Unless the multiline option is on, the editing modes implement a
2331 2531 concept where the user is looking through a window at the current line.
2332 2532 The window width is the value of COLUMNS if it is defined, otherwise
2333 2533 80. If the window width is too small to display the prompt and leave at
2334 2534 least 8 columns to enter input, the prompt is truncated from the left.
2335 2535 If the line is longer than the window width minus two, a mark is
2336 2536 displayed at the end of the window to notify the user. As the cursor
2337 2537 moves and reaches the window boundaries the window is centered about
2338 2538 the cursor. The mark is a > (<, *) if the line extends on the right ,
2339 2539 left, or both sides of the window.
2340 2540
2341 2541
2342 2542 The search commands in each edit mode provide access to the history
2343 2543 file. Only strings are matched, not patterns, although a leading ^ in
2344 2544 the string restricts the match to begin at the first character in the
2345 2545 line.
2346 2546
2347 2547
2348 2548 Each of the edit modes has an operation to list the files or commands
2349 2549 that match a partially entered word. When applied to the first word on
2350 2550 the line, or the first word after a ;, |, &, or (, and the word does
2351 2551 not begin with ~ or contain a /, the list of aliases, functions, and
2352 2552 executable commands defined by the PATH variable that could match the
2353 2553 partial word is displayed. Otherwise, the list of files that match the
2354 2554 specified word is displayed. If the partially entered word does not
2355 2555 contain any file expansion characters, a * is appended before
2356 2556 generating these lists. After displaying the generated list, the input
2357 2557 line is redrawn. These operations are called command name listing and
2358 2558 file name listing, respectively. There are additional operations,
2359 2559 referred to as command name completion and file name completion, which
2360 2560 compute the list of matching commands or files, but instead of printing
2361 2561 the list, replace the current word with a complete or partial match.
2362 2562 For file name completion, if the match is unique, a / is appended if
2363 2563 the file is a directory and a space is appended if the file is not a
2364 2564 directory. Otherwise, the longest common prefix for all the matching
2365 2565 files replaces the word. For command name completion, only the portion
2366 2566 of the file names after the last / are used to find the longest command
2367 2567 prefix. If only a single name matches this prefix, then the word is
2368 2568 replaced with the command name followed by a space. When using a TAB
2369 2569 for completion that does not yield a unique match, a subsequent TAB
2370 2570 provides a numbered list of matching alternatives. A specific selection
2371 2571 can be made by entering the selection number followed by a TAB.
2372 2572
2373 2573 Key Bindings
2374 2574 The KEYBD trap can be used to intercept keys as they are typed and
2375 2575 change the characters that are actually seen by the shell. This trap is
2376 2576 executed after each character (or sequence of characters when the first
2377 2577 character is ESC) is entered while reading from a terminal.
2378 2578
2379 2579
2380 2580 The variable .sh.edchar contains the character or character sequence
2381 2581 which generated the trap. Changing the value of .sh.edchar in the trap
2382 2582 action causes the shell to behave as if the new value were entered from
2383 2583 the keyboard rather than the original value. The variable .sh.edcol is
2384 2584 set to the input column number of the cursor at the time of the input.
2385 2585 The variable .sh.edmode is set to ESC when in vi insert mode and is
2386 2586 null otherwise. By prepending ${.sh.editmode} to a value assigned to
2387 2587 .sh.edchar it causes the shell to change to control mode if it is not
2388 2588 already in this mode.
2389 2589
2390 2590
2391 2591 This trap is not invoked for characters entered as arguments to editing
2392 2592 directives, or while reading input for a character search.
2393 2593
2394 2594 emacs Editing Mode
2395 2595 This mode is entered by enabling either the emacs or gmacs option. The
2396 2596 only difference between these two modes is the way they handle ^T. To
2397 2597 edit, the user moves the cursor to the point needing correction and
2398 2598 then inserts or deletes characters or words as needed. All the editing
2399 2599 commands are control characters or escape sequences. The notation for
2400 2600 control characters is caret (^) followed by the character.
2401 2601
2402 2602
2403 2603 For example, ^F is the notation for CTRL/F. This is entered by
2404 2604 depressing f while holding down the CTRL (control) key. The SHIFT key
2405 2605 is not depressed. (The notation ^? indicates the DEL (delete) key.)
2406 2606
2407 2607
2408 2608 The notation for escape sequences is M- followed by a character. For
2409 2609 example, M-f (pronounced Meta f) is entered by depressing ESC (ASCII
2410 2610 033) followed by f. M-F is the notation for ESC followed by F.
2411 2611
2412 2612
2413 2613 All edit commands operate from any place on the line, not just at the
2414 2614 beginning. The RETURN or the LINE FEED key is not entered after edit
2415 2615 commands except when noted.
2416 2616
2417 2617 ^F
2418 2618 Move the cursor forward (right) one character.
2419 2619
2420 2620
2421 2621 M-[C
2422 2622 Move the cursor forward (right) one character.
2423 2623
2424 2624
2425 2625 M-f
2426 2626 Move the cursor forward one word. The emacs editor's idea
2427 2627 of a word is a string of characters consisting of only
2428 2628 letters, digits and underscores.
2429 2629
2430 2630
2431 2631 ^B
2432 2632 Move the cursor backward (left) one character.
2433 2633
2434 2634
2435 2635 M-[D
2436 2636 Move the cursor backward (left) one character.
2437 2637
2438 2638
2439 2639 M-b
2440 2640 Move the cursor backward one word.
2441 2641
2442 2642
2443 2643 ^A
2444 2644 Move the cursor to the beginning of the line.
2445 2645
2446 2646
2447 2647 M-[H
2448 2648 Move the cursor to the beginning of the line.
2449 2649
2450 2650
2451 2651 ^E
2452 2652 Move the cursor to the end of the line.
2453 2653
2454 2654
2455 2655 M-[Y
2456 2656 Move the cursor to the end of line.
2457 2657
2458 2658
2459 2659 ^]char
2460 2660 Move the cursor forward to the character char on the
2461 2661 current line.
2462 2662
2463 2663
2464 2664 M-^]char
2465 2665 Move the cursor backwards to the character char on the
2466 2666 current line.
2467 2667
2468 2668
2469 2669 ^X^X
2470 2670 Interchange the cursor and the mark.
2471 2671
2472 2672
2473 2673 erase
2474 2674 Delete the previous character. The user-defined erase
2475 2675 character is defined by the stty(1) command, and is
2476 2676 usually ^H or #.
2477 2677
2478 2678
2479 2679 lnext
2480 2680 Removes the next character's editing features. The user-
2481 2681 defined literal next character is defined by the stty(1)
2482 2682 command, or is ^V if not defined.
2483 2683
2484 2684
2485 2685 ^D
2486 2686 Delete the current character.
2487 2687
2488 2688
2489 2689 M-d
2490 2690 Delete the current word.
2491 2691
2492 2692
2493 2693 M-^H
2494 2694 MetaBACKSPACE. Delete the previous word.
2495 2695
2496 2696
2497 2697 M-h
2498 2698 Delete the previous word.
2499 2699
2500 2700
2501 2701 M-^?
2502 2702 MetaDEL. Delete the previous word. If your interrupt
2503 2703 character is ^? (DEL, the default), this command does not
2504 2704 work.
2505 2705
2506 2706
2507 2707 ^T
2508 2708 Transpose the current character with the previous
2509 2709 character, and advance the cursor in emacs mode. Transpose
2510 2710 two previous characters in gmacs mode.
2511 2711
2512 2712
2513 2713 ^C
2514 2714 Capitalize the current character.
2515 2715
2516 2716
2517 2717 M-c
2518 2718 Capitalize the current word.
2519 2719
2520 2720
2521 2721 M-l
2522 2722 Change the current word to lower case.
2523 2723
2524 2724
2525 2725 ^K
2526 2726 Delete from the cursor to the end of the line. If preceded
2527 2727 by a numerical parameter whose value is less than the
2528 2728 current cursor position, delete from specified position up
2529 2729 to the cursor. If preceded by a numerical parameter whose
2530 2730 value is greater than the current cursor position, then
2531 2731 delete from cursor up to specified cursor position.
2532 2732
2533 2733
2534 2734 ^W
2535 2735 Kill from the cursor to the mark.
2536 2736
2537 2737
2538 2738 M-p
2539 2739 Push the region from the cursor to the mark on the stack.
2540 2740
2541 2741
2542 2742 kill
2543 2743 Kill the entire current line. The user-defined kill
2544 2744 character is defined by the stty(1) command, usually a ^G
2545 2745 or @. If two kill characters are entered in succession,
2546 2746 all kill characters from then on cause a line feed. This
2547 2747 is useful when using paper terminals.
2548 2748
2549 2749
2550 2750 ^Y
2551 2751 Restore the last item removed from line. Yank the item
2552 2752 back to the line.
2553 2753
2554 2754
2555 2755 ^L
2556 2756 Line feed and print the current line.
2557 2757
2558 2758
2559 2759 M-^L
2560 2760 Clear the screen.
2561 2761
2562 2762
2563 2763 ^@
2564 2764 Null character. Set mark.
2565 2765
2566 2766
2567 2767 M-space
2568 2768 MetaSPACE. Set the mark.
2569 2769
2570 2770
2571 2771 ^J
2572 2772 New line. Execute the current line.
2573 2773
2574 2774
2575 2775 ^M
2576 2776 Return. Execute the current line.
2577 2777
2578 2778
2579 2779 EOF
2580 2780 End-of-file character, normally ^D, is processed as an
2581 2781 end-of-file only if the current line is null.
2582 2782
2583 2783
2584 2784 ^P
2585 2785 Fetch the previous command. Each time ^P is entered the
2586 2786 previous command back in time is accessed. Moves back one
2587 2787 line when it is not on the first line of a multi-line
2588 2788 command.
2589 2789
2590 2790
2591 2791 M-[A
2592 2792 Equivalent to ^P.
2593 2793
2594 2794
2595 2795 M-<
2596 2796 Fetch the least recent (oldest) history line.
2597 2797
2598 2798
2599 2799 M->
2600 2800 Fetch the most recent (youngest) history line.
2601 2801
2602 2802
2603 2803 ^N
2604 2804 Fetch the next command line. Each time ^N is entered the
2605 2805 next command line forward in time is accessed.
2606 2806
2607 2807
2608 2808 M-[B
2609 2809 Equivalent to ^N.
2610 2810
2611 2811
2612 2812 ^Rstring
2613 2813 Reverse search history for a previous command line
2614 2814 containing string. If a parameter of zero is specified,
2615 2815 the search is forward. string is terminated by a RETURN or
2616 2816 NEWLINE. If string is preceded by a ^, the matched line
2617 2817 must begin with string. If string is omitted, then the
2618 2818 next command line containing the most recent string is
2619 2819 accessed. In this case a parameter of zero reverses the
2620 2820 direction of the search.
2621 2821
2622 2822
2623 2823 ^O
2624 2824 Operate. Execute the current line and fetch the next line
2625 2825 relative to current line from the history file.
2626 2826
2627 2827
2628 2828 M-digits
2629 2829 Escape. Define numeric parameter. The digits are taken as
2630 2830 a parameter to the next command. The commands that accept
2631 2831 a parameter are: ^F, ^B, ERASE, ^C, ^D, ^K, ^R, ^P, ^N,
2632 2832 ^], M-., M-, M-^], M-_, M-=, M-b, M-c, M-d, M-f, M-h, M-l,
2633 2833 and M-^H.
2634 2834
2635 2835
2636 2836 M-letter
2637 2837 Soft-key. Search the alias list for an alias by the name
2638 2838 letter. If an alias of letter is defined, insert its value
2639 2839 on the input queue. letter must not be one of the
2640 2840 metafunctions in this section.
2641 2841
2642 2842
2643 2843 M-[letter
2644 2844 Soft key. Search the alias list for an alias by the name
2645 2845 letter. If an alias of this name is defined, insert its
2646 2846 value on the input queue. This can be used to program
2647 2847 function keys on many terminals.
2648 2848
2649 2849
2650 2850 M-.
2651 2851 The last word of the previous command is inserted on the
2652 2852 line. If preceded by a numeric parameter, the value of
2653 2853 this parameter determines which word to insert rather than
2654 2854 the last word.
2655 2855
2656 2856
2657 2857 M-_
2658 2858 Same as M-..
2659 2859
2660 2860
2661 2861 M-*
2662 2862 Attempt filename generation on the current word. As
2663 2863 asterisk is appended if the word does not match any file
2664 2864 or contain any special pattern characters.
2665 2865
2666 2866
2667 2867 M-ESC
2668 2868 Command or file name completion as described in this
2669 2869 manual page.
2670 2870
2671 2871
2672 2872 ^ITAB
2673 2873 Attempts command or file name completion as described in
2674 2874 this manual page. If a partial completion occurs,
2675 2875 repeating this behaves as if M-= were entered. If no
2676 2876 match is found or entered after SPACE, a TAB is inserted.
2677 2877
2678 2878
2679 2879 M-=
2680 2880 If not preceded by a numeric parameter, generates the list
2681 2881 of matching commands or file names as described in this
2682 2882 manual page. Otherwise, the word under the cursor is
2683 2883 replaced by the item corresponding to the value of the
2684 2884 numeric parameter from the most recently generated command
2685 2885 or file list. If the cursor is not on a word, the word is
2686 2886 inserted instead.
2687 2887
2688 2888
2689 2889 ^U
2690 2890 Multiply parameter of next command by 4.
2691 2891
2692 2892
2693 2893 \
2694 2894 Escape the next character. Editing characters, the user's
2695 2895 erase, kill and interrupt (normally ^?) characters can be
2696 2896 entered in a command line or in a search string if
2697 2897 preceded by a \. The \ removes the next character's
2698 2898 editing features, if any.
2699 2899
2700 2900
2701 2901 M-^V
2702 2902 Display the version of the shell.
2703 2903
2704 2904
2705 2905 M-#
2706 2906 If the line does not begin with a #, a # is inserted at
2707 2907 the beginning of the line and after each NEWLINE, and the
2708 2908 line is entered. This causes a comment to be inserted in
2709 2909 the history file. If the line begins with a #, the # is
2710 2910 deleted and one # after each NEWLINE is also deleted.
2711 2911
2712 2912
2713 2913 vi Editing Mode
2714 2914 There are two typing modes. Initially, when you enter a command you are
2715 2915 in the input mode. To edit, the user enters control mode by typing ESC
2716 2916 (033) and moves the cursor to the point needing correction and then
2717 2917 inserts or deletes characters or words as needed. Most control commands
2718 2918 accept an optional repeat count prior to the command.
2719 2919
2720 2920
2721 2921 When in vi mode on most systems, canonical processing is initially
2722 2922 enabled and the command is echoed again if the speed is 1200 baud or
2723 2923 greater and it contains any control characters or less than one second
2724 2924 has elapsed since the prompt was printed. The ESC character terminates
2725 2925 canonical processing for the remainder of the command and the user can
2726 2926 then modify the command line. This scheme has the advantages of
2727 2927 canonical processing with the type-ahead echoing of raw mode.
2728 2928
2729 2929
2730 2930 If the option viraw is also set, the terminal is always have canonical
2731 2931 processing disabled. This mode is implicit for systems that do not
2732 2932 support two alternate end of line delimiters, and might be helpful for
2733 2933 certain terminals.
2734 2934
2735 2935 Input Edit Commands
2736 2936 By default the editor is in input mode.
2737 2937
2738 2938
2739 2939 The following input edit commands are supported:
2740 2940
2741 2941 ERASE
2742 2942 User defined erase character as defined by the stty command,
2743 2943 usually ^H or #. Delete previous character.
2744 2944
2745 2945
2746 2946 ^W
2747 2947 Delete the previous blank separated word. On some systems the
2748 2948 viraw option might be required for this to work.
2749 2949
2750 2950
2751 2951 EOF
2752 2952 As the first character of the line causes the shell to
2753 2953 terminate unless the ignoreeof option is set. Otherwise this
2754 2954 character is ignored.
2755 2955
2756 2956
2757 2957 lnext
2758 2958 User defined literal next character as defined by the stty(1)
2759 2959 or ^V if not defined. Removes the next character's editing
2760 2960 features, if any. On some systems the viraw option might be
2761 2961 required for this to work.
2762 2962
2763 2963
2764 2964 \
2765 2965 Escape the next ERASE or KILL character.
2766 2966
2767 2967
2768 2968 ^I TAB
2769 2969 Attempts command or file name completion as described in this
2770 2970 manual page and returns to input mode. If a partial
2771 2971 completion occurs, repeating this behaves as if = were
2772 2972 entered from control mode. If no match is found or entered
2773 2973 after SPACE, a TAB is inserted.
2774 2974
2775 2975
2776 2976 Motion Edit Commands
2777 2977 The motion edit commands move the cursor.
2778 2978
2779 2979
2780 2980 The following motion edit commands are supported:
2781 2981
2782 2982 [count]l
2783 2983 Move the cursor forward (right) one character.
2784 2984
2785 2985
2786 2986 [count][C
2787 2987 Move the cursor forward (right) one character.
2788 2988
2789 2989
2790 2990 [count]w
2791 2991 Move the cursor forward one alphanumeric word.
2792 2992
2793 2993
2794 2994 [count]W
2795 2995 Move the cursor to the beginning of the next word that
2796 2996 follows a blank.
2797 2997
2798 2998
2799 2999 [count]e
2800 3000 Move the cursor to the end of the word.
2801 3001
2802 3002
2803 3003 [count]E
2804 3004 Move the cursor to the end of the current blank delimited
2805 3005 word.
2806 3006
2807 3007
2808 3008 [count]h
2809 3009 Move the cursor backward (left) one character.
2810 3010
2811 3011
2812 3012 [count][D
2813 3013 Move the cursor backward (left) one character.
2814 3014
2815 3015
2816 3016 [count]b
2817 3017 Move the cursor backward one word.
2818 3018
2819 3019
2820 3020 [count]B
2821 3021 Move the cursor to the preceding blank separated word.
2822 3022
2823 3023
2824 3024 [count]|
2825 3025 Move the cursor to column count.
2826 3026
2827 3027
2828 3028 [count]fc
2829 3029 Find the next character c in the current line.
2830 3030
2831 3031
2832 3032 [count]Fc
2833 3033 Find the previous character c in the current line.
2834 3034
2835 3035
2836 3036 [count]tC
2837 3037 Equivalent to f followed by h.
2838 3038
2839 3039
2840 3040 [count]Tc
2841 3041 Equivalent to F followed by l.
2842 3042
2843 3043
2844 3044 [count];
2845 3045 Repeat count times the last single character find command:
2846 3046 f, F, t, or T.
2847 3047
2848 3048
2849 3049 [count],
2850 3050 Reverse the last single character find command count
2851 3051 times.
2852 3052
2853 3053
2854 3054 0
2855 3055 Move the cursor to the start of line.
2856 3056
2857 3057
2858 3058 ^
2859 3059 Move the cursor to start of line.
2860 3060
2861 3061
2862 3062 [H
2863 3063 Move the cursor to the first non-blank character in the
2864 3064 line.
2865 3065
2866 3066
2867 3067 $
2868 3068 Move the cursor to the end of the line.
2869 3069
2870 3070
2871 3071 [Y
2872 3072 Move the cursor to the end of the line.
2873 3073
2874 3074
2875 3075 %
2876 3076 Moves to balancing (, ), {, }, [, or ]. If cursor is not
2877 3077 on one of the characters described in this section, the
2878 3078 remainder of the line is searched for the first occurrence
2879 3079 of one of the characters first.
2880 3080
2881 3081
2882 3082 Search Edit Commands
2883 3083 The search edit commands access your command history.
2884 3084
2885 3085
2886 3086 The following search edit commands are supported:
2887 3087
2888 3088 [count]k
2889 3089 Fetch the previous command. Each time k is entered, the
2890 3090 previous command back in time is accessed.
2891 3091
2892 3092
2893 3093 [count]-
2894 3094 Fetch the previous command. Each time k is entered, the
2895 3095 previous command back in time is accessed.
2896 3096
2897 3097 Equivalent to k.
2898 3098
2899 3099
2900 3100 [count][A
2901 3101 Fetch the previous command. Each time k is entered, the
2902 3102 previous command back in time is accessed.
2903 3103
2904 3104 Equivalent to k.
2905 3105
2906 3106
2907 3107 [count]j
2908 3108 Fetch the next command. Each time j is entered, the next
2909 3109 command forward in time is accessed.
2910 3110
2911 3111
2912 3112 [count]+
2913 3113 Fetch the next command. Each time j is entered, the next
2914 3114 command forward in time is accessed.
2915 3115
2916 3116 Equivalent to j.
2917 3117
2918 3118
2919 3119 [count][B
2920 3120 Fetch the next command. Each time j is entered, the next
2921 3121 command forward in time is accessed.
2922 3122
2923 3123 Equivalent to j.
2924 3124
2925 3125
2926 3126 [count]G
2927 3127 Fetch command number count. The default is the least
2928 3128 recent history command.
2929 3129
2930 3130
2931 3131 /string
2932 3132 Search backward through history for a previous command
2933 3133 containing string. string is terminated by a RETURN or
2934 3134 NEWLINE. If string is preceded by a ^, the matched line
2935 3135 must begin with string. If string is null, the previous
2936 3136 string is used.
2937 3137
2938 3138
2939 3139 ?string
2940 3140 Search forward through history for a previous command
2941 3141 containing string. string is terminated by a RETURN or
2942 3142 NEWLINE. If string is preceded by a ^, the matched line
2943 3143 must begin with string. If string is null, the previous
2944 3144 string is used.
2945 3145
2946 3146 Same as / except that search is in the forward direction.
2947 3147
2948 3148
2949 3149 n
2950 3150 Search in the backwards direction for the next match of
2951 3151 the last pattern to / or ? commands.
2952 3152
2953 3153
2954 3154 N
2955 3155 Search in the forward direction for next match of the last
2956 3156 pattern to / or ?.
2957 3157
2958 3158
2959 3159 Text Modification Edit Commands
2960 3160 The following commands modify the line:
2961 3161
2962 3162 a
2963 3163 Enter input mode and enter text after the current
2964 3164 character.
2965 3165
2966 3166
2967 3167 A
2968 3168 Append text to the end of the line. Equivalent to
2969 3169 $a.
2970 3170
2971 3171
2972 3172 [count]cmotion
2973 3173 c[count]motion
2974 3174 Delete current character through the character that
2975 3175 motion would move the cursor to and enter input
2976 3176 mode. If motion is c, the entire line is deleted and
2977 3177 input mode entered.
2978 3178
2979 3179
2980 3180 C
2981 3181 Delete the current character through the end of line
2982 3182 and enter input mode. Equivalent to c$.
2983 3183
2984 3184
2985 3185 S
2986 3186 Equivalent to cc.
2987 3187
2988 3188
2989 3189 [count]s
2990 3190 Replace characters under the cursor in input mode.
2991 3191
2992 3192
2993 3193 D[count]dmotion
2994 3194 Delete the current character through the end of
2995 3195 line. Equivalent to d$.
2996 3196
2997 3197
2998 3198 d[count]motion
2999 3199 Delete current character through the character that
3000 3200 motion would move to. If motion is d , the entire
3001 3201 line is deleted.
3002 3202
3003 3203
3004 3204 i
3005 3205 Enter input mode and insert text before the current
3006 3206 character.
3007 3207
3008 3208
3009 3209 I
3010 3210 Insert text before the beginning of the line.
3011 3211 Equivalent to 0i.
3012 3212
3013 3213
3014 3214 [count]P
3015 3215 Place the previous text modification before the
3016 3216 cursor.
3017 3217
3018 3218
3019 3219 [count]p
3020 3220 Place the previous text modification after the
3021 3221 cursor.
3022 3222
3023 3223
3024 3224 R
3025 3225 Enter input mode and replace characters on the
3026 3226 screen with characters you type overlay fashion.
3027 3227
3028 3228
3029 3229 [count]rc
3030 3230 Replace the count characters starting at the current
3031 3231 cursor position with c, and advance the cursor.
3032 3232
3033 3233
3034 3234 [count]x
3035 3235 Delete current character.
3036 3236
3037 3237
3038 3238 [count]X
3039 3239 Delete preceding character.
3040 3240
3041 3241
3042 3242 [count].
3043 3243 Repeat the previous text modification command.
3044 3244
3045 3245
3046 3246 [count]~
3047 3247 Invert the case of the count characters starting at
3048 3248 the current cursor position and advance the cursor.
3049 3249
3050 3250
3051 3251 [count]_
3052 3252 Causes the count word of the previous command to be
3053 3253 appended and input mode entered. The last word is
3054 3254 used if count is omitted.
3055 3255
3056 3256
3057 3257 *
3058 3258 Causes an * to be appended to the current word and
3059 3259 file name generation attempted. If no match is
3060 3260 found, it rings the bell. Otherwise, the word is
3061 3261 replaced by the matching pattern and input mode is
3062 3262 entered.
3063 3263
3064 3264
3065 3265 \
3066 3266 Command or file name completion as described in this
3067 3267 manual page.
3068 3268
3069 3269
3070 3270 Other Edit Commands
3071 3271 The following miscellaneous edit commands are supported:
3072 3272
3073 3273 [count]ymotion
3074 3274 y[count]motion
3075 3275 Yank the current character through the character to
3076 3276 which motion would move the cursor. Put the yanked
3077 3277 characters in the delete buffer. The text and cursor
3078 3278 position are unchanged.
3079 3279
3080 3280
3081 3281 yy
3082 3282 Yank the current line.
3083 3283
3084 3284
3085 3285 Y
3086 3286 Yank the current line from the current cursor
3087 3287 location to the end of the line. Equivalent to y$.
3088 3288
3089 3289
3090 3290 u
3091 3291 Undo the last text modifying command.
3092 3292
3093 3293
3094 3294 U
3095 3295 Undo all the text modifying commands performed on
3096 3296 current line.
3097 3297
3098 3298
3099 3299 [count]V
3100 3300 Return the command :
3101 3301
3102 3302 hist -e ${VISUAL:-${EDITOR:-vi}} count
3103 3303
3104 3304
3105 3305 in the input buffer. If count is omitted, the current
3106 3306 line is used.
3107 3307
3108 3308
3109 3309 ^L
3110 3310 Line feed and print the current line. This command
3111 3311 only works in control mode.
3112 3312
3113 3313
3114 3314 ^J
3115 3315 New line. Execute the current line, regardless of
3116 3316 mode.
3117 3317
3118 3318
3119 3319 ^M
3120 3320 Return. Execute the current line, regardless of mode.
3121 3321
3122 3322
3123 3323 #
3124 3324 If the first character of the command is a # , delete
3125 3325 this # and each # that follows a NEWLINE.
3126 3326
3127 3327 Otherwise, send the line after inserting a # in front
3128 3328 of each line in the command.
3129 3329
3130 3330 This is command is useful for causing the current
3131 3331 line to be inserted in the history as a comment and
3132 3332 un-commenting previously commented commands in the
3133 3333 history file.
3134 3334
3135 3335
3136 3336 [count]=
3137 3337 If count is not specified, generate the list of
3138 3338 matching commands or file names as described in this
3139 3339 manual page.
3140 3340
3141 3341 Otherwise, replace the word at the current cursor
3142 3342 location with the count item from the most recently
3143 3343 generated command or file list. If the cursor is not
3144 3344 on a word, it is inserted after the current cursor
3145 3345 location.
3146 3346
3147 3347
3148 3348 @letter
3149 3349 Search your alias list for an alias by the name
3150 3350 letter. If an alias of this name is defined, insert
3151 3351 its value on the input queue for processing.
3152 3352
3153 3353
3154 3354 ^V
3155 3355 Display version of the shell.
3156 3356
3157 3357
3158 3358 Built-in Commands
3159 3359 The following simple-commands are executed in the shell process. Input
3160 3360 and output redirection is permitted. Unless otherwise indicated, the
3161 3361 output is written on file descriptor 1 and the exit status, when there
3162 3362 is no syntax error, is 0. Except for :, true, false, echo, newgrp, and
3163 3363 login, all built-in commands accept -- to indicate the end of options.
3164 3364 They also interpret the option --man as a request to display the manual
3165 3365 page onto standard error and -? as a help request which prints a usage
3166 3366 message on standard error.
3167 3367
3168 3368
3169 3369 Commands that are preceded by one or two ++ symbols are special built-
3170 3370 in commands and are treated specially in the following ways:
3171 3371
3172 3372 1. Variable assignment lists preceding the command remain in
3173 3373 effect when the command completes.
3174 3374
3175 3375 2. I/O redirections are processed after variable assignments.
3176 3376
3177 3377 3. Errors cause a script that contains them to abort.
3178 3378
3179 3379 4. They are not valid function names.
3180 3380
3181 3381 5. Words following a command preceded by ++ that are in the
3182 3382 format of a variable assignment are expanded with the same
3183 3383 rules as a variable assignment. This means that tilde
3184 3384 substitution is performed after the = sign and field
3185 3385 splitting and file name generation are not performed.
3186 3386
3187 3387 + : [arg ...]
3188 3388
3189 3389 The command only expands parameters.
3190 3390
3191 3391
3192 3392 + . name [arg ...]
3193 3393
3194 3394 If name is a function defined with the function name reserved word
3195 3395 syntax, the function is executed in the current environment (as if
3196 3396 it had been defined with the name() syntax.) Otherwise if name
3197 3397 refers to a file, the file is read in its entirety and the commands
3198 3398 are executed in the current shell environment. The search path
3199 3399 specified by PATH is used to find the directory containing the
3200 3400 file. If any arguments arg are specified, they become the
3201 3401 positional parameters while processing the . command and the
3202 3402 original positional parameters are restored upon completion.
3203 3403 Otherwise the positional parameters are unchanged. The exit status
3204 3404 is the exit status of the last command executed.
3205 3405
3206 3406
3207 3407 ++ alias [-ptx] [name[ =value]] ...
3208 3408
3209 3409 alias with no arguments prints the list of aliases in the form
3210 3410 name=value on standard output. The -p option causes the word alias
3211 3411 to be inserted before each one. When one or more arguments are
3212 3412 specified, an alias is defined for each name whose value is
3213 3413 specified. A trailing space in value causes the next word to be
3214 3414 checked for alias substitution. The obsolete -t option is used to
3215 3415 set and list tracked aliases. The value of a tracked alias is the
3216 3416 full pathname corresponding to the specified name. The value
3217 3417 becomes undefined when the value of PATH is reset but the alias
3218 3418 remains tracked. Without the -t option, for each name in the
3219 3419 argument list for which no value is specified, the name and value
3220 3420 of the alias is printed. The obsolete -x option has no effect. The
3221 3421 exit status is non-zero if a name is specified, but no value, and
3222 3422 no alias has been defined for the name.
3223 3423
3224 3424
3225 3425 bg [ job...]
3226 3426
3227 3427 This command is only on systems that support job control. Puts each
3228 3428 specified job into the background. The current job is put in the
3229 3429 background if job is not specified. See the Jobs section of this
3230 3430 manual page for a description of the format of job.
3231 3431
3232 3432
3233 3433 + break [n]
3234 3434
↓ open down ↓ |
931 lines elided |
↑ open up ↑ |
3235 3435 Exit from the enclosing for, while, until, or select loop, if any.
3236 3436 If n is specified, then break n levels.
3237 3437
3238 3438
3239 3439 builtin [-ds ] [-f file] [name ...]
3240 3440
3241 3441 If name is not specified, and no -f option is specified, the built-
3242 3442 ins are printed on standard output. The -s option prints only the
3243 3443 special built-ins. Otherwise, each name represents the pathname
3244 3444 whose basename is the name of the built-in. The entry point
3245 - function name is determined by prepending b to the built-in name.
3445 + function name is determined by prepending b_ to the built-in name.
3446 + A built-in specified by a pathname will only be executed when that
3447 + pathname would be found during the path search. Built-ins found in
3448 + libraries loaded via the .paths file will be associate with the
3449 + pathname of the directory containing the .paths file.
3450 +
3246 3451 The ISO C/C++ prototype is bmycommand(int argc, char *argv[], void
3247 3452 *context) for the built-in command mycommand where argv is an array
3248 3453 of argc elements and context is an optional pointer to a Shell_t
3249 3454 structure as described in <ast/shell.h> Special built-ins cannot be
3250 3455 bound to a pathname or deleted. The -d option deletes each of the
3251 3456 specified built-ins. On systems that support dynamic loading, the
3252 3457 -f option names a shared library containing the code for built-ins.
3253 3458 The shared library prefix and/or suffix, which depend on the
3254 3459 system, can be omitted. Once a library is loaded, its symbols
3255 3460 become available for subsequent invocations of builtin. Multiple
3256 3461 libraries can be specified with separate invocations of the builtin
3257 3462 command. Libraries are searched in the reverse order in which they
3258 3463 are specified. When a library is loaded, it looks for a function in
3259 3464 the library whose name is lib_init() and invokes this function with
3260 3465 an argument of 0.
3261 3466
3262 3467
3263 3468 cd [-LP] [arg]
3264 3469 cd [-LP] old new
3265 3470
3266 3471 This command has two forms.
3267 3472
3268 3473 In the first form it changes the current directory to arg. If arg
3269 3474 is a -, the directory is changed to the previous directory. The
3270 3475 shell variable HOME is the default arg. The variable PWD is set to
3271 3476 the current directory. The shell variable CDPATH defines the search
3272 3477 path for the directory containing arg. Alternative directory names
3273 3478 are separated by a colon (:). The default path is NULL (specifying
3274 3479 the current directory). The current directory is specified by a
3275 3480 null path name, which can appear immediately after the equal sign
3276 3481 or between the colon delimiters anywhere else in the path list. If
3277 3482 arg begins with a /, the search path is not used. Otherwise, each
3278 3483 directory in the path is searched for arg.
3279 3484
3280 3485 The second form of cd substitutes the string new for the string old
3281 3486 in the current directory name, PWD, and tries to change to this new
3282 3487 directory. By default, symbolic link names are treated literally
3283 3488 when finding the directory name. This is equivalent to the -L
3284 3489 option. The -P option causes symbolic links to be resolved when
3285 3490 determining the directory. The last instance of -L or -P on the
3286 3491 command line determines which method is used. The cd command cannot
3287 3492 be executed by rksh93.
3288 3493
3289 3494
3290 3495 command [-pvVx] name [arg ...]
3291 3496
3292 3497 Without the -v or -V options, executes name with the arguments
3293 3498 specified by arg.
3294 3499
3295 3500 The -p option causes a default path to be searched rather than the
3296 3501 one defined by the value of PATH. Functions are not searched when
3297 3502 finding name. In addition, if name refers to a special built-in,
3298 3503 none of the special properties associated with the leading daggers
3299 3504 are honored. For example, the predefined alias redirect='command
3300 3505 exec' prevents a script from terminating when an invalid
3301 3506 redirection is specified.
3302 3507
3303 3508 With the -x option, if command execution would result in a failure
3304 3509 because there are too many arguments, errno E2BIG, the shell
3305 3510 invokes command name multiple times with a subset of the arguments
3306 3511 on each invocation. Arguments that occur prior to the first word
3307 3512 that expands to multiple arguments and after the last word that
3308 3513 expands to multiple arguments are passed on each invocation. The
3309 3514 exit status is the maximum invocation exit status.
3310 3515
3311 3516 With the -v option, command is equivalent to the built-in whence
3312 3517 command described in this section. The -V option causes command to
3313 3518 act like whence -v.
3314 3519
3315 3520
3316 3521 +continue [n]
3317 3522
3318 3523 Resumes the next iteration of the enclosing for, while, until, or
3319 3524 select loop. If n is specified, then resume at the nth enclosing
3320 3525 loop.
3321 3526
3322 3527
3323 3528 disown [job...]
3324 3529
3325 3530 Causes the shell not to send a HUP signal to each specified job, or
3326 3531 all active jobs if job is omitted, when a login shell terminates.
3327 3532
3328 3533
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
3329 3534 echo [arg ...]
3330 3535
3331 3536 When the first arg does not begin with a -, and none of the
3332 3537 arguments contain a backslash (\), prints each of its arguments
3333 3538 separated by a SPACE and terminated by a NEWLINE. Otherwise, the
3334 3539 behavior of echo is system dependent and print or printf described
3335 3540 in this section should be used. See echo(1) for usage and
3336 3541 description.
3337 3542
3338 3543
3544 + ++enum [ -i ] type[=(value ...) ]
3545 +
3546 + Creates a declaration command named type that is an integer type
3547 + that allows one of the specified values as enumeration names. If
3548 + =(value ...) is omitted, then type must be an indexed array
3549 + variable with at least two elements and the values are taken from
3550 + this array variable. If -i is specified the values are case
3551 + insensitive.
3552 +
3553 +
3339 3554 +eval [arg ...]
3340 3555
3341 3556 The arguments are read as input to the shell and the resulting
3342 3557 commands are executed.
3343 3558
3344 3559
3345 3560 +exec [-c] [-a name ...] [arg ...]
3346 3561
3347 3562 If arg is specified, the command specified by the arguments is
3348 3563 executed in place of this shell without creating a new process. The
3349 3564 -c option causes the environment to be cleared before applying
3350 3565 variable assignments associated with the exec invocation. The -a
3351 3566 option causes name rather than the first arg, to become argv[0] for
3352 3567 the new process. Input and output arguments can appear and affect
3353 3568 the current process. If arg is not specified, the effect of this
3354 3569 command is to modify file descriptors as prescribed by the
3355 3570 input/output redirection list. In this case, any file descriptor
3356 3571 numbers greater than 2 that are opened with this mechanism are
3357 3572 closed when invoking another program.
3358 3573
3359 3574
3360 3575 +exit [n]
3361 3576
3362 3577 Causes the shell to exit with the exit status specified by n. The
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
3363 3578 value is the least significant 8 bits of the specified status. If n
3364 3579 is omitted, then the exit status is that of the last command
3365 3580 executed. An end-of-file also causes the shell to exit except for a
3366 3581 shell which has the ignoreeof option turned on. See set.
3367 3582
3368 3583
3369 3584 ++export [-p] [name[=value]] ...
3370 3585
3371 3586 If name is not specified, the names and values of each variable
3372 3587 with the export attribute are printed with the values quoted in a
3373 - manner that allows them to be re-entered. The -p option causes the
3374 - word export to be inserted before each one. Otherwise, the
3375 - specified names are marked for automatic export to the environment
3376 - of subsequently-executed commands.
3588 + manner that allows them to be re-entered. The export command is the
3589 + same as typeset -x except that if you use export within a function,
3590 + no local variable is created. The -p option causes the word export
3591 + to be inserted before each one. Otherwise, the specified names are
3592 + marked for automatic export to the environment of subsequently-
3593 + executed commands.
3377 3594
3378 3595
3379 3596 false
3380 3597
3381 3598 Does nothing, and exits 1. Used with until for infinite loops.
3382 3599
3383 3600
3384 3601 fg [job ...]
3385 3602
3386 3603 This command is only on systems that support job control. Each job
3387 3604 specified is brought to the foreground and waited for in the
3388 3605 specified order. Otherwise, the current job is brought into the
3389 3606 foreground. See Jobs for a description of the format of job.
3390 3607
3391 3608
3392 3609 getconf [name [pathname]]
3393 3610
3394 3611 Prints the current value of the configuration parameter specified
3395 3612 by name. The configuration parameters are defined by the IEEE POSIX
3396 3613 1003.1 and IEEE POSIX 1003.2 standards. See pathconf(2) and
3397 3614 sysconf(3C).
3398 3615
3399 3616 The pathname argument is required for parameters whose value
3400 3617 depends on the location in the file system. If no arguments are
3401 3618 specified, getconf prints the names and values of the current
3402 3619 configuration parameters. The pathname / is used for each of the
3403 3620 parameters that requires pathname.
3404 3621
3405 3622
3406 3623 getopts [ -a name] optstring vname [arg ...]
3407 3624
3408 3625 Checks arg for legal options. If arg is omitted, the positional
3409 3626 parameters are used. An option argument begins with a + or a -. An
3410 3627 option that does not begin with + or - or the argument -- ends the
3411 3628 options. Options beginning with + are only recognized when
3412 3629 optstring begins with a +. optstring contains the letters that
3413 3630 getopts recognizes. If a letter is followed by a :, that option is
3414 3631 expected to have an argument. The options can be separated from the
3415 3632 argument by blanks. The option -?causes getopts to generate a usage
3416 3633 message on standard error. The -a option can be used to specify the
3417 3634 name to use for the usage message, which defaults to $0. getopts
3418 3635 places the next option letter it finds inside variable vname each
3419 3636 time it is invoked. The option letter is prepended with a + when
3420 3637 arg begins with a +. The index of the next arg is stored in OPTIND.
3421 3638 The option argument, if any, gets stored in OPTARG. A leading : in
3422 3639 optstring causes getopts to store the letter of an invalid option
3423 3640 in OPTARG, and to set vname to ? for an unknown option and to: when
3424 3641 a required option argument is missing. Otherwise, getopts prints an
3425 3642 error message. The exit status is non-zero when there are no more
3426 3643 options. There is no way to specify any of the options :, +, -, ?,
3427 3644 [, and ]. The option # can only be specified as the first option.
3428 3645
3429 3646
3430 3647 hist [ -e ename][-nlr] [ first[last ] ]
3431 3648 hist -s [ old=new ] [ command]
3432 3649
3433 3650 In the first form, a range of commands from first to last is
3434 3651 selected from the last HISTSIZE commands that were typed at the
3435 3652 terminal. The arguments first and last can be specified as a
3436 3653 number or as a string. A string is used to locate the most recent
3437 3654 command starting with the specified string. A negative number is
3438 3655 used as an offset to the current command number. If the -l option
3439 3656 is selected, the commands are listed on standard output. Otherwise,
3440 3657 the editor program ename is invoked on a file containing these
3441 3658 keyboard commands. If ename is not supplied, then the value of the
3442 3659 variable HISTEDIT is used. If HISTEDIT is not set, then FCEDIT
3443 3660 (default /bin/ed) is used as the editor. When editing is complete,
3444 3661 the edited command(s) is executed if the changes have been saved.
3445 3662 If last is not specified, then it is set to first. If first is not
3446 3663 specified, the default is the previous command for editing and -16
3447 3664 for listing. The option -r reverses the order of the commands and
3448 3665 the option -n suppresses command numbers when listing. In the
3449 3666 second form, command is interpreted as first described in this
3450 3667 section and defaults to the last command executed. The resulting
3451 3668 command is executed after the optional substitution old=new is
3452 3669 performed.
3453 3670
3454 3671
3455 3672 jobs -lnp [job ...]
3456 3673
↓ open down ↓ |
70 lines elided |
↑ open up ↑ |
3457 3674 Lists information about each specified job, or all active jobs if
3458 3675 job is omitted. The -l option lists process ids in addition to the
3459 3676 normal information. The -n option only displays jobs that have
3460 3677 stopped or exited since last notified. The -p option causes only
3461 3678 the process group to be listed. See Jobs for a description of the
3462 3679 format of job.
3463 3680
3464 3681
3465 3682 kill [-s signame] job ...
3466 3683 kill [-n signum] job ...
3467 - kill -l [sig ...]
3684 + kill -Ll [sig ...]
3468 3685
3469 3686 Sends either the TERM (terminate) signal or the specified signal to
3470 3687 the specified jobs or processes. Signals are either specified by
3471 3688 number with the -n option or by name with the -s option (as
3472 3689 specified in <signal.h>, stripped of the prefix `SIG with the
3473 3690 exception that SIGCLD is named CHLD). For backward compatibility,
3474 3691 the n and s can be omitted and the number or name placed
3475 3692 immediately after the -. If the signal being sent is TERM
3476 3693 (terminate) or HUP (hang up), then the job or process is sent a
3477 3694 CONT (continue) signal if it is stopped. The argument job can be
3478 3695 the process id of a process that is not a member of one of the
3479 3696 active jobs. See Jobs for a description of the format of job. In
3480 - the third form, kill -l, if sig is not specified, the signal names
3481 - are listed. Otherwise, for each sig that is a name, the
3482 - corresponding signal number is listed. For each sig that is a
3483 - number, the signal name corresponding to the least significant 8
3484 - bits of sig is listed.
3697 + the third form, kill -l or kill -L, if sig is not specified, the
3698 + signal names are listed. The -l option lists only the signal names
3699 + whereas -L lists each signal name and corresponding number.
3700 + Otherwise, for each sig that is a name, the corresponding signal
3701 + number is listed. For each sig that is a number, the signal name
3702 + corresponding to the least significant 8 bits of sig is listed.
3485 3703
3486 3704
3487 3705 let [arg ...]
3488 3706
3489 - Each arg is a separate arithmetic expression to be evaluated. See
3490 - the Arithmetic Evaluation section of this manual page for a
3491 - description of arithmetic expression evaluation. The exit status is
3492 - 0 if the value of the last expression is non-zero, and 1 otherwise.
3707 + Each arg is a separate arithmetic expression to be evaluated. let
3708 + only recognizes octal constants starting with 0 when the set option
3709 + letoctal is on. See the Arithmetic Evaluation section of this
3710 + manual page for a description of arithmetic expression evaluation.
3711 + The exit status is 0 if the value of the last expression is non-
3712 + zero, and 1 otherwise.
3493 3713
3494 3714
3495 3715 +newgrp [arg ...]
3496 3716
3497 3717 Equivalent to exec /bin/newgrp arg ...
3498 3718
3499 3719
3500 - print [-Renprs] [ -u unit] [ -f format ] [ arg ...]
3720 + print [-CRenprsv] [ -u unit] [ -f format ] [ arg ...]
3501 3721
3502 3722 With no options or with option - or --, each arg is printed on
3503 3723 standard output. The -f option causes the arguments to be printed
3504 3724 as described by printf. In this case, any e, n, r, or R options are
3505 3725 ignored. Otherwise, unless the -R or -r, are specified, the
3506 3726 following escape conventions are applied:
3507 3727
3508 3728 \a
3509 3729 Alert character (ASCII 07)
3510 3730
3511 3731
3512 3732 \b
3513 3733 Backspace character (ASCII 010)
3514 3734
3515 3735
3516 3736 \c
3517 3737 Causes print to end without processing more arguments and
3518 3738 not adding a NEWLINE
3519 3739
3520 3740
3521 3741 \f
3522 3742 Form-feed character (ASCII 014)
3523 3743
3524 3744
3525 3745 \n
3526 3746 NEWLINE character (ASCII 012)
3527 3747
3528 3748
3529 3749 \r
3530 3750 RETURN character (ASCII 015)
3531 3751
3532 3752
3533 3753 \t
3534 3754 TAB character (ASCII 011)
3535 3755
3536 3756
3537 3757 \v
3538 3758 Vertical TAB character (ASCII 013)
3539 3759
3540 3760
3541 3761 \E
3542 3762 Escape character (ASCII 033)
3543 3763
3544 3764
3545 3765 \\
3546 3766 Backslash character \
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
3547 3767
3548 3768
3549 3769 \0x
3550 3770 Character defined by the 1, 2, or 3-digit octal string
3551 3771 specified by x
3552 3772
3553 3773 The -R option prints all subsequent arguments and options other
3554 3774 than -n. The -e causes the escape conventions to be applied This is
3555 3775 the default behavior. It reverses the effect of an earlier -r. The
3556 3776 -p option causes the arguments to be written onto the pipe of the
3557 - process spawned with |& instead of standard output. The -s option
3777 + process spawned with |& instead of standard output. The -v option
3778 + treats each arg as a variable name and writes the value in the
3779 + printf %B format. The -C option treats each arg as a variable name
3780 + and writes the values in the printf %#B format. The -s option
3558 3781 causes the arguments to be written onto the history file instead of
3559 3782 standard output. The -u option can be used to specify a one digit
3560 3783 file descriptor unit number unit on which the output is placed. The
3561 3784 default is 1. If the option -n is used, no NEWLINE is added to the
3562 3785 output.
3563 3786
3564 3787
3565 - printf format[arg ...]
3788 + printf format [arg ...]
3566 3789
3567 3790 The arguments arg are printed on standard output in accordance with
3568 3791 the ANSI-C formatting rules associated with the format string
3569 3792 format. If the number of arguments exceeds the number of format
3570 3793 specifications, the format string is reused to format remaining
3571 - arguments. The following extensions can also be used: A %b format
3572 - can be used instead of %s to cause escape sequences in the
3573 - corresponding arg to be expanded as described in print. A %B option
3574 - causes each of the arguments to be treated as variable names and
3575 - the binary value of the variables is printed. This is most useful
3576 - for variables with an attribute of b. A %H format can be used
3577 - instead of %s to cause characters in arg that are special in HTML
3578 - and XML to be output as their entity name. A %P format can be used
3579 - instead of %s to cause arg to be interpreted as an extended regular
3580 - expression and be printed as a shell pattern. A %R format can be
3581 - used instead of %s to cause arg to be interpreted as a shell
3582 - pattern and to be printed as an extended regular expression. A %q
3583 - format can be used instead of %s to cause the resulting string to
3584 - be quoted in a manner than can be input again to the shell. A
3585 - %(date-format)T format can be use to treat an argument as a
3586 - date/time string and to format the date/time according to the date-
3587 - format as defined for the date(1) command. A %Z format outputs a
3588 - byte whose value is 0. The precision field of the %d format can be
3589 - followed by a . and the output base. In this case, the # flag
3590 - character causes base# to be prepended. The # flag when used with
3591 - the d specifier without an output base, causes the output to be
3592 - displayed in thousands units with one of the suffixes k M G T P E
3593 - to indicate the unit. The # flag when used with the i specifier
3594 - causes the output to be displayed in 1024 with one of the suffixes
3595 - Ki Mi Gi Ti Pi Ei to indicate the unit. The = flag has been added
3596 - to center the output within the specified field width.
3794 + arguments. The following extensions can also be used:
3597 3795
3598 3796
3797 + %b
3798 +
3799 + A %b format can be used instead of %s to cause escape sequences
3800 + in the corresponding arg to be expanded as described in print.
3801 +
3802 +
3803 + %B
3804 +
3805 + A %B option causes each of the arguments to be treated as
3806 + variable names and the binary value of the variables is
3807 + printed. This is most useful for variables with an attribute of
3808 + b.
3809 +
3810 +
3811 + %H
3812 +
3813 + A %H format can be used instead of %s to cause characters in
3814 + arg that are special in HTML and XML to be output as their
3815 + entity name. The alternate flag # formats the output for use as
3816 + a URI.
3817 +
3818 +
3819 + %P
3820 +
3821 + A %P format can be used instead of %s to cause arg to be
3822 + interpreted as an extended regular expression and be printed as
3823 + a shell pattern.
3824 +
3825 +
3826 +
3827 + %R
3828 +
3829 + A %R format can be used instead of %s to cause arg to be
3830 + interpreted as a shell pattern and to be printed as an extended
3831 + regular expression.
3832 +
3833 +
3834 + %q
3835 +
3836 + A %q format can be used instead of %s to cause the resulting
3837 + string to be quoted in a manner than can be input again to the
3838 + shell. When q is preceded by the alternative format specifier,
3839 + #, the string is quoted in manner suitable as a field in a .csv
3840 + format file.
3841 +
3842 +
3843 + %(date-format)
3844 +
3845 + A %(date-format)T format can be use to treat an argument as a
3846 + date/time string and to format the date/time according to the
3847 + date-format as defined for the date(1) command.
3848 +
3849 +
3850 +
3851 + %Z
3852 +
3853 + A %Z format outputs a byte whose value is 0.
3854 +
3855 +
3856 + %d
3857 +
3858 + The precision field of the %d format can be followed by a . and
3859 + the output base. In this case, the # flag character causes
3860 + base# to be prepended.
3861 +
3862 +
3863 + #
3864 +
3865 + The # flag, when used with the %d format without an output
3866 + base, displays the output in powers of 1000 indicated by one of
3867 + the following suffixes: k M G T P E, and when used with the %i
3868 + format displays the output in powers of 1024 indicated by one
3869 + of the following suffixes: Ki Mi Gi Ti Pi Ei.
3870 +
3871 +
3872 +
3873 + =
3874 +
3875 + The = flag centers the output within the specified field width.
3876 +
3877 +
3878 + L
3879 +
3880 + The L flag, when used with the %c or %s formats, treats
3881 + precision as character width instead of byte count.
3882 +
3883 +
3884 + ,
3885 +
3886 + The , flag, when used with the %d or %f formats, separates
3887 + groups of digits with the grouping delimiter (, in groups of 3
3888 + in the C locale).
3889 +
3890 +
3891 +
3892 +
3599 3893 pwd [-LP]
3600 3894
3601 3895 Outputs the value of the current working directory. The -L option
3602 3896 is the default. It prints the logical name of the current
3603 3897 directory. If the -P option is specified, all symbolic links are
3604 3898 resolved from the name. The last instance of -L or -P on the
3605 3899 command line determines which method is used.
3606 3900
3607 3901
3608 - read [-Aprs] [-d delim] [ -n n] [[ -N n] [[-t timeout] [-u unit]
3902 + read [-ACSprsv] [-d delim] [ -n n] [[ -N n] [[-t timeout] [-u unit]
3609 3903 [vname?prompt] [ vname ... ]
3610 3904
3611 3905 The shell input mechanism. One line is read and is broken up into
3612 3906 fields using the characters in IFS as separators. The escape
3613 3907 character, \, is used to remove any special meaning for the next
3614 3908 character and for line continuation. The -d option causes the read
3615 3909 to continue to the first character of delim rather than NEWLINE.
3616 3910 The -n option causes at most n bytes to read rather a full line but
3617 3911 returns when reading from a slow device as soon as any characters
3618 3912 have been read. The -N option causes exactly n to be read unless an
3619 3913 end-of-file has been encountered or the read times out because of
3620 3914 the -t option. In raw mode, -r, the \ character is not treated
3621 3915 specially. The first field is assigned to the first vname, the
3622 3916 second field to the second vname, etc., with leftover fields
3623 3917 assigned to the last vname. When vname has the binary attribute and
3624 3918 -n or -N is specified, the bytes that are read are stored directly
3625 3919 into the variable. If the -v is specified, then the value of the
3626 3920 first vname is used as a default value when reading from a terminal
3627 3921 device. The -A option causes the variable vname to be unset and
3628 3922 each field that is read to be stored in successive elements of the
3629 - indexed array vname. The -p option causes the input line to be
3630 - taken from the input pipe of a process spawned by the shell using
3631 - |&. If the -s option is present, the input is saved as a command in
3632 - the history file. The option -u can be used to specify a one digit
3633 - file descriptor unit unit to read from. The file descriptor can be
3634 - opened with the exec special built-in command. The default value of
3635 - unit n is 0. The option -t is used to specify a time out in seconds
3636 - when reading from a terminal or pipe. If vname is omitted, then
3637 - REPLY is used as the default vname. An end-of-file with the -p
3638 - option causes cleanup for this process so that another can be
3639 - spawned. If the first argument contains a ?, the remainder of this
3640 - word is used as a prompt on standard error when the shell is
3641 - interactive. The exit status is 0 unless an end-of-file is
3642 - encountered or read has timed out.
3923 + indexed array vname. The -C option causes the variable vname to be
3924 + read as a compound variable. Blanks will be ignored when finding
3925 + the beginning open parenthesis. The -S option causes the line to be
3926 + treated like a record in a .csv format file so that double quotes
3927 + can be used to allow the delimiter character and the new-line
3928 + character to appear within a field. The -p option causes the input
3929 + line to be taken from the input pipe of a process spawned by the
3930 + shell using |&. If the -s option is present, the input is saved as
3931 + a command in the history file. The option -u can be used to specify
3932 + a one digit file descriptor unit unit to read from. The file
3933 + descriptor can be opened with the exec special built-in command.
3934 + The default value of unit n is 0. The option -t is used to specify
3935 + a time out in seconds when reading from a terminal or pipe. If
3936 + vname is omitted, then REPLY is used as the default vname. An end-
3937 + of-file with the -p option causes cleanup for this process so that
3938 + another can be spawned. If the first argument contains a ?, the
3939 + remainder of this word is used as a prompt on standard error when
3940 + the shell is interactive. The exit status is 0 unless an end-of-
3941 + file is encountered or read has timed out.
3643 3942
3644 3943
3645 3944 ++readonly [-p] [ vname[=value]] ...
3646 3945
3647 3946 If vname is not specified, the names and values of each variable
3648 3947 with the read-only attribute is printed with the values quoted in a
3649 3948 manner that allows them to be input again. The -p option causes the
3650 3949 word readonly to be inserted before each one. Otherwise, the
3651 3950 specified vnames are marked readonly and these names cannot be
3652 3951 changed by subsequent assignment.
3653 3952
3654 3953
3655 3954 +return [n]
3656 3955
3657 3956 Causes a shell function or script to return to the invoking script
3658 3957 with the exit status specified by n. The value is the least
3659 3958 significant 8 bits of the specified status. If n is omitted, then
3660 3959 the return status is that of the last command executed. If return
3661 3960 is invoked while not in a function or a script, then it behaves the
3662 3961 same as exit.
3663 3962
3664 3963
3665 3964 +set [ +-BCGabefhkmnoprstuvx] [+-o [ option ] ] ... [ +-A vname]
3666 3965 [arg...]
3667 3966
3668 3967 The set command supports the following options:
3669 3968
3670 3969 -a
3671 3970
3672 3971 All subsequent variables that are defined are automatically
3673 3972 exported.
3674 3973
3675 3974
3676 3975 -A
3677 3976
3678 3977 Array assignment. Unset the variable vname and assign values
3679 3978 sequentially from the arg list. If +A is used, the variable
3680 3979 vname is not unset first.
3681 3980
3682 3981
3683 3982 -b
3684 3983
3685 3984 Prints job completion messages as soon as a background job
3686 3985 changes state rather than waiting for the next prompt.
3687 3986
3688 3987
3689 3988 -B
3690 3989
3691 3990 Enable brace pattern field generation. This is the default
3692 3991 behavior.
3693 3992
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
3694 3993
3695 3994 -C
3696 3995
3697 3996 Prevents redirection (>) from truncating existing files. Files
3698 3997 that are created are opened with the O_EXCL mode. Requires >|
3699 3998 to truncate a file when turned on.
3700 3999
3701 4000
3702 4001 -e
3703 4002
3704 - If a command has a non-zero exit status, execute the ERR trap,
3705 - if set, and exit. This mode is disabled while reading profiles.
4003 + Unless contained in a || or && command, or the command
4004 + following an if, while or until command or in the pipeline
4005 + following !, if a command has a non-zero exit status, execute
4006 + the ERR trap, if set, and exit. This mode is disabled while
4007 + reading profiles.
3706 4008
3707 4009
3708 4010 -f
3709 4011
3710 4012 Disables file name generation.
3711 4013
3712 4014
3713 4015 -G
3714 4016
3715 4017 Causes the pattern ** by itself to match files and zero or more
3716 4018 directories and subdirectories when used for file name
3717 4019 generation. If followed by a / only directories and
3718 4020 subdirectories are matched.
3719 4021
3720 4022
3721 4023 -h
3722 4024
3723 4025 Each command becomes a tracked alias when first encountered.
3724 4026
3725 4027
3726 4028 -k
3727 4029
3728 4030 Obsolete. All variable assignment arguments are placed in the
3729 4031 environment for a command, not just those that precede the
3730 4032 command name.
3731 4033
3732 4034
3733 4035 -m
3734 4036
3735 4037 Background jobs run in a separate process group and a line
3736 4038 prints upon completion. The exit status of background jobs is
3737 4039 reported in a completion message. On systems with job control,
3738 4040 this option is turned on automatically for interactive shells.
3739 4041
3740 4042
3741 4043 -n
3742 4044
3743 4045 Read commands and check them for syntax errors, but do not
3744 4046 execute them. Ignored for interactive shells.
3745 4047
3746 4048
3747 4049 -o
3748 4050
3749 4051 If no option name is supplied, the list of options and their
3750 4052 current settings are written to standard output. When invoked
3751 4053 with a +, the options are written in a format that can be input
3752 4054 again to the shell to restore the settings. This option can be
3753 4055 repeated to enable or disable multiple options.
3754 4056
3755 4057 The following argument can be one of the following option
3756 4058 names:
3757 4059
3758 4060 allexport
3759 4061
3760 4062 Same as -a.
3761 4063
3762 4064
3763 4065 bgnice
3764 4066
3765 4067 All background jobs are run at a lower priority. This is
3766 4068 the default mode.
3767 4069
3768 4070
3769 4071 braceexpand
3770 4072
3771 4073 Same as -B.
3772 4074
3773 4075
3774 4076 emacs
3775 4077
3776 4078 Puts you in an emacs style inline editor for command entry.
3777 4079
3778 4080
3779 4081 errexit
3780 4082
3781 4083 Same as -e.
3782 4084
3783 4085
3784 4086 globstar
3785 4087
3786 4088 Same as -G.
3787 4089
3788 4090
3789 4091 gmacs
3790 4092
3791 4093 Puts you in a gmacs style inline editor for command entry.
3792 4094
3793 4095
3794 4096 ignoreeof
↓ open down ↓ |
79 lines elided |
↑ open up ↑ |
3795 4097
3796 4098 The shell does not exit on end-of-file. The command exit
3797 4099 must be used.
3798 4100
3799 4101
3800 4102 keyword
3801 4103
3802 4104 Same as -k.
3803 4105
3804 4106
4107 + letoctal
4108 +
4109 + The let command allows octal constants starting with 0.
4110 +
4111 +
3805 4112 markdirs
3806 4113
3807 4114 All directory names resulting from file name generation
3808 4115 have a trailing / appended.
3809 4116
3810 4117
3811 4118 monitor
3812 4119
3813 4120 Same as -m.
3814 4121
3815 4122
3816 4123 multiline
3817 4124
3818 4125 The built-in editors use multiple lines on the screen for
3819 4126 lines that are longer than the width of the screen. This
3820 4127 might not work for all terminals.
3821 4128
3822 4129
3823 4130 noclobber
3824 4131
3825 4132 Same as -C.
3826 4133
3827 4134
3828 4135 noexec
3829 4136
3830 4137 Same as -n.
3831 4138
3832 4139
3833 4140 noglob
3834 4141
3835 4142 Same as -f.
3836 4143
3837 4144
3838 4145 nolog
3839 4146
3840 4147 Do not save function definitions in the history file.
3841 4148
3842 4149
3843 4150 notify
3844 4151
3845 4152 Same as -b.
3846 4153
3847 4154
3848 4155 nounset
3849 4156
3850 4157 Same as -u.
3851 4158
3852 4159
3853 4160 pipefail
3854 4161
3855 4162 A pipeline does not complete until all components of the
3856 4163 pipeline have completed, and the return value is the value
3857 4164 of the last non-zero command to fail or zero if no command
3858 4165 has failed.
3859 4166
3860 4167
3861 4168 privileged
3862 4169
3863 4170 Same as -p.
3864 4171
3865 4172
3866 4173 showme
3867 4174
3868 4175 When enabled, simple commands or pipelines preceded by a a
3869 4176 semicolon (;) is displayed as if the xtrace option were
3870 4177 enabled but is not executed. Otherwise, the leading ; is
3871 4178 ignored.
3872 4179
3873 4180
3874 4181 trackall
3875 4182
3876 4183 Same as -h.
3877 4184
3878 4185
3879 4186 verbose
3880 4187
3881 4188 Same as -v.
3882 4189
3883 4190
3884 4191 vi
3885 4192
3886 4193 Puts you in insert mode of a vi style inline editor until
3887 4194 you hit the escape character 033. This puts you in control
3888 4195 mode. A return sends the line.
3889 4196
3890 4197
3891 4198 viraw
3892 4199
3893 4200 Each character is processed as it is typed in vi mode.
3894 4201
3895 4202
3896 4203 xtrace
3897 4204
3898 4205 Same as -x.
3899 4206
3900 4207 If no option name is supplied, the current options settings
3901 4208 are printed.
3902 4209
3903 4210
3904 4211
3905 4212 -p
3906 4213
3907 4214 Disables processing of the $HOME/.profile file and uses the
3908 4215 file /etc/suid_profile instead of the ENV file. This mode is on
3909 4216 whenever the effective uid (gid) is not equal to the real uid
3910 4217 (gid). Turning this off causes the effective uid and gid to be
3911 4218 set to the real uid and gid.
3912 4219
3913 4220
3914 4221 -r
3915 4222
3916 4223 Enables the restricted shell. This option cannot be unset once
3917 4224 set.
3918 4225
3919 4226
3920 4227 -s
3921 4228
3922 4229 Sort the positional parameters lexicographically.
3923 4230
3924 4231
3925 4232 -t
3926 4233
3927 4234 Obsolete. Exit after reading and executing one command.
3928 4235
3929 4236
3930 4237 -u
3931 4238
3932 4239 Treat unset parameters as an error when substituting.
3933 4240
3934 4241
3935 4242 -v
3936 4243
3937 4244 Print shell input lines as they are read.
3938 4245
3939 4246
3940 4247 -x
3941 4248
3942 4249 Print commands and their arguments as they are executed.
3943 4250
3944 4251
3945 4252 --
3946 4253
3947 4254 Do not change any of the options. This is useful in setting $1
3948 4255 to a value beginning with -. If no arguments follow this option
3949 4256 then the positional parameters are unset.
3950 4257
3951 4258 As an obsolete feature, if the first arg is - then the -x and -v
3952 4259 options are turned off and the next arg is treated as the first
3953 4260 argument. Using + rather than - causes these options to be turned
3954 4261 off. These options can also be used upon invocation of the shell.
3955 4262 The current set of options can be found in $-. Unless -A is
3956 4263 specified, the remaining arguments are positional parameters and
3957 4264 are assigned, in order, to $1 $2 .... If no arguments are
3958 4265 specified, then the names and values of all variables are printed
3959 4266 on the standard output.
3960 4267
3961 4268
3962 4269 +shift [n]
3963 4270
3964 4271 The positional parameters from $n+1 ... are renamed $1 ..., the
3965 4272 default n is 1. The parameter n can be any arithmetic expression
3966 4273 that evaluates to a non-negative number less than or equal to $#.
3967 4274
3968 4275
3969 4276 sleep seconds
3970 4277
3971 4278 Suspends execution for the number of decimal seconds or fractions
3972 4279 of a second specified by seconds.
3973 4280
3974 4281
3975 4282 +trap -p [action] [sig] ...
3976 4283
3977 4284 The -p option causes the trap action associated with each trap as
3978 4285 specified by the arguments to be printed with appropriate quoting.
3979 4286 Otherwise, action is processed as if it were an argument to eval
3980 4287 when the shell receives signal(s) sig. Each sig can be specified as
3981 4288 a number or as the name of the signal. Trap commands are executed
3982 4289 in order of signal number. Any attempt to set a trap on a signal
3983 4290 that was ignored on entry to the current shell is ineffective. If
3984 4291 action is omitted and the first sig is a number, or if action is -,
3985 4292 then the trap(s) for each sig are reset to their original values.
3986 4293 If action is the null string then this signal is ignored by the
3987 4294 shell and by the commands it invokes. If sig is ERR then action is
3988 4295 executed whenever a command has a non-zero exit status. If sig is
3989 4296 DEBUG then action is executed before each command. The variable
3990 4297 .sh.command contains the contents of the current command line when
3991 4298 action is running. If sig is 0 or EXIT and the trap statement is
3992 4299 executed inside the body of a function defined with the function
3993 4300 name syntax, then the command action is executed after the function
3994 4301 completes. If sig is 0 or EXIT for a trap set outside any function
3995 4302 then the command action is executed on exit from the shell. If sig
↓ open down ↓ |
181 lines elided |
↑ open up ↑ |
3996 4303 is KEYBD, then action is executed whenever a key is read while in
3997 4304 emacs, gmacs, or vi mode. The trap command with no arguments prints
3998 4305 a list of commands associated with each signal number.
3999 4306
4000 4307
4001 4308 true
4002 4309
4003 4310 Does nothing, and exits 0. Used with while for infinite loops.
4004 4311
4005 4312
4006 - ++typeset [+-AHflabnprtux ] [ +-EFLRZi[n] ] [ vname[=value ] ]
4313 + ++typeset [+-ACHSfblmnprtux ] [ +-EFLRXZi[n] ] [ +-M [ mapname ] ] [ -T
4314 + [ tname=(assign_list) ] ] [ -h str ] [ -a [type] ] [ vname[=value ] ]
4007 4315
4008 4316 Sets attributes and values for shell variables and functions. When
4009 4317 invoked inside a function defined with the function name syntax, a
4010 4318 new instance of the variable vname is created, and the variable's
4011 4319 value and type are restored when the function completes.
4012 4320
4013 4321 Using + rather than - causes these options to be turned off. If no
4014 4322 vname arguments are specified, a list of vnames (and optionally the
4015 4323 values) of the variables is printed. Using + rather than - keeps
4016 4324 the values from being printed.) The -p option causes typeset
4017 4325 followed by the option letters to be printed before each name
4018 4326 rather than the names of the options. If any option other than -p
4019 4327 is specified, only those variables which have all of the specified
4020 4328 options are printed. Otherwise, the vnames and attributes of all
4021 4329 variables that have attributes are printed.
4022 4330
4023 4331 The following list of attributes can be specified:
4024 4332
4025 4333 -a
4026 4334 Declares vname to be an indexed array. This is optional
4027 4335 unless except for compound variable assignments.
4028 4336
4029 4337
4030 4338 -A
4031 4339 Declares vname to be an associative array. Sub-scripts are
4032 4340 strings rather than arithmetic expressions.
4033 4341
4034 4342
4035 4343 -b
4036 4344 The variable can hold any number of bytes of data. The data
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
4037 4345 can be text or binary. The value is represented by the base64
4038 4346 encoding of the data. If -Z is also specified, the size in
4039 4347 bytes of the data in the buffer is determined by the size
4040 4348 associated with the -Z. If the base64 string assigned results
4041 4349 in more data, it is truncated. Otherwise, it is filled with
4042 4350 bytes whose value is zero. The printf format %B can be used
4043 4351 to output the actual data in this buffer instead of the
4044 4352 base64 encoding of the data.
4045 4353
4046 4354
4355 + -C
4356 + Causes each vname to be a compound variable. If value names a
4357 + compound variable it is copied into vname. Otherwise, it
4358 + unsets each vname.
4359 +
4360 +
4047 4361 -E
4048 4362 Declares vname to be a double precision floating point
4049 4363 number. If n is non-zero, it defines the number of
4050 4364 significant figures that are used when expanding vname.
4051 4365 Otherwise, ten significant figures is used.
4052 4366
4053 4367
4054 4368 -f
4055 4369 The names refer to function names rather than variable names.
4056 4370 No assignments can be made and the only other valid options
4057 4371 are -t, -u, and -x. The -t option turns on execution tracing
4058 4372 for this function. The -u option causes this function to be
4059 4373 marked undefined. The FPATH variable is searched to find the
4060 4374 function definition when the function is referenced. If no
4061 4375 options other than -f is specified, then the function
4062 4376 definition is displayed on standard output. If +f is
4063 4377 specified, then a line containing the function name followed
4064 4378 by a shell comment containing the line number and path name
4065 4379 of the file where this function was defined, if any, is
4066 - displayed.
4380 + displayed. The names refer to function names rather than
4381 + variable names. No assignments can be made and the only
4382 + other valid options are -S, -t, -u and -x. The -S can be
4383 + used with discipline functions defined in a type to indicate
4384 + that the function is static. For a static function, the same
4385 + method will be used by all instances of that type no matter
4386 + which instance references it. In addition, it can only use
4387 + value of variables from the original type definition. These
4388 + discipline functions cannot be redefined in any type
4389 + instance. The -t option turns on execution tracing for this
4390 + function. The -u option causes this function to be marked
4391 + undefined. The FPATH variable will be searched to find the
4392 + function definition when the function is referenced. If no
4393 + options other than -f is specified, then the function
4394 + definition will be displayed on standard output. If +f is
4395 + specified, then a line containing the function name followed
4396 + by a shell comment containing the line number and path name
4397 + of the file where this function was defined, if any, is
4398 + displayed. The exit status can be used to determine whether
4399 + the function is defined so that typeset -f .sh.math. name
4400 + will return 0 when math function name is defined and non-zero
4401 + otherwise.
4067 4402
4068 4403 The -i attribute cannot be specified with -f.
4069 4404
4070 4405
4071 4406 -F
4072 4407 Declares vname to be a double precision floating point
4073 4408 number. If n is non-zero, it defines the number of places
4074 4409 after the decimal point that are used when expanding vname.
4075 4410 Otherwise ten places after the decimal point is used.
4076 4411
4077 4412
4413 + -h
4414 + Used within type definitions to add information when
4415 + generating information about the sub-variable on the man
4416 + page. It is ignored when used outside of a type definition.
4417 + When used with -f the information is associated with the
4418 + corresponding discipline function.
4419 +
4420 +
4078 4421 -H
4079 4422 This option provides UNIX to hostname file mapping on non-
4080 4423 UNIX machines.
4081 4424
4082 4425
4083 4426 -i
4084 4427 Declares vname to be represented internally as integer. The
4085 4428 right hand side of an assignment is evaluated as an
4086 4429 arithmetic expression when assigning to an integer. If n is
4087 4430 non-zero, it defines the output arithmetic base, otherwise
4088 4431 the output base is ten.
4089 4432
4090 4433 The -i attribute cannot be specified along with -R, -L, -Z,
4091 4434 or -f.
4092 4435
4093 4436
4094 4437 -l
4095 - All uppercase characters are converted to lowercase. The
4096 - uppercase option, -u, is turned off.
4438 + Used with -i, -E or -F to indicate long integer, or long
4439 + float. Otherwise, all upper-case characters are converted to
4440 + lower-case. The upper-case option, -u, is turned off.
4441 + Equivalent to -M tolower.
4097 4442
4098 4443
4099 4444 -L
4100 4445 Left justify and remove leading blanks from value. If n is
4101 4446 non-zero, it defines the width of the field, otherwise it is
4102 4447 determined by the width of the value of first assignment.
4103 4448 When the variable is assigned to, it is filled on the right
4104 4449 with blanks or truncated, if necessary, to fit into the
4105 4450 field. The -R option is turned off.
4106 4451
4107 4452 The -i attribute cannot be specified with -L.
4108 4453
4109 4454
4455 + -m
4456 + moves or renames the variable. The value is the name of a
4457 + variable whose value will be moved to vname. The original
4458 + variable will be unset. Cannot be used with any other
4459 + options.
4460 +
4461 +
4462 + -M
4463 + Use the character mapping mapping such as tolower and toupper
4464 + when assigning a value to each of the specified operands.
4465 + When mapping is specified and there are not operands, all
4466 + variables that use this mapping are written to standard
4467 + output. When mapping is omitted and there are no operands,
4468 + all mapped variables are written to standard output.
4469 +
4470 +
4110 4471 -n
4111 4472 Declares vname to be a reference to the variable whose name
4112 4473 is defined by the value of variable vname. This is usually
4113 4474 used to reference a variable inside a function whose name has
4114 4475 been passed as an argument.
4115 4476
4116 4477
4478 + -p
4479 + The name, attributes and values for the given vname are
4480 + written on standard output in a form that can be used as
4481 + shell input. If +p is specified, then the values are not
4482 + displayed.
4483 +
4484 +
4117 4485 -R
4118 4486 Right justify and fill with leading blanks. If n is non-zero,
4119 4487 it defines the width of the field, otherwise it is determined
4120 4488 by the width of the value of first assignment. The field is
4121 4489 left filled with blanks or truncated from the end if the
4122 4490 variable is reassigned. The -L option is turned off.
4123 4491
4124 4492 The -i attribute cannot be specified with -R.
4125 4493
4126 4494
4127 4495 -r
4128 4496 The specified vnames are marked read-only and these names
4129 4497 cannot be changed by subsequent assignment.
4130 4498
4131 4499
4500 + -S
4501 + When used within the assign_list of a type definition, it
4502 + causes the specified sub-variable to be shared by all
4503 + instances of the type. When used inside a function defined
4504 + with the function reserved word, the specified variables will
4505 + have function static scope. Otherwise, the variable is unset
4506 + prior to processing the assignment list.
4507 +
4508 +
4132 4509 -t
4133 4510 Tags the variables. Tags are user definable and have no
4134 4511 special meaning to the shell.
4135 4512
4136 4513
4514 + -T
4515 + If followed by tname, it creates a type named by tname using
4516 + the compound assignment assign_list to tname. Otherwise, it
4517 + writes all the type definitions to standard output.
4518 +
4519 +
4137 4520 -u
4138 - All lowercase characters are converted to uppercase. The
4139 - lowercase option, -l, is turned off.
4521 + When given along with -i specifies unsigned integer.
4522 + Otherwise, all lower-case characters are converted to upper-
4523 + case. The lower-case option, -l, is turned off. Equivalent
4524 + to -M toupper.
4140 4525
4141 4526
4142 4527 -x
4143 4528 The specified vnames are marked for automatic export to the
4144 4529 environment of subsequently-executed commands. Variables
4145 4530 whose names contain a . cannot be exported.
4146 4531
4147 4532
4533 + -X
4534 + Declares vname to be a double precision floating point number
4535 + and expands using the %a format of ISO-C99. If n is non-
4536 + zero, it defines the number of hex digits after the radix
4537 + point that is used when expanding vname. The default is 10.
4538 +
4539 +
4148 4540 -Z
4149 4541 Right justify and fill with leading zeros if the first non-
4150 4542 blank character is a digit and the -L option has not been
4151 4543 set. Remove leading zeros if the -L option is also set. If n
4152 4544 is non-zero, it defines the width of the field, otherwise it
4153 4545 is determined by the width of the value of first assignment.
4154 4546
4155 4547 The -i attribute cannot be specified with -Z.
4156 4548
4157 4549
4158 4550
4159 4551 ulimit [-HSacdfmnpstv] [ limit]
4160 4552
4161 4553 Set or display a resource limit. Many systems do not support one or
4162 4554 more of these limits. The limit for a specified resource is set
4163 4555 when limit is specified. The value of limit can be a number in the
4164 4556 unit specified with each resource, or the value unlimited. When
4165 4557 more than one resource is specified, then the limit name and unit
4166 4558 is printed before the value.
4167 4559
4168 4560 If no option is specified, -f is assumed.
4169 4561
4170 4562 The following are the available resource limits:
4171 4563
4172 4564 -a
4173 4565 Lists all of the current resource limits.
4174 4566
4175 4567
4176 4568 -c
4177 4569 The number of 512-byte blocks on the size of core dumps.
4178 4570
4179 4571
4180 4572 -d
4181 4573 The number of Kbytes on the size of the data area.
4182 4574
4183 4575
4184 4576 -f
4185 4577 The number of 512-byte blocks on files that can be written by
4186 4578 the current process or by child processes (files of any size
4187 4579 can be read).
4188 4580
4189 4581
4190 4582 -H
4191 4583 Specifies a hard limit for the specified resource.
4192 4584
4193 4585 A hard limit cannot be increased once it is set.
4194 4586
4195 4587 If neither the -H nor -S option is specified, the limit
4196 4588 applies to both. The current resource limit is printed when
4197 4589 limit is omitted. In this case, the soft limit is printed
4198 4590 unless -H is specified.
4199 4591
4200 4592
4201 4593 -m
4202 4594 The number of Kbytes on the size of physical memory.
4203 4595
4204 4596
4205 4597 -n
4206 4598 The number of file descriptors plus 1.
4207 4599
4208 4600
4209 4601 -p
4210 4602 The number of 512-byte blocks for pipe buffering.
4211 4603
4212 4604
4213 4605 -s
4214 4606 The number of Kbytes on the size of the stack area.
4215 4607
4216 4608
4217 4609 -S
4218 4610 Specifies a soft limit for the specified resource.
4219 4611
4220 4612 A soft limit can be increased up to the value of the hard
4221 4613 limit.
4222 4614
4223 4615 If neither the -H nor -S option is specified, the limit
4224 4616 applies to both. The current resource limit is printed when
4225 4617 limit is omitted. In this case, the soft limit is printed
4226 4618 unless -H is specified.
4227 4619
4228 4620
4229 4621 -t
4230 4622 The number of CPU seconds to be used by each process.
4231 4623
4232 4624
4233 4625 -v
4234 4626 The number of Kbytes for virtual memory.
4235 4627
4236 4628
4237 4629
4238 4630 umask [-S][mask]
4239 4631
4240 4632 The user file-creation mask is set to mask. mask can either be an
4241 4633 octal number or a symbolic value as described in chmod(1).
4242 4634
4243 4635 If a symbolic value is specified, the new umask value is the
4244 4636 complement of the result of applying mask to the complement of the
4245 4637 previous umask value. If mask is omitted, the current value of the
4246 4638 mask is printed. The -S option causes the mode to be printed as a
4247 4639 symbolic value. Otherwise, the mask is printed in octal.
4248 4640
4249 4641 See umask(2)
4250 4642
4251 4643
4252 4644 +unalias [-a] name
4253 4645
4254 4646 The aliases specified by the list of names are removed from the
4255 4647 alias list. The -a option causes all the aliases to be unset.
4256 4648
4257 4649
4258 4650 +unset [-fnv] vname
4259 4651
4260 4652 The variables specified by the list of vnames are unassigned, i.e.,
4261 4653 their values and attributes are erased. Read-only variables cannot
4262 4654 be unset. If the -f option is set, then the names refer to function
4263 4655 names. If the -v option is set, then the names refer to variable
4264 4656 names. The -f option overrides -v. If -n is set and name is a name
4265 4657 reference, then name is unset rather than the variable that it
4266 4658 references. The default is equivalent to -v. Unsetting LINENO,
4267 4659 MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _ removes
4268 4660 their special meaning even if they are subsequently assigned to.
4269 4661
4270 4662
4271 4663 wait [job]
4272 4664
4273 4665 Wait for the specified job and report its termination status. If
4274 4666 job is not specified, then all currently active child processes are
4275 4667 waited for. The exit status from this command is that of the last
4276 4668 process waited for if job is specified; otherwise it is zero. See
4277 4669 Jobs for a description of the format of job.
4278 4670
4279 4671
4280 4672 whence [-afpv] name ...
4281 4673
4282 4674 For each name, indicate how it would be interpreted if used as a
4283 4675 command name. The -v option produces a more verbose report. The -f
4284 4676 option skips the search for functions. The -p option does a path
4285 4677 search for name even if name is an alias, a function, or a reserved
4286 4678 word. The -a option is similar to the -v option but causes all
4287 4679 interpretations of the specified name to be reported.
4288 4680
4289 4681
4290 4682 Invocation
4291 4683 If the shell is invoked by exec(2), and the first character of argument
4292 4684 zero ($0) is -, then the shell is assumed to be a login shell and
4293 4685 commands are read from /etc/profile and then from either .profile in
4294 4686 the current directory or $HOME/.profile, if either file exists. Next,
4295 4687 for interactive shells, commands are read first from /etc/ksh.kshrc,
4296 4688 and then from the file named by performing parameter expansion, command
4297 4689 substitution, and arithmetic substitution on the value of the
4298 4690 environment variable ENV if the file exists. If the -s option is not
4299 4691 present and arg and a file by the name of arg exists, then it reads and
4300 4692 executes this script. Otherwise, if the first arg does not contain a /,
4301 4693 a path search is performed on the first arg to determine the name of
4302 4694 the script to execute. The script arg must have execute permission and
4303 4695 any setuid and setgid settings are ignored. If the script is not found
4304 4696 on the path, arg is processed as if it named a built-in command or
4305 4697 function.
4306 4698
4307 4699
4308 4700 Commands are then read as described, and the following options are
4309 4701 interpreted by the shell when it is invoked:
4310 4702
4311 4703 -c
4312 4704 If the -c option is present, then commands are read from
4313 4705 the first arg. Any remaining arguments become positional
4314 4706 parameters starting at 0.
↓ open down ↓ |
157 lines elided |
↑ open up ↑ |
4315 4707
4316 4708
4317 4709 -D
4318 4710 A list of all double quoted strings that are preceded by
4319 4711 a $ is printed on standard output and the shell exits.
4320 4712 This set of strings is subject to language translation
4321 4713 when the locale is not C or POSIX. No commands are
4322 4714 executed.
4323 4715
4324 4716
4717 + -E
4718 + Reads the file named by the ENV variable or by
4719 + $HOME/.kshrc if not defined after the profiles.
4720 +
4721 +
4325 4722 -i
4326 4723 If the -i option is present or if the shell input and
4327 4724 output are attached to a terminal (as told by
4328 4725 tcgetattr(3C), this shell is interactive. In this case
4329 4726 TERM is ignored (so that kill 0 does not kill an
4330 4727 interactive shell) and INTR is caught and ignored (so
4331 4728 that wait is interruptible). In all cases, QUIT is
4332 4729 ignored by the shell.
4333 4730
4334 4731
4732 + -P
4733 + If -P or -o profile is present, the shell is a profile
4734 + shell (see pfexec(1)).
4735 +
4736 +
4335 4737 -R filename
4336 4738 The -R filename option is used to generate a cross
4337 4739 reference database that can be used by a separate
4338 4740 utility to find definitions and references for variables
4339 4741 and commands.
4340 4742
4341 4743
4342 4744 -r
4343 4745 If the -r option is present, the shell is a restricted
4344 4746 shell.
4345 4747
4346 4748
4347 4749 -s
4348 4750 If the -s option is present or if no arguments remain,
4349 4751 then commands are read from the standard input. Shell
4350 4752 output, except for the output of the Special Commands
4351 4753 listed, is written to file descriptor 2.
4352 4754
4353 4755
4354 4756
4355 4757 The remaining options and arguments are described under the set
4356 4758 command. An optional - as the first argument is ignored.
4357 4759
4358 4760 rksh93 Only
4359 4761 rksh93 is used to set up login names and execution environments whose
4360 4762 capabilities are more controlled than those of the standard shell.
4361 4763
4362 4764
4363 4765 The actions of rksh93 are identical to those of ksh93, except that the
4364 4766 following are disallowed:
4365 4767
4366 4768 o Unsetting the restricted option
4367 4769
4368 4770 o Changing directory. See cd(1).
4369 4771
4370 4772 o Setting or unsetting the value or attributes of SHELL, ENV,
4371 4773 FPATH, or PATH
4372 4774
4373 4775 o Specifying path or command names containing /,
4374 4776
4375 4777 o Redirecting output (>, >|, <>, and >>).
4376 4778
4377 4779 o Adding or deleting built-in commands.
4378 4780
4379 4781 o Using command -p to invoke a command.
4380 4782
4381 4783
4382 4784 These restrictions are enforced after .profile and the ENV files are
4383 4785 interpreted.
4384 4786
4385 4787
4386 4788 When a command to be executed is found to be a shell procedure, rksh93
4387 4789 invokes ksh93 to execute it. Thus, it is possible to provide to the
4388 4790 end-user shell procedures that have access to the full power of the
4389 4791 standard shell, while imposing a limited menu of commands. This scheme
4390 4792 assumes that the end-user does not have write and execute permissions
4391 4793 in the same directory. The net effect of these rules is that the writer
4392 4794 of the .profile has complete control over user actions, by performing
4393 4795 guaranteed setup actions and leaving the user in an appropriate
4394 4796 directory (probably not the login directory). The system administrator
4395 4797 often sets up a directory of commands, for example, /usr/rbin, that can
4396 4798 be safely invoked by rksh.
4397 4799
4398 4800 USAGE
4399 4801 See largefile(5) for the description of the behavior of ksh93 and
4400 4802 rksh93 when encountering files greater than or equal to 2 Gbyte ( 2^31
4401 4803 bytes).
4402 4804
4403 4805 EXIT STATUS
4404 4806 The following exit values are returned:
4405 4807
4406 4808 non-zero
4407 4809
4408 4810 Returns non-zero when errors, such as syntax errors, are detected
4409 4811 by the shell.
4410 4812
4411 4813 If the shell is being used non-interactively, then execution of the
4412 4814 shell file is abandoned unless the error occurs inside a sub-shell
4413 4815 in which case the sub-shell is abandoned.
4414 4816
4415 4817
4416 4818 exit status of last command executed
4417 4819
4418 4820 Returns the exit status of the last command executed.
4419 4821
4420 4822 Run time errors detected by the shell are reported by printing the
4421 4823 command or function name and the error condition. If the line
4422 4824 number that the error occurred on is greater than one, then the
4423 4825 line number is also printed in square brackets ([]) after the
4424 4826 command or function name.
4425 4827
4426 4828 See the ksh93 exit command for additional details.
4427 4829
4428 4830
4429 4831 FILES
4430 4832 /etc/profile
4431 4833
4432 4834 The system initialization file, executed for login shells.
4433 4835
4434 4836
4435 4837 /etc/ksh.kshrc
4436 4838
4437 4839 The system wide startup file, executed for interactive shells.
4438 4840
4439 4841
4440 4842 $HOME/.profile
4441 4843
4442 4844 The personal initialization file, executed for login shells after
4443 4845 /etc/profile.
4444 4846
4445 4847
4446 4848 $HOME/.kshrc
4447 4849
4448 4850 Default personal initialization file, executed after
4449 4851 /etc/ksh.kshrc, for interactive shells when ENV is not set.
4450 4852
4451 4853
4452 4854 /etc/suid-profile
4453 4855
4454 4856 Alternative initialization file, executed instead of the personal
4455 4857 initialization file when the real and effective user or group id do
4456 4858 not match.
4457 4859
4458 4860
4459 4861 /dev/null
4460 4862
4461 4863 NULL device.
4462 4864
4463 4865
4464 4866 AUTHORS
4465 4867 David Korn, dgk@research.att.com
4466 4868
4467 4869 ATTRIBUTES
4468 4870 See attributes(5) for descriptions of the following attributes:
4469 4871
4470 4872
4471 4873
4472 4874
4473 4875 +--------------------+-----------------+
4474 4876 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
↓ open down ↓ |
130 lines elided |
↑ open up ↑ |
4475 4877 +--------------------+-----------------+
4476 4878 |Interface Stability | See below. |
4477 4879 +--------------------+-----------------+
4478 4880
4479 4881
4480 4882 The scripting interface is Uncommitted. The environment variables,
4481 4883 .paths feature, and editing modes are Volatile.
4482 4884
4483 4885 SEE ALSO
4484 4886 cat(1), cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1), egrep(1),
4485 - env(1), fgrep(1), grep(1), login(1), newgrp(1), paste(1), printf(1),
4486 - stty(1), test(1), umask(1), vi(1), dup(2), exec(2), fork(2), ioctl(2),
4487 - lseek(2), pathconf(2), pipe(2), sysconf(3C), ulimit(2), umask(2),
4488 - rand(3C), tcgetattr(3C), wait(3C), a.out(4), profile(4), attributes(5),
4489 - environ(5), largefile(5), standards(5)
4887 + env(1), fgrep(1), grep(1), login(1), newgrp(1), paste(1), pfexec(1),
4888 + printf(1), stty(1), test(1), umask(1), vi(1), dup(2), exec(2), fork(2),
4889 + ioctl(2), lseek(2), pathconf(2), pipe(2), sysconf(3C), ulimit(2),
4890 + umask(2), rand(3C), tcgetattr(3C), wait(3C), a.out(4), profile(4),
4891 + attributes(5), environ(5), largefile(5), standards(5)
4490 4892
4491 4893
4492 4894 Bolsky, Morris I. and Korn, David G., The New KornShell Command and
4493 4895 Programming Language, Prentice Hall, 1995.
4494 4896
4495 4897
4496 4898 POSIX-Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC
4497 4899 9945-2, IEEE, 1993.
4498 4900
4499 4901 NOTES
4500 4902 ksh93 scripts should choose shell function names outside the namespace
4501 4903 used by reserved keywords of the ISO C99, C++ and JAVA languages to
4502 4904 avoid collisions with future enhancements to ksh93.
4503 4905
4504 4906
4505 4907 If a command is executed, and then a command with the same name is
4506 4908 installed in a directory in the search path before the directory where
4507 4909 the original command was found, the shell continues to exec the
4508 4910 original command. Use the -t option of the alias command to correct
4509 4911 this situation.
4510 4912
4511 4913
4512 4914 Some very old shell scripts contain a caret (^) as a synonym for the
4513 4915 pipe character (|).
4514 4916
4515 4917
4516 4918 Using the hist built-in command within a compound command causes the
4517 4919 whole command to disappear from the history file.
4518 4920
4519 4921
4520 4922 The built-in command . file reads the whole file before any commands
4521 4923 are executed. alias and unalias commands in the file do not apply to
4522 4924 any commands defined in the file.
4523 4925
4524 4926
4525 4927 Traps are not processed while a job is waiting for a foreground
4526 4928 process. Thus, a trap on CHLD is not executed until the foreground job
4527 4929 terminates.
4528 4930
4529 4931
4530 4932 It is a good idea to leave a space after the comma operator in
4531 4933 arithmetic expressions to prevent the comma from being interpreted as
4532 4934 the decimal point character in certain locales.
4533 4935
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
4534 4936
4535 4937 There might be some restrictions on creating a .paths file which is
4536 4938 portable across other operating systems.
4537 4939
4538 4940
4539 4941 If the system supports the 64-bit instruction set, /bin/ksh93 executes
4540 4942 the 64-bit version of ksh93.
4541 4943
4542 4944
4543 4945
4544 - June 27, 2018 KSH93(1)
4946 + January 6, 2020 KSH93(1)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX