1KSH(1) General Commands Manual KSH(1)
2
3
4
6 ksh, rksh, pfksh - KornShell, a standard/restricted command and pro‐
7 gramming language
8
10 [ ±abcefhikmnoprstuvxBCDP ] [ -R file ] [ ±o option ] ... [ - ] [ arg
11 ... ]
12 rksh [ ±abcefhikmnoprstuvxBCD ] [ -R file ] [ ±o option ] ... [ - ] [
13 arg ... ]
14
16 Ksh is a command and programming language that executes commands read
17 from a terminal or a file. Rksh is a restricted version of the command
18 interpreter ksh; it is used to set up login names and execution envi‐
19 ronments whose capabilities are more controlled than those of the stan‐
20 dard shell. Rpfksh is a profile shell version of the command inter‐
21 preter ksh; it is used to to execute commands with the attributes spec‐
22 ified by the user's profiles (see pfexec(1)). See Invocation below for
23 the meaning of arguments to the shell.
24
25 Definitions.
26 A metacharacter is one of the following characters:
27
28 ; & ( ) ⎪ < > new-line space tab
29
30 A blank is a tab or a space. An identifier is a sequence of letters,
31 digits, or underscores starting with a letter or underscore. Identi‐
32 fiers are used as components of variable names. A vname is a sequence
33 of one or more identifiers separated by a . and optionally preceded by
34 a .. Vnames are used as function and variable names. A word is a
35 sequence of characters from the character set defined by the current
36 locale, excluding non-quoted metacharacters.
37
38 A command is a sequence of characters in the syntax of the shell lan‐
39 guage. The shell reads each command and carries out the desired action
40 either directly or by invoking separate utilities. A built-in command
41 is a command that is carried out by the shell itself without creating a
42 separate process. Some commands are built-in purely for convenience
43 and are not documented here. Built-ins that cause side effects in the
44 shell environment and built-ins that are found before performing a path
45 search (see Execution below) are documented here. For historical rea‐
46 sons, some of these built-ins behave differently than other built-ins
47 and are called special built-ins.
48
49 Commands.
50 A simple-command is a list of variable assignments (see Variable
51 Assignments below) or a sequence of blank separated words which may be
52 preceded by a list of variable assignments (see Environment below).
53 The first word specifies the name of the command to be executed.
54 Except as specified below, the remaining words are passed as arguments
55 to the invoked command. The command name is passed as argument 0 (see
56 exec(2)). The value of a simple-command is its exit status; 0-255 if
57 it terminates normally; 256+signum if it terminates abnormally (the
58 name of the signal corresponding to the exit status can be obtained via
59 the -l option of the kill built-in utility).
60
61 A pipeline is a sequence of one or more commands separated by ⎪. The
62 standard output of each command but the last is connected by a pipe(2)
63 to the standard input of the next command. Each command, except possi‐
64 bly the last, is run as a separate process; the shell waits for the
65 last command to terminate. The exit status of a pipeline is the exit
66 status of the last command unless the pipefail option is enabled. Each
67 pipeline can be preceded by the reserved word ! which causes the exit
68 status of the pipeline to become 0 if the exit status of the last com‐
69 mand is non-zero, and 1 if the exit status of the last command is 0.
70
71 A list is a sequence of one or more pipelines separated by ;, &, ⎪&,
72 &&, or ⎪⎪, and optionally terminated by ;, &, or ⎪&. Of these five
73 symbols, ;, &, and ⎪& have equal precedence, which is lower than that
74 of && and ⎪⎪. The symbols && and ⎪⎪ also have equal precedence. A
75 semicolon (;) causes sequential execution of the preceding pipeline; an
76 ampersand (&) causes asynchronous execution of the preceding pipeline
77 (i.e., the shell does not wait for that pipeline to finish). The sym‐
78 bol ⎪& causes asynchronous execution of the preceding pipeline with a
79 two-way pipe established to the parent shell; the standard input and
80 output of the spawned pipeline can be written to and read from by the
81 parent shell by applying the redirection operators <& and >& with arg p
82 to commands and by using -p option of the built-in commands read and
83 print described later. The symbol && (⎪⎪) causes the list following it
84 to be executed only if the preceding pipeline returns a zero (non-zero)
85 value. One or more new-lines may appear in a list instead of a semi‐
86 colon, to delimit a command. The first item of the first pipeline of
87 a list that is a simple command not beginning with a redirection, and
88 not occuring within a while, until, or if list, can be prededed by a
89 semicolon. This semicolon is ignored unless the showme option is
90 enabled as described with the set built-in below.
91
92 A command is either a simple-command or one of the following. Unless
93 otherwise stated, the value returned by a command is that of the last
94 simple-command executed in the command.
95
96 for vname [ in word ... ] ;do list ;done
97 Each time a for command is executed, vname is set to the next
98 word taken from the in word list. If in word ... is omitted,
99 then the for command executes the do list once for each posi‐
100 tional parameter that is set starting from 1 (see Parameter
101 Expansion below). Execution ends when there are no more words
102 in the list.
103
104 for (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done
105 The arithmetic expression expr1 is evaluated first (see Arith‐
106 metic evaluation below). The arithmetic expression expr2 is
107 repeatedly evaluated until it evaluates to zero and when non-
108 zero, list is executed and the arithmetic expression expr3 eval‐
109 uated. If any expression is omitted, then it behaves as if it
110 evaluated to 1.
111
112 select vname [ in word ... ] ;do list ;done
113 A select command prints on standard error (file descriptor 2)
114 the set of words, each preceded by a number. If in word ... is
115 omitted, then the positional parameters starting from 1 are used
116 instead (see Parameter Expansion below). The PS3 prompt is
117 printed and a line is read from the standard input. If this
118 line consists of the number of one of the listed words, then the
119 value of the variable vname is set to the word corresponding to
120 this number. If this line is empty, the selection list is
121 printed again. Otherwise the value of the variable vname is set
122 to null. The contents of the line read from standard input is
123 saved in the variable REPLY. The list is executed for each
124 selection until a break or end-of-file is encountered. If the
125 REPLY variable is set to null by the execution of list, then the
126 selection list is printed before displaying the PS3 prompt for
127 the next selection.
128
129 case word in [ [(]pattern [ ⎪ pattern ] ... ) list ;; ] ... esac
130 A case command executes the list associated with the first pat‐
131 tern that matches word. The form of the patterns is the same as
132 that used for file-name generation (see File Name Generation
133 below). The ;; operator causes execution of case to terminate.
134 If ;& is used in place of ;; the next subsequent list, if any,
135 is executed.
136
137 if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi
138 The list following if is executed and, if it returns a zero exit
139 status, the list following the first then is executed. Other‐
140 wise, the list following elif is executed and, if its value is
141 zero, the list following the next then is executed. Failing
142 each successive elif list, the else list is executed. If the if
143 list has non-zero exit status and there is no else list, then
144 the if command returns a zero exit status.
145
146 while list ;do list ;done
147 until list ;do list ;done
148 A while command repeatedly executes the while list and, if the
149 exit status of the last command in the list is zero, executes
150 the do list; otherwise the loop terminates. If no commands in
151 the do list are executed, then the while command returns a zero
152 exit status; until may be used in place of while to negate the
153 loop termination test.
154
155 ((expression))
156 The expression is evaluated using the rules for arithmetic eval‐
157 uation described below. If the value of the arithmetic expres‐
158 sion is non-zero, the exit status is 0, otherwise the exit sta‐
159 tus is 1.
160
161 (list)
162 Execute list in a separate environment. Note, that if two adja‐
163 cent open parentheses are needed for nesting, a space must be
164 inserted to avoid evaluation as an arithmetic command as
165 described above.
166
167 { list;}
168 list is simply executed. Note that unlike the metacharacters (
169 and ), { and } are reserved words and must occur at the begin‐
170 ning of a line or after a ; in order to be recognized.
171
172 [[ expression ]]
173 Evaluates expression and returns a zero exit status when expres‐
174 sion is true. See Conditional Expressions below, for a descrip‐
175 tion of expression.
176
177 function varname { list ;}
178 varname () { list ;}
179 Define a function which is referenced by varname. A function
180 whose varname contains a . is called a discipline function and
181 the portion of the varname preceding the last . must refer to
182 an existing variable. The body of the function is the list of
183 commands between { and }. A function defined with the function
184 varname syntax can also be used as an argument to the . special
185 built-in command to get the equivalent behavior as if the var‐
186 name() syntax were used to define it. (See Functions below.)
187
188 time [ pipeline ]
189 If pipeline is omitted the user and system time for the current
190 shell and completed child processes is printed on standard
191 error. Otherwise, pipeline is executed and the elapsed time as
192 well as the user and system time are printed on standard error.
193 The TIMEFORMAT variable may be set to a format string that spec‐
194 ifies how the timing information should be displayed. See Shell
195 Variables below for a description of the TIMEFORMAT variable.
196
197 The following reserved words are recognized as reserved only when they
198 are the first word of a command and are not quoted:
199
200 if then else elif fi case esac for while until do done { } function
201 select time [[ ]] !
202
203 Variable Assignments.
204 One or more variable assignments can start a simple command or can be
205 arguments to the typeset, export, or readonly special built-in com‐
206 mands. The syntax for an assignment is of the form:
207
208 varname=word
209 varname[word]=word
210 No space is permitted between varname and the = or between = and
211 word.
212
213 varname=(assign_list)
214 No space is permitted between varname and the =. An assign_list
215 can be one of the following:
216 word ...
217 Indexed array assignment.
218 [word]=word ...
219 Associative array assignment. If preceded by
220 typeset -a this will create an indexed array
221 instead.
222 assignment ...
223 Compound variable assignment. This creates a
224 compound variable varname with sub-variables of
225 the form varname.name, where name is the name
226 portion of assignment. The value of varname will
227 contain all the assignment elements. Additional
228 assignments made to sub-variables of varname will
229 also be displayed as part of the value of var‐
230 name. If no assignments are specified, varname
231 will be a compound variable allowing subsequence
232 child elements to be defined.
233 typeset [options] assignment ...
234 Nested variable assignment. Multiple assignments
235 can be specified by separating each of them with
236 a ;. The previous value is unset before the
237 assignment.
238
239 In addition, a += can be used in place of the = to signify adding to or
240 appending to the previous value. When += is applied to an arithmetic
241 type, word is evaluated as an arithmetic expression and added to the
242 current value. When applied to a string variable, the value defined by
243 word is appended to the value. For compound assignments, the previous
244 value is not unset and the new values are appended to the current ones
245 provided that the types are compatible.
246
247 Comments.
248 A word beginning with # causes that word and all the following charac‐
249 ters up to a new-line to be ignored.
250 Aliasing.
251 The first word of each command is replaced by the text of an alias if
252 an alias for this word has been defined. An alias name consists of any
253 number of characters excluding metacharacters, quoting characters, file
254 expansion characters, parameter expansion and command substitution
255 characters, and =. The replacement string can contain any valid shell
256 script including the metacharacters listed above. The first word of
257 each command in the replaced text, other than any that are in the
258 process of being replaced, will be tested for aliases. If the last
259 character of the alias value is a blank then the word following the
260 alias will also be checked for alias substitution. Aliases can be used
261 to redefine built-in commands but cannot be used to redefine the
262 reserved words listed above. Aliases can be created and listed with
263 the alias command and can be removed with the unalias command.
264 Aliasing is performed when scripts are read, not while they are exe‐
265 cuted. Therefore, for an alias to take effect, the alias definition
266 command has to be executed before the command which references the
267 alias is read.
268 The following aliases are compiled into the shell but can be unset or
269 redefined:
270 autoload=′typeset -fu′
271 command=′command ′
272 fc=hist
273 float=′typeset -lE′
274 functions=′typeset -f′
275 hash=′alias -t --′
276 history=′hist -l′
277 integer=′typeset -li′
278 nameref=′typeset -n′
279 nohup=′nohup ′
280 r=′hist -s′
281 redirect=′command exec′
282 source=′command .′
283 stop=′kill -s STOP′
284 suspend=′kill -s STOP $$′
285 times=′{ { time;} 2>&1;}′
286 type=′whence -v′
287
288 Tilde Substitution.
289 After alias substitution is performed, each word is checked to see if
290 it begins with an unquoted ∼. For tilde substitution, word also refers
291 to the word portion of parameter expansion (see Parameter Expansion
292 below). If it does, then the word up to a / is checked to see if it
293 matches a user name in the password database (See getpwname(3).) If a
294 match is found, the ∼ and the matched login name are replaced by the
295 login directory of the matched user. If no match is found, the origi‐
296 nal text is left unchanged. A ∼ by itself, or in front of a /, is
297 replaced by $HOME. A ∼ followed by a + or - is replaced by the value
298 of $PWD and $OLDPWD respectively.
299
300 In addition, when expanding a variable assignment, tilde substitution
301 is attempted when the value of the assignment begins with a ∼, and when
302 a ∼ appears after a :. The : also terminates a ∼ login name.
303
304 Command Substitution.
305 The standard output from a command enclosed in parentheses preceded by
306 a dollar sign ( $() ) or a pair of grave accents (``) may be used as
307 part or all of a word; trailing new-lines are removed. In the second
308 (obsolete) form, the string between the quotes is processed for special
309 quoting characters before the command is executed (see Quoting below).
310 The command substitution $(cat file) can be replaced by the equivalent
311 but faster $(<file). The command substitution $(n<#) will expand to
312 the current byte offset for file descriptor n.
313
314 Arithmetic Substitution.
315 An arithmetic expression enclosed in double parentheses preceded by a
316 dollar sign ( $(()) ) is replaced by the value of the arithmetic
317 expression within the double parentheses.
318
319 Process Substitution.
320 This feature is only available on versions of the UNIX operating system
321 that support the /dev/fd directory for naming open files. Each command
322 argument of the form <(list) or >(list) will run process list asyn‐
323 chronously connected to some file in /dev/fd. The name of this file
324 will become the argument to the command. If the form with > is
325 selected then writing on this file will provide input for list. If <
326 is used, then the file passed as an argument will contain the output of
327 the list process. For example,
328
329 paste <(cut -f1 file1) <(cut -f3 file2) | tee >(process1)
330 >(process2)
331
332 cuts fields 1 and 3 from the files file1 and file2 respectively, pastes
333 the results together, and sends it to the processes process1 and
334 process2, as well as putting it onto the standard output. Note that
335 the file, which is passed as an argument to the command, is a UNIX
336 pipe(2) so programs that expect to lseek(2) on the file will not work.
337
338 Parameter Expansion.
339 A parameter is a variable, one or more digits, or any of the characters
340 ∗, @, #, ?, -, $, and !. A variable is denoted by a vname. To create
341 a variable whose vname contains a ., a variable whose vname consists of
342 everything before the last . must already exist. A variable has a
343 value and zero or more attributes. Variables can be assigned values
344 and attributes by using the typeset special built-in command. The
345 attributes supported by the shell are described later with the typeset
346 special built-in command. Exported variables pass values and
347 attributes to the environment.
348
349 The shell supports both indexed and associative arrays. An element of
350 an array variable is referenced by a subscript. A subscript for an
351 indexed array is denoted by an arithmetic expression (see Arithmetic
352 evaluation below) between a [ and a ]. To assign values to an indexed
353 array, use set -A vname value ... . The value of all subscripts must
354 be in the range of 0 through 1,048,575. Indexed arrays need not be
355 declared. Any reference to a variable with a valid subscript is legal
356 and an array will be created if necessary.
357
358 An associative array is created with the -A option to typeset. A sub‐
359 script for an associative array is denoted by a string enclosed between
360 [ and ].
361
362 Referencing any array without a subscript is equivalent to referencing
363 the array with subscript 0.
364
365 The value of a variable may be assigned by writing:
366
367 vname=value [ vname=value ] ...
368
369 or
370 vname[subscript]=value [ vname[subscript]=value ] ...
371 Note that no space is allowed before or after the =.
372 A nameref is a variable that is a reference to another variable. A
373 nameref is created with the -n attribute of typeset. The value of the
374 variable at the time of the typeset command becomes the variable that
375 will be referenced whenever the nameref variable is used. The name of
376 a nameref cannot contain a .. When a variable or function name con‐
377 tains a ., and the portion of the name up to the first . matches the
378 name of a nameref, the variable referred to is obtained by replacing
379 the nameref portion with the name of the variable referenced by the
380 nameref. If a nameref is used as the index of a for loop, a name ref‐
381 erence is established for each item in the list. A nameref provides a
382 convenient way to refer to the variable inside a function whose name is
383 passed as an argument to a function. For example, if the name of a
384 variable is passed as the first argument to a function, the command
385 typeset -n var=$1
386 inside the function causes references and assignments to var to be ref‐
387 erences and assignments to the variable whose name has been passed to
388 the function.
389 If either of the floating point attributes, -E, or -F, or the integer
390 attribute, -i, is set for vname, then the value is subject to arith‐
391 metic evaluation as described below.
392 Positional parameters, parameters denoted by a number, may be assigned
393 values with the set special built-in command. Parameter $0 is set from
394 argument zero when the shell is invoked.
395 The character $ is used to introduce substitutable parameters.
396 ${parameter}
397 The shell reads all the characters from ${ to the matching } as
398 part of the same word even if it contains braces or metacharac‐
399 ters. The value, if any, of the parameter is substituted. The
400 braces are required when parameter is followed by a letter,
401 digit, or underscore that is not to be interpreted as part of
402 its name, when the variable name contains a ., or when a vari‐
403 able is subscripted. If parameter is one or more digits then it
404 is a positional parameter. A positional parameter of more than
405 one digit must be enclosed in braces. If parameter is ∗ or @,
406 then all the positional parameters, starting with $1, are sub‐
407 stituted (separated by a field separator character). If an
408 array vname with subscript ∗ or @ is used, then the value for
409 each of the elements is substituted, separated by the first
410 character of the value of IFS.
411 ${#parameter}
412 If parameter is ∗ or @, the number of positional parameters is
413 substituted. Otherwise, the length of the value of the parame‐
414 ter is substituted.
415 ${#vname[*]}
416 ${#vname[@]}
417 The number of elements in the array vname is substituted.
418
419 ${!vname}
420 Expands to the name of the variable referred to by vname. This
421 will be vname except when vname is a name reference.
422
423 ${!vname[subscript]}
424 Expands to name of the subscript unless subscript is * or @.
425 When subscript is *, the list of array subscripts for vname is
426 generated. For a variable that is not an array, the value is 0
427 if the variable is set. Otherwise it is null. When subscript
428 is @, same as above, except that when used in double quotes,
429 each array subscript yields a separate argument.
430
431 ${!prefix*}
432 Expands to the names of the variables whose names begin with
433 prefix.
434
435 ${parameter:-word}
436 If parameter is set and is non-null then substitute its value;
437 otherwise substitute word.
438
439 ${parameter:=word}
440 If parameter is not set or is null then set it to word; the
441 value of the parameter is then substituted. Positional parame‐
442 ters may not be assigned to in this way.
443
444 ${parameter:?word}
445 If parameter is set and is non-null then substitute its value;
446 otherwise, print word and exit from the shell (if not interac‐
447 tive). If word is omitted then a standard message is printed.
448
449 ${parameter:+word}
450 If parameter is set and is non-null then substitute word; other‐
451 wise substitute nothing.
452
453 In the above, word is not evaluated unless it is to be used as the sub‐
454 stituted string, so that, in the following example, pwd is executed
455 only if d is not set or is null:
456
457 print ${d:-$(pwd)}
458
459 If the colon ( : ) is omitted from the above expressions, then the
460 shell only checks whether parameter is set or not.
461
462 ${parameter:offset:length}
463 ${parameter:offset}
464 Expands to the portion of the value of parameter starting at the
465 character (counting from 0) determined by expanding offset as an
466 arithmetic expression and consisting of the number of characters
467 determined by the arithmetic expression defined by length. In
468 the second form, the remainder of the value is used. If A nega‐
469 tive offset counts backwards from the end of parameter. Note
470 that one or more blanks is required in front of a minus sign to
471 prevent the shell from interpreting the operator as :-. If
472 parameter is ∗ or @, or is an array name indexed by ∗ or @, then
473 offset and length refer to the array index and number of ele‐
474 ments respectively. A negative offset is taken relative to one
475 greater than the highest subscript for indexed arrays. The
476 order for associate arrays is unspecified.
477 ${parameter#pattern}
478 ${parameter##pattern}
479 If the shell pattern matches the beginning of the value of
480 parameter, then the value of this expansion is the value of the
481 parameter with the matched portion deleted; otherwise the value
482 of this parameter is substituted. In the first form the small‐
483 est matching pattern is deleted and in the second form the
484 largest matching pattern is deleted. When parameter is @, *, or
485 an array variable with subscript @ or *, the substring operation
486 is applied to each element in turn.
487
488 ${parameter%pattern}
489 ${parameter%%pattern}
490 If the shell pattern matches the end of the value of parameter,
491 then the value of this expansion is the value of the parameter
492 with the matched part deleted; otherwise substitute the value of
493 parameter. In the first form the smallest matching pattern is
494 deleted and in the second form the largest matching pattern is
495 deleted. When parameter is @, *, or an array variable with sub‐
496 script @ or *, the substring operation is applied to each ele‐
497 ment in turn.
498
499 ${parameter/pattern/string}
500 ${parameter//pattern/string}
501 ${parameter/#pattern/string}
502 ${parameter/%pattern/string}
503 Expands parameter and replaces the longest match of pattern with
504 the given string. Each occurrence of \n in string is replaced
505 by the portion of parameter that matches the n-th sub-pattern.
506 In the first form, only the first occurrence of pattern is
507 replaced. In the second form, each match for pattern is
508 replaced by the given string. The third form restricts the pat‐
509 tern match to the beginning of the string while the fourth form
510 restricts the pattern match to the end of the string. When
511 string is null, the pattern will be deleted and the / in front
512 of string may be omitted. When parameter is @, *, or an array
513 variable with subscript @ or *, the substitution operation is
514 applied to each element in turn. In this case, the string por‐
515 tion of word will be re-evaluated for each element.
516
517 The following parameters are automatically set by the shell:
518 # The number of positional parameters in decimal.
519 - Options supplied to the shell on invocation or by the set
520 command.
521 ? The decimal value returned by the last executed command.
522 $ The process number of this shell.
523 _ Initially, the value of _ is an absolute pathname of the
524 shell or script being executed as passed in the environ‐
525 ment. Subsequently it is assigned the last argument of
526 the previous command. This parameter is not set for com‐
527 mands which are asynchronous. This parameter is also
528 used to hold the name of the matching MAIL file when
529 checking for mail.
530 ! The process number of the last background command invoked
531 or the most recent job put in the background with the bg
532 built-in command.
533 .sh.command
534 When processing a DEBUG trap, this variable contains the
535 current command line that is about to run.
536 .sh.edchar
537 This variable contains the value of the keyboard charac‐
538 ter (or sequence of characters if the first character is
539 an ESC, ascii 033) that has been entered when processing
540 a KEYBD trap (see Key Bindings below). If the value is
541 changed as part of the trap action, then the new value
542 replaces the key (or key sequence) that caused the trap.
543 .sh.edcol
544 The character position of the cursor at the time of the
545 most recent KEYBD trap.
546 .sh.edmode
547 The value is set to ESC when processing a KEYBD trap
548 while in vi insert mode. (See Vi Editing Mode below.)
549 Otherwise, .sh.edmode is null when processing a KEYBD
550 trap.
551 .sh.edtext
552 The characters in the input buffer at the time of the
553 most recent KEYBD trap. The value is null when not pro‐
554 cessing a KEYBD trap.
555 .sh.file
556 The pathname of the file than contains the current com‐
557 mand.
558 .sh.fun
559 The name of the current function that is being executed.
560 .sh.match
561 An indexed array which stores the most recent match and
562 sub-pattern matches after conditional pattern matches
563 that match and after variables expansions using the oper‐
564 ators #, %, or /. The 0-th element stores the complete
565 match and the i-th. element stores the i-th submatch.
566 The .sh.match variable becomes unset when the variable
567 that has expanded is assigned a new value.
568 .sh.name
569 Set to the name of the variable at the time that a disci‐
570 pline function is invoked.
571 .sh.subscript
572 Set to the name subscript of the variable at the time
573 that a discipline function is invoked.
574 .sh.subshell
575 The current depth for subshells and command substitution.
576 .sh.value
577 Set to the value of the variable at the time that the set
578 or append discipline function is invoked.
579 .sh.version
580 Set to a value that identifies the version of this shell.
581 LINENO The current line number within the script or function
582 being executed.
583 OLDPWD The previous working directory set by the cd command.
584 OPTARG The value of the last option argument processed by the
585 getopts built-in command.
586 OPTIND The index of the last option argument processed by the
587 getopts built-in command.
588 PPID The process number of the parent of the shell.
589 PWD The present working directory set by the cd command.
590 RANDOM Each time this variable is referenced, a random integer,
591 uniformly distributed between 0 and 32767, is generated.
592 The sequence of random numbers can be initialized by
593 assigning a numeric value to RANDOM.
594 REPLY This variable is set by the select statement and by the
595 read built-in command when no arguments are supplied.
596 SECONDS
597 Each time this variable is referenced, the number of sec‐
598 onds since shell invocation is returned. If this vari‐
599 able is assigned a value, then the value returned upon
600 reference will be the value that was assigned plus the
601 number of seconds since the assignment.
602
603 The following variables are used by the shell:
604 CDPATH The search path for the cd command.
605 COLUMNS
606 If this variable is set, the value is used to define the
607 width of the edit window for the shell edit modes and for
608 printing select lists.
609 EDITOR If the VISUAL variable is not set, the value of this
610 variable will be checked for the patterns as described
611 with VISUAL below and the corresponding editing option
612 (see Special Command set below) will be turned on.
613 ENV If this variable is set, then parameter expansion, com‐
614 mand substitution, and arithmetic substitution are per‐
615 formed on the value to generate the pathname of the
616 script that will be executed when the shell is invoked
617 (see Invocation below). This file is typically used for
618 alias and function definitions. The default value is
619 $HOME/.kshrc.
620 FCEDIT Obsolete name for the default editor name for the hist
621 command. FCEDIT is not used when HISTEDIT is set.
622 FIGNORE
623 A pattern that defines the set of filenames that will be
624 ignored when performing filename matching.
625 FPATH The search path for function definitions. The directo‐
626 ries in this path are searched for a file with the same
627 name as the function or command when a function with the
628 -u attribute is referenced and when a command is not
629 found. If an executable file with the name of that com‐
630 mand is found, then it is read and executed in the cur‐
631 rent environment. Unlike PATH, the current directory
632 must be represented explictily by . rather than by adja‐
633 cent : characters or a beginning or ending :.
634 HISTCMD
635 Number of the current command in the history file.
636 HISTEDIT
637 Name for the default editor name for the hist command.
638 HISTFILE
639 If this variable is set when the shell is invoked, then
640 the value is the pathname of the file that will be used
641 to store the command history (see Command Re-entry
642 below).
643 HISTSIZE
644 If this variable is set when the shell is invoked, then
645 the number of previously entered commands that are acces‐
646 sible by this shell will be greater than or equal to this
647 number. The default is 512.
648 HOME The default argument (home directory) for the cd command.
649 IFS Internal field separators, normally space, tab, and new-
650 line that are used to separate the results of command
651 substitution or parameter expansion and to separate
652 fields with the built-in command read. The first charac‐
653 ter of the IFS variable is used to separate arguments for
654 the "$∗" substitution (see Quoting below). Each single
655 occurrence of an IFS character in the string to be split,
656 that is not in the isspace character class, and any adja‐
657 cent characters in IFS that are in the isspace character
658 class, delimit a field. One or more characters in IFS
659 that belong to the isspace character class, delimit a
660 field. In addition, if the same isspace character
661 appears consecutively inside IFS, this character is
662 treated as if it were not in the isspace class, so that
663 if IFS consists of two tab characters, then two adjacent
664 tab characters delimit a null field.
665 LANG This variable determines the locale category for any cat‐
666 egory not specifically selected with a variable starting
667 with LC_ or LANG.
668 LC_ALL This variable overrides the value of the LANG variable
669 and any other LC_ variable.
670 LC_COLLATE
671 This variable determines the locale category for charac‐
672 ter collation information.
673 LC_CTYPE
674 This variable determines the locale category for charac‐
675 ter handling functions. It determines the character
676 classes for pattern matching (see File Name Generation
677 below).
678 LC_NUMERIC
679 This variable determines the locale category for the dec‐
680 imal point character.
681 LINES If this variable is set, the value is used to determine
682 the column length for printing select lists. Select
683 lists will print vertically until about two-thirds of
684 LINES lines are filled.
685 MAIL If this variable is set to the name of a mail file and
686 the MAILPATH variable is not set, then the shell informs
687 the user of arrival of mail in the specified file.
688 MAILCHECK
689 This variable specifies how often (in seconds) the shell
690 will check for changes in the modification time of any of
691 the files specified by the MAILPATH or MAIL variables.
692 The default value is 600 seconds. When the time has
693 elapsed the shell will check before issuing the next
694 prompt.
695 MAILPATH
696 A colon ( : ) separated list of file names. If this
697 variable is set, then the shell informs the user of any
698 modifications to the specified files that have occurred
699 within the last MAILCHECK seconds. Each file name can be
700 followed by a ? and a message that will be printed. The
701 message will undergo parameter expansion, command substi‐
702 tution, and arithmetic substitution with the variable $_
703 defined as the name of the file that has changed. The
704 default message is you have mail in $_.
705 PATH The search path for commands (see Execution below). The
706 user may not change PATH if executing under rksh (except
707 in .profile).
708 PS1 The value of this variable is expanded for parameter
709 expansion, command substitution, and arithmetic substitu‐
710 tion to define the primary prompt string which by default
711 is ``$''. The character ! in the primary prompt string
712 is replaced by the command number (see Command Re-entry
713 below). Two successive occurrences of ! will produce a
714 single ! when the prompt string is printed.
715 PS2 Secondary prompt string, by default ``> ''.
716 PS3 Selection prompt string used within a select loop, by
717 default ``#? ''.
718 PS4 The value of this variable is expanded for parameter
719 evaluation, command substitution, and arithmetic substi‐
720 tution and precedes each line of an execution trace. By
721 default, PS4 is ``+ ''. In addition when PS4 is unset,
722 the execution trace prompt is also ``+ ''.
723 SHELL The pathname of the shell is kept in the environment. At
724 invocation, if the basename of this variable is rsh,
725 rksh, or krsh, then the shell becomes restricted. If it
726 is pfsh or pfksh, then the shell becomes a profile shell
727 (see pfexec(1)).
728 TIMEFORMAT
729 The value of this parameter is used as a format string
730 specifying how the timing information for pipelines pre‐
731 fixed with the time reserved word should be displayed.
732 The % character introduces a format sequence that is
733 expanded to a time value or other information. The for‐
734 mat sequences and their meanings are as follows.
735 %% A literal %.
736 %[p][l]R The elapsed time in seconds.
737 %[p][l]U The number of CPU seconds spent in user mode.
738 %[p][l]S The number of CPU seconds spent in system mode.
739 %P The CPU percentage, computed as (U + S) / R.
740
741 The braces denote optional portions. The optional p is a
742 digit specifying the precision, the number of fractional
743 digits after a decimal point. A value of 0 causes no
744 decimal point or fraction to be output. At most three
745 places after the decimal point can be displayed; values
746 of p greater than 3 are treated as 3. If p is not speci‐
747 fied, the value 3 is used.
748
749 The optional l specifies a longer format, including hours
750 if greater than zero, minutes, and seconds of the form
751 HHhMMmSS.FFs. The value of p determines whether or not
752 the fraction is included.
753
754 All other characters are output without change and a
755 trailing newline is added. If unset, the default value,
756 $'\nreal\t%2lR\nuser\t%2lU\nsys%2lS', is used. If the
757 value is null, no timing information is displayed.
758
759 TMOUT If set to a value greater than zero, TMOUT will be the
760 default timeout value for the read built-in command. The
761 select compound command terminates after TMOUT seconds
762 when input is from a terminal. Otherwise, the shell will
763 terminate if a line is not entered within the prescribed
764 number of seconds while reading from a terminal. (Note
765 that the shell can be compiled with a maximum bound for
766 this value which cannot be exceeded.)
767
768 VISUAL If the value of this variable matches the pattern
769 *[Vv][Ii]*, then the vi option (see Special Command set
770 below) is turned on. If the value matches the pattern
771 *gmacs* , the gmacs option is turned on. If the value
772 matches the pattern *macs*, then the emacs option will be
773 turned on. The value of VISUAL overrides the value of
774 EDITOR.
775
776 The shell gives default values to PATH, PS1, PS2, PS3, PS4, MAILCHECK,
777 FCEDIT, TMOUT and IFS, while HOME, SHELL, ENV, and MAIL are not set at
778 all by the shell (although HOME is set by login(1)). On some systems
779 MAIL and SHELL are also set by login(1).
780
781 Field Splitting.
782 After parameter expansion and command substitution, the results of sub‐
783 stitutions are scanned for the field separator characters (those found
784 in IFS) and split into distinct fields where such characters are found.
785 Explicit null fields ("" or ′′) are retained. Implicit null fields
786 (those resulting from parameters that have no values or command substi‐
787 tutions with no output) are removed.
788
789 If the braceexpand (-B) option is set then each of the fields resulting
790 from IFS are checked to see if they contain one or more of the brace
791 patterns {*,*}, {l1..l2} , {n1..n2} , {n1..n2% fmt} , {n1..n2 ..n3} ,
792 or {n1..n2 ..n3%fmt} , where * represents any character, l1,l2 are let‐
793 ters and n1,n2,n3 are signed numbers and fmt is a format specified as
794 used by printf. In each case, fields are created by prepending the
795 characters before the { and appending the characters after the } to
796 each of the strings generated by the characters between the { and }.
797 The resulting fields are checked to see if they have any brace pat‐
798 terns.
799
800 In the first form, a field is created for each string between { and ,,
801 between , and ,, and between , and }. The string represented by * can
802 contain embedded matching { and } without quoting. Otherwise, each {
803 and } with * must be quoted.
804
805 In the seconds form, l1 and l2 must both be either upper case or both
806 be lower case characters in the C locale. In this case a field is cre‐
807 ated for each character from l1 thru l2.
808
809 In the remaining forms, a field is created for each number starting at
810 n1 and continuing until it reaches n2 incrementing n1 by n3. The cases
811 where n3 is not specified behave as if n3 where 1 if n1<=n2 and -1 oth‐
812 erwise. If forms which specify %fmt any format flags, widths and pre‐
813 cisions can be specified and fmt can end in any of the specifiers
814 cdiouxX. For example, {a,z}{1..5..3%02d}{b..c}x expands to the 8
815 fields, a01bx, a01cx, a04bx, a04cx, z01bx, z01cx, z04bx and z4cx.
816
817 File Name Generation.
818 Following splitting, each field is scanned for the characters ∗, ?, (,
819 and [ unless the -f option has been set. If one of these characters
820 appears, then the word is regarded as a pattern. Each file name compo‐
821 nent that contains any pattern character is replaced with a lexico‐
822 graphically sorted set of names that matches the pattern from that
823 directory. If no file name is found that matches the pattern, then
824 that component of the filename is left unchanged unless the pattern is
825 prefixed with ∼(N) in which case it is removed as described below. If
826 FIGNORE is set, then each file name component that matches the pattern
827 defined by the value of FIGNORE is ignored when generating the matching
828 filenames. The names . and .. are also ignored. If FIGNORE is not
829 set, the character . at the start of each file name component will be
830 ignored unless the first character of the pattern corresponding to this
831 component is the character . itself. Note, that for other uses of
832 pattern matching the / and . are not treated specially.
833
834 ∗ Matches any string, including the null string. When used
835 for filename expansion, if the globstar option is on, two
836 adjacent ∗'s by itself will match all files and zero or
837 more directories and subdirectories. If followed by a /
838 than only directories and subdirectories will match.
839 ? Matches any single character.
840 [...] Matches any one of the enclosed characters. A pair of
841 characters separated by - matches any character lexically
842 between the pair, inclusive. If the first character fol‐
843 lowing the opening [ is a ! then any character not
844 enclosed is matched. A - can be included in the charac‐
845 ter set by putting it as the first or last character.
846 Within [ and ], character classes can be specified with
847 the syntax [:class:] where class is one of the following
848 classes defined in the ANSI-C standard: (Note that word
849 is equivalent to alnum plus the character _).
850 alnum alpha blank cntrl digit graph lower print punct space
851 upper word xdigit
852 Within [ and ], an equivalence class can be specified with the
853 syntax [=c=] which matches all characters with the same primary
854 collation weight (as defined by the current locale) as the char‐
855 acter c.
856 Within [ and ], [.symbol.] matches the collating symbol symbol.
857 A pattern-list is a list of one or more patterns separated from each
858 other with a & or ⎪. A & signifies that all patterns must be matched
859 whereas ⎪ requires that only one pattern be matched. Composite pat‐
860 terns can be formed with one or more of the following sub-patterns:
861 ?(pattern-list)
862 Optionally matches any one of the given patterns.
863 *(pattern-list)
864 Matches zero or more occurrences of the given patterns.
865 +(pattern-list)
866 Matches one or more occurrences of the given patterns.
867 {n}(pattern-list)
868 Matches n occurrences of the given patterns.
869 {m,n}(pattern-list)
870 Matches from m to n occurrences of the given patterns.
871 If m is omitted, 0 will be used. If n is omitted at
872 least m occurrences will be matched.
873 @(pattern-list)
874 Matches exactly one of the given patterns.
875 !(pattern-list)
876 Matches anything except one of the given patterns.
877 By default, each pattern, or sub-pattern will match the longest string
878 possible consistent with generating the longest overall match. If more
879 than one match is possible, the one starting closest to the beginning
880 of the string will be chosen. However, for each of the above compound
881 patterns a - can be inserted in front of the ( to cause the shortest
882 match to the specified pattern-list to be used.
883
884 When pattern-list is contained within parenthesis, the backslash char‐
885 acter \ is treated specially even when inside a character class. All
886 ANSI-C character escapes are recognized and match the specified charac‐
887 ter. In addition the following escape sequences are recognized:
888 \d Matches any character in the digit class.
889 \D Matches any character not in the digit class.
890 \s Matches any character in the space class.
891 \S Matches any character not in the space class.
892 \w Matches any character in the word class.
893 \W Matches any character not in the word class.
894
895 A pattern of the form %(pattern-pair(s)) is a sub-pattern that can be
896 used to match nested character expressions. Each pattern-pair is a two
897 character sequence which cannot contain & or ⎪. The first pattern-pair
898 specifies the starting and ending characters for the match. Each sub‐
899 sequent pattern-pair represents the beginning and ending characters of
900 a nested group that will be skipped over when counting starting and
901 ending character matches. The behavior is unspecified when the first
902 character of a pattern-pair is alpha-numeric except for the following:
903 D Causes the ending character to terminate the search for
904 this pattern without finding a match.
905 E Causes the ending character to be interpreted as an
906 escape character.
907 L Causes the ending character to be interpreted as a quote
908 character causing all characters to be ignored when look‐
909 ing for a match.
910 Q Causes the ending character to be interpreted as a quote
911 character causing all characters other than any escape
912 character to be ignored when looking for a match.
913 Thus, %({}Q"E\), matches characters starting at { until the matching }
914 is found not counting any { or } that is inside a double quoted string
915 or preceded by the escape character \. Without the {} this pattern
916 matches any C language string.
917
918 Each sub-pattern in a composite pattern is numbered, starting at 1, by
919 the location of the ( within the pattern. The sequence \n, where n is
920 a single digit and \n comes after the n-th. sub-pattern, matches the
921 same string as the sub-pattern itself.
922
923 Finally a pattern can contain sub-patterns of the form ∼(options:pat‐
924 tern-list). where either options or :pattern-list can be omitted.
925 Unlike, the other compound patterns, these sub-patterns are not counted
926 in the numbered sub-patterns. If options is present, it can consist of
927 one or more of the following:
928 + Enable the following options. This is the default.
929 - Disable the following options.
930 E The remainder of the pattern uses extended regular
931 expression syntax like the egrep(1) command.
932 F The remainder of the pattern uses fgrep(1) expression
933 syntax.
934 G The remainder of the pattern uses basic regular expres‐
935 sion syntax like the grep(1) command.
936 K The remainder of the pattern uses shell pattern syntax.
937 This is the default.
938 N This is ignored. However, when it is the first letter
939 and is used with file name generation, and no matches
940 occur, the file pattern expands to the empty string.
941 i Treat the match as case insensitive.
942 g File the longest match (greedy). This is the default.
943 l Left anchor the pattern. This is the default for K style
944 patterns.
945 r Right anchor the pattern. This is the default for K
946 style patterns.
947 If both options and :pattern-list are specified, then the options apply
948 only to pattern-list. Otherwise, these options remain in effect until
949 they are disabled by a subsequent ∼(...) or at the end of the sub-pat‐
950 tern containing ∼(...).
951
952 Quoting.
953 Each of the metacharacters listed earlier (see Definitions above) has a
954 special meaning to the shell
955
956 i Treat the match as case insensitive.
957
958 g File the longest match (greedy). This is the default.
959 If both options and :pattern-list are specified, then the options apply
960 only to pattern-list. Otherwise, these options remain in effect until
961 they are disabled by a subsequent ∼(...) or at the end of the sub-pat‐
962 tern containing ∼(...).
963
964 Quoting.
965 Each of the metacharacters listed earlier (see Definitions above) has a
966 special meaning to the shell and causes termination of a word unless
967 quoted. A character may be quoted (i.e., made to stand for itself) by
968 preceding it with a \. The pair \new-line is removed. All characters
969 enclosed between a pair of single quote marks (′′) that is not preceded
970 by a $ are quoted. A single quote cannot appear within the single
971 quotes. A single quoted string preceded by an unquoted $ is processed
972 as an ANSI-C string except for the following:
973 \0 Causes the remainder of the string to be ignored.
974 \E Equivalent to the escape character (ascii 033),
975 \e Equivalent to the escape character (ascii 033),
976 \cx Expands to the character control-x.
977 \C[.name.]
978 Expands to the collating element name.
979
980 Inside double quote marks (""), parameter and command substitution
981 occur and \ quotes the characters \, `, ", and $. A $ in front of a
982 double quoted string will be ignored in the "C" or "POSIX" locale, and
983 may cause the string to be replaced by a locale specific string other‐
984 wise. The meaning of $∗ and $@ is identical when not quoted or when
985 used as a variable assignment value or as a file name. However, when
986 used as a command argument, "$∗" is equivalent to "$1d$2d...", where d
987 is the first character of the IFS variable, whereas "$@" is equivalent
988 to "$1" "$2" .... Inside grave quote marks (``), \ quotes the charac‐
989 ters \, `, and $. If the grave quotes occur within double quotes, then
990 \ also quotes the character ".
991
992 The special meaning of reserved words or aliases can be removed by
993 quoting any character of the reserved word. The recognition of func‐
994 tion names or built-in command names listed below cannot be altered by
995 quoting them.
996
997 Arithmetic Evaluation.
998 The shell performs arithmetic evaluation for arithmetic substitution,
999 to evaluate an arithmetic command, to evaluate an indexed array sub‐
1000 script, and to evaluate arguments to the built-in commands shift and
1001 let. Evaluations are performed using double precision floating point
1002 arithmetic or long double precision floating point for systems that
1003 provide this data type. Floating point constants follow the ANSI-C
1004 programming language floating point conventions. Integer constants
1005 follow the ANSI-C programming language integer constant conventions
1006 although only single byte character constants are recognized and char‐
1007 acter casts are not recognized. In addition constants can be of the
1008 form [base#]n where base is a decimal number between two and sixty-four
1009 representing the arithmetic base and n is a number in that base. The
1010 digits above 9 are represented by the lower case letters, the upper
1011 case letters, @, and _ respectively. For bases less than or equal to
1012 36, upper and lower case characters can be used interchangeably.
1013
1014 An arithmetic expression uses the same syntax, precedence, and associa‐
1015 tivity of expression as the C language. All the C language operators
1016 that apply to floating point quantities can be used. In addition, the
1017 operator ** can be used for exponentiation. It has higher precedence
1018 than multiplication as is left associative. In addition, when the
1019 value of an arithmetic variable or sub-expression can be represented as
1020 a long integer, all C language integer arithmetic operations can be
1021 performed. Variables can be referenced by name within an arithmetic
1022 expression without using the parameter expansion syntax. When a vari‐
1023 able is referenced, its value is evaluated as an arithmetic expression.
1024
1025 Any of the following math library functions that are in the C math
1026 library can be used within an arithmetic expression:
1027
1028 abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf
1029 erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod hypot ilogb
1030 int isinf isnan lgamma log log2 logb nearbyint nextafter nexttoward pow
1031 remainder rint round sin sinh sqrt tan tanh tgamma trunc
1032
1033 An internal representation of a variable as a double precision floating
1034 point can be specified with the -E [n] or -F [n] option of the typeset
1035 special built-in command. The -E option causes the expansion of the
1036 value to be represented using scientific notation when it is expanded.
1037 The optional option argument n defines the number of significant fig‐
1038 ures. The -F option causes the expansion to be represented as a float‐
1039 ing decimal number when it is expanded. The optional option argument n
1040 defines the number of places after the decimal point in this case.
1041
1042 An internal integer representation of a variable can be specified with
1043 the -i [n] option of the typeset special built-in command. The
1044 optional option argument n specifies an arithmetic base to be used when
1045 expanding the variable. If you do not specify an arithmetic base, base
1046 10 will be used.
1047
1048 Arithmetic evaluation is performed on the value of each assignment to a
1049 variable with the -E, -F, or -i attribute. Assigning a floating point
1050 number to a variable whose type is an integer causes the fractional
1051 part to be truncated.
1052
1053 Prompting.
1054 When used interactively, the shell prompts with the value of PS1 after
1055 expanding it for parameter expansion, command substitution, and arith‐
1056 metic substitution, before reading a command. In addition, each single
1057 ! in the prompt is replaced by the command number. A !! is required
1058 to place ! in the prompt. If at any time a new-line is typed and fur‐
1059 ther input is needed to complete a command, then the secondary prompt
1060 (i.e., the value of PS2) is issued.
1061
1062 Conditional Expressions.
1063 A conditional expression is used with the [[ compound command to test
1064 attributes of files and to compare strings. Field splitting and file
1065 name generation are not performed on the words between [[ and ]]. Each
1066 expression can be constructed from one or more of the following unary
1067 or binary expressions:
1068 string True, if string is not null.
1069 -a file
1070 Same as -e below. This is obsolete.
1071 -b file
1072 True, if file exists and is a block special file.
1073 -c file
1074 True, if file exists and is a character special file.
1075 -d file
1076 True, if file exists and is a directory.
1077 -e file
1078 True, if file exists.
1079 -f file
1080 True, if file exists and is an ordinary file.
1081 -g file
1082 True, if file exists and it has its setgid bit set.
1083 -k file
1084 True, if file exists and it has its sticky bit set.
1085 -n string
1086 True, if length of string is non-zero.
1087 -o ?option
1088 True, if option named option is a valid option name.
1089 -o option
1090 True, if option named option is on.
1091 -p file
1092 True, if file exists and is a fifo special file or a pipe.
1093 -r file
1094 True, if file exists and is readable by current process.
1095 -s file
1096 True, if file exists and has size greater than zero.
1097 -t fildes
1098 True, if file descriptor number fildes is open and associated
1099 with a terminal device.
1100 -u file
1101 True, if file exists and it has its setuid bit set.
1102 -w file
1103 True, if file exists and is writable by current process.
1104 -x file
1105 True, if file exists and is executable by current process. If
1106 file exists and is a directory, then true if the current process
1107 has permission to search in the directory.
1108 -z string
1109 True, if length of string is zero.
1110 -L file
1111 True, if file exists and is a symbolic link.
1112 -h file
1113 True, if file exists and is a symbolic link.
1114 -N file
1115 True, if file exists and the modification time is greater than
1116 the last access time.
1117 -O file
1118 True, if file exists and is owned by the effective user id of
1119 this process.
1120 -G file
1121 True, if file exists and its group matches the effective group
1122 id of this process.
1123 -S file
1124 True, if file exists and is a socket.
1125 file1 -nt file2
1126 True, if file1 exists and file2 does not, or file1 is newer than
1127 file2.
1128 file1 -ot file2
1129 True, if file2 exists and file1 does not, or file1 is older than
1130 file2.
1131 file1 -ef file2
1132 True, if file1 and file2 exist and refer to the same file.
1133 string == pattern
1134 True, if string matches pattern. Any part of pattern can be
1135 quoted to cause it to be matched as a string. With a successful
1136 match to a pattern, the .sh.match array variable will contain
1137 the match and sub-pattern matches.
1138 string = pattern
1139 Same as == above, but is obsolete.
1140 string != pattern
1141 True, if string does not match pattern. With the string matches
1142 the pattern the .sh.match array variable will contain the match
1143 and sub-pattern matches.
1144 string =∼ ere
1145 True if string matches the pattern ∼(E)ere where ere is an
1146 extended regular expression.
1147 string1 < string2
1148 True, if string1 comes before string2 based on ASCII value of
1149 their characters.
1150 string1 > string2
1151 True, if string1 comes after string2 based on ASCII value of
1152 their characters.
1153 The following obsolete arithmetic comparisons are also permitted:
1154 exp1 -eq exp2
1155 True, if exp1 is equal to exp2.
1156 exp1 -ne exp2
1157 True, if exp1 is not equal to exp2.
1158 exp1 -lt exp2
1159 True, if exp1 is less than exp2.
1160 exp1 -gt exp2
1161 True, if exp1 is greater than exp2.
1162 exp1 -le exp2
1163 True, if exp1 is less than or equal to exp2.
1164 exp1 -ge exp2
1165 True, if exp1 is greater than or equal to exp2.
1166
1167 In each of the above expressions, if file is of the form /dev/fd/n,
1168 where n is an integer, then the test is applied to the open file whose
1169 descriptor number is n.
1170
1171 A compound expression can be constructed from these primitives by using
1172 any of the following, listed in decreasing order of precedence.
1173 (expression)
1174 True, if expression is true. Used to group expressions.
1175 ! expression
1176 True if expression is false.
1177 expression1 && expression2
1178 True, if expression1 and expression2 are both true.
1179 expression1 ⎪⎪ expression2
1180 True, if either expression1 or expression2 is true.
1181
1182 Input/Output.
1183 Before a command is executed, its input and output may be redirected
1184 using a special notation interpreted by the shell. The following may
1185 appear anywhere in a simple-command or may precede or follow a command
1186 and are not passed on to the invoked command. Command substitution,
1187 parameter expansion, and arithmetic substitution occur before word or
1188 digit is used except as noted below. File name generation occurs only
1189 if the shell is interactive and the pattern matches a single file.
1190 Field splitting is not performed.
1191
1192 In each of the following redirections, if file is of the form
1193 /dev/sctp/host/port, /dev/tcp/host/port, or /dev/udp/host/port, where
1194 host is a hostname or host address, and port is a service given by name
1195 or an integer port number, then the redirection attempts to make a tcp,
1196 sctp or udp connection to the corresponding socket.
1197
1198 No intervening space is allowed between the characters of redirection
1199 operators.
1200
1201 <word Use file word as standard input (file descriptor 0).
1202
1203 >word Use file word as standard output (file descriptor 1). If
1204 the file does not exist then it is created. If the file
1205 exists, and the noclobber option is on, this causes an
1206 error; otherwise, it is truncated to zero length.
1207
1208 >|word Sames as >, except that it overrides the noclobber
1209 option.
1210
1211 >>word Use file word as standard output. If the file exists,
1212 then output is appended to it (by first seeking to the
1213 end-of-file); otherwise, the file is created.
1214
1215 <>word Open file word for reading and writing as standard input.
1216
1217 <<[-]word The shell input is read up to a line that is the same as
1218 word after any quoting has been removed, or to an end-of-
1219 file. No parameter substitution, command substitution,
1220 arithmetic substitution or file name generation is per‐
1221 formed on word. The resulting document, called a here-
1222 document, becomes the standard input. If any character
1223 of word is quoted, then no interpretation is placed upon
1224 the characters of the document; otherwise, parameter
1225 expansion, command substitution, and arithmetic substitu‐
1226 tion occur, \new-line is ignored, and \ must be used to
1227 quote the characters \, $, `. If - is appended to <<,
1228 then all leading tabs are stripped from word and from the
1229 document. If # is appended to <<, then leading spaces
1230 and tabs will be stripped off the first line of the docu‐
1231 ment and up to an equivalent indentation will be stripped
1232 from the remaining lines and from word. A tab stop is
1233 assumend to occur at every 8 columns for the purposes of
1234 determining the indentation.
1235
1236 <<<word A short form of here document in which word becomes the
1237 contents of the here-document after any parameter expan‐
1238 sion, command substitution, and arithmetic substitution
1239 occur.
1240
1241 <&digit The standard input is duplicated from file descriptor
1242 digit (see dup(2)). Similarly for the standard output
1243 using >&digit.
1244
1245 <&digit- The file descriptor given by digit is moved to standard
1246 input. Similarly for the standard output using >&digit-.
1247
1248 <&- The standard input is closed. Similarly for the standard
1249 output using >&-.
1250
1251 <&p The input from the co-process is moved to standard input.
1252
1253 >&p The output to the co-process is moved to standard output.
1254
1255 <#((expr)) Evaluate arithmetic expression expr and position file
1256 descriptor 0 to the resulting value bytes from the start
1257 of the file. The variables CUR and EOF evaluate to the
1258 current offset and end-of-file offset respectively when
1259 evaluating expr.
1260
1261 >#((offset)) The same as <# except applies to file descriptor 1.
1262
1263 <#pattern Seeks forward to the beginning of the next line contain‐
1264 ing pattern.
1265
1266 <##pattern The same as <# except that the portion of the file that
1267 is skipped is copied to standard output.
1268
1269 If one of the above is preceded by a digit, with no intervening space,
1270 then the file descriptor number referred to is that specified by the
1271 digit (instead of the default 0 or 1). If one of the above, other than
1272 >&- and the ># and ># forms, is preceded by {varname} with no interven‐
1273 ing space, then a file descriptor number > 10 will be selected by the
1274 shell and stored in the variable varname. If >&- or the any of the >#
1275 and ># forms is preceded by {varname} the value of varname defines the
1276 file descriptor to close or position. For example:
1277
1278 ... 2>&1
1279
1280 means file descriptor 2 is to be opened for writing as a duplicate of
1281 file descriptor 1 and
1282
1283 exec {n}<file
1284
1285 means open file named file for reading and store the file descriptor
1286 number in variable n.
1287
1288 The order in which redirections are specified is significant. The
1289 shell evaluates each redirection in terms of the (file descriptor,
1290 file) association at the time of evaluation. For example:
1291
1292 ... 1>fname 2>&1
1293
1294 first associates file descriptor 1 with file fname. It then associates
1295 file descriptor 2 with the file associated with file descriptor 1 (i.e.
1296 fname). If the order of redirections were reversed, file descriptor 2
1297 would be associated with the terminal (assuming file descriptor 1 had
1298 been) and then file descriptor 1 would be associated with file fname.
1299
1300 If a command is followed by & and job control is not active, then the
1301 default standard input for the command is the empty file /dev/null.
1302 Otherwise, the environment for the execution of a command contains the
1303 file descriptors of the invoking shell as modified by input/output
1304 specifications.
1305
1306 Environment.
1307 The environment (see environ(7)) is a list of name-value pairs that is
1308 passed to an executed program in the same way as a normal argument
1309 list. The names must be identifiers and the values are character
1310 strings. The shell interacts with the environment in several ways. On
1311 invocation, the shell scans the environment and creates a variable for
1312 each name found, giving it the corresponding value and attributes and
1313 marking it export. Executed commands inherit the environment. If the
1314 user modifies the values of these variables or creates new ones, using
1315 the export or typeset -x commands, they become part of the environment.
1316 The environment seen by any executed command is thus composed of any
1317 name-value pairs originally inherited by the shell, whose values may be
1318 modified by the current shell, plus any additions which must be noted
1319 in export or typeset -x commands.
1320
1321 The environment for any simple-command or function may be augmented by
1322 prefixing it with one or more variable assignments. A variable assign‐
1323 ment argument is a word of the form identifier=value. Thus:
1324
1325 TERM=450 cmd args and
1326 (export TERM; TERM=450; cmd args)
1327
1328 are equivalent (as far as the above execution of cmd is concerned
1329 except for special built-in commands listed below - those that are pre‐
1330 ceded with a dagger).
1331
1332 If the obsolete -k option is set, all variable assignment arguments are
1333 placed in the environment, even if they occur after the command name.
1334 The following first prints a=b c and then c:
1335
1336 echo a=b c
1337 set -k
1338 echo a=b c
1339 This feature is intended for use with scripts written for early ver‐
1340 sions of the shell and its use in new scripts is strongly discouraged.
1341 It is likely to disappear someday.
1342
1343 Functions.
1344 For historical reasons, there are two ways to define functions, the
1345 name() syntax and the function name syntax, described in the Commands
1346 section above. Shell functions are read in and stored internally.
1347 Alias names are resolved when the function is read. Functions are exe‐
1348 cuted like commands with the arguments passed as positional parameters.
1349 (See Execution below.)
1350
1351 Functions defined by the function name syntax and called by name exe‐
1352 cute in the same process as the caller and share all files and present
1353 working directory with the caller. Traps caught by the caller are
1354 reset to their default action inside the function. A trap condition
1355 that is not caught or ignored by the function causes the function to
1356 terminate and the condition to be passed on to the caller. A trap on
1357 EXIT set inside a function is executed in the environment of the caller
1358 after the function completes. Ordinarily, variables are shared between
1359 the calling program and the function. However, the typeset special
1360 built-in command used within a function defines local variables whose
1361 scope includes the current function. They can be passed to functions
1362 that they call in the variable assignment list the precedes the call or
1363 as arguments passed as name references. Errors within functions return
1364 control to the caller.
1365
1366 Functions defined with the name() syntax and functions defined with the
1367 function name syntax that are invoked with the . special built-in are
1368 executed in the caller's environment and share all variables and traps
1369 with the caller. Errors within these function executions cause the
1370 script that contains them to abort.
1371
1372 The special built-in command return is used to return from function
1373 calls.
1374
1375 Function names can be listed with the -f or +f option of the typeset
1376 special built-in command. The text of functions, when available, will
1377 also be listed with -f. Functions can be undefined with the -f option
1378 of the unset special built-in command.
1379
1380 Ordinarily, functions are unset when the shell executes a shell script.
1381 Functions that need to be defined across separate invocations of the
1382 shell should be placed in a directory and the FPATH variable should
1383 contain the name of this directory. They may also be specified in the
1384 ENV file.
1385
1386 Discipline Functions.
1387 Each variable can have zero or more discipline functions associated
1388 with it. The shell initially understands the discipline names get,
1389 set, append, and unset but on most systems others can be added at run
1390 time via the C programming interface extension provided by the builtin
1391 built-in utility. If the get discipline is defined for a variable, it
1392 is invoked whenever the given variable is referenced. If the variable
1393 .sh.value is assigned a value inside the discipline function, the ref‐
1394 erenced variable will evaluate to this value instead. If the set dis‐
1395 cipline is defined for a variable, it is invoked whenever the given
1396 variable is assigned a value. If the append discipline is defined for
1397 a variable, it is invoked whenever a value is appended to the given
1398 variable. The variable .sh.value is given the value of the variable
1399 before invoking the discipline, and the variable will be assigned the
1400 value of .sh.value after the discipline completes. If .sh.value is
1401 unset inside the discipline, then that value is unchanged. If the
1402 unset discipline is defined for a variable, it is invoked whenever the
1403 given variable is unset. The variable will not be unset unless it is
1404 unset explicitly from within this discipline function.
1405
1406 The variable .sh.name contains the name of the variable for which the
1407 discipline function is called, .sh.subscript is the subscript of the
1408 variable, and .sh.value will contain the value being assigned inside
1409 the .set discipline function. For the set discipline, changing
1410 .sh.value will change the value that gets assigned.
1411
1412 Jobs.
1413 If the monitor option of the set command is turned on, an interactive
1414 shell associates a job with each pipeline. It keeps a table of current
1415 jobs, printed by the jobs command, and assigns them small integer num‐
1416 bers. When a job is started asynchronously with &, the shell prints a
1417 line which looks like:
1418
1419 [1] 1234
1420
1421 indicating that the job which was started asynchronously was job number
1422 1 and had one (top-level) process, whose process id was 1234.
1423
1424 This paragraph and the next require features that are not in all ver‐
1425 sions of UNIX and may not apply. If you are running a job and wish to
1426 do something else you may hit the key ^Z (control-Z) which sends a STOP
1427 signal to the current job. The shell will then normally indicate that
1428 the job has been `Stopped', and print another prompt. You can then
1429 manipulate the state of this job, putting it in the background with the
1430 bg command, or run some other commands and then eventually bring the
1431 job back into the foreground with the foreground command fg. A ^Z
1432 takes effect immediately and is like an interrupt in that pending out‐
1433 put and unread input are discarded when it is typed.
1434
1435 A job being run in the background will stop if it tries to read from
1436 the terminal. Background jobs are normally allowed to produce output,
1437 but this can be disabled by giving the command stty tostop. If you set
1438 this tty option, then background jobs will stop when they try to pro‐
1439 duce output like they do when they try to read input.
1440
1441 There are several ways to refer to jobs in the shell. A job can be
1442 referred to by the process id of any process of the job or by one of
1443 the following:
1444 %number
1445 The job with the given number.
1446 %string
1447 Any job whose command line begins with string.
1448 %?string
1449 Any job whose command line contains string.
1450 %% Current job.
1451 %+ Equivalent to %%.
1452 %- Previous job.
1453
1454 The shell learns immediately whenever a process changes state. It nor‐
1455 mally informs you whenever a job becomes blocked so that no further
1456 progress is possible, but only just before it prints a prompt. This is
1457 done so that it does not otherwise disturb your work. The notify
1458 option of the set command causes the shell to print these job change
1459 messages as soon as they occur.
1460
1461 When the monitor option is on, each background job that completes trig‐
1462 gers any trap set for CHLD.
1463
1464 When you try to leave the shell while jobs are running or stopped, you
1465 will be warned that `You have stopped(running) jobs.' You may use the
1466 jobs command to see what they are. If you immediately try to exit
1467 again, the shell will not warn you a second time, and the stopped jobs
1468 will be terminated. When a login shell receives a HUP signal, it sends
1469 a HUP signal to each job that has not been disowned with the disown
1470 built-in command described below.
1471
1472 Signals.
1473 The INT and QUIT signals for an invoked command are ignored if the com‐
1474 mand is followed by & and the monitor option is not active. Otherwise,
1475 signals have the values inherited by the shell from its parent (but see
1476 also the trap built-in command below).
1477
1478 Execution.
1479 Each time a command is read, the above substitutions are carried out.
1480 If the command name matches one of the Special Built-in Commands listed
1481 below, it is executed within the current shell process. Next, the com‐
1482 mand name is checked to see if it matches a user defined function. If
1483 it does, the positional parameters are saved and then reset to the
1484 arguments of the function call. A function is also executed in the
1485 current shell process. When the function completes or issues a return,
1486 the positional parameter list is restored. For functions defined with
1487 the function name syntax, any trap set on EXIT within the function is
1488 executed. The exit value of a function is the value of the last com‐
1489 mand executed. If a command name is not a special built-in command or
1490 a user defined function, but it is one of the built-in commands listed
1491 below, it is executed in the current shell process.
1492
1493 The shell variable PATH defines the search path for the directory con‐
1494 taining the command. Alternative directory names are separated by a
1495 colon (:). The default path is /bin:/usr/bin: (specifying /bin,
1496 /usr/bin, and the current directory in that order). The current direc‐
1497 tory can be specified by two or more adjacent colons, or by a colon at
1498 the beginning or end of the path list. If the command name contains a
1499 /, then the search path is not used. Otherwise, each directory in the
1500 path is searched for an executable file of the given name that is not a
1501 directory. If found, and if the shell determines that there is a
1502 built-in version of a command corresponding to a given pathname, this
1503 built-in is invoked in the current process. If found, and this direc‐
1504 tory is also contained in the value of the FPATH variable, then this
1505 file is loaded into the current shell environment as if it were the
1506 argument to the . command except that only preset aliases are expanded,
1507 and a function of the given name is executed as described above. If
1508 not found, and the file .paths is found, and the this file contains a
1509 line of the form FPATH=path where path names an existing directory, and
1510 this directory contains a file of the given name, then this file is
1511 loaded into the current shell environment as if it were the argument to
1512 the . special built-in command and a function of the given name is exe‐
1513 cuted. Otherwise, if found, a process is created and an attempt is
1514 made to execute the command via exec(2).
1515
1516 When an executable is found, the directory where it is found in is
1517 searched for a file named .paths. If this file is found and it con‐
1518 tains a line of the form BUILTIN_LIB=value , then the library named by
1519 value will be searched for as if it were an option argument to builtin
1520 -f, and if it contains a built-in of the specified name this will be
1521 executed instead of a command by this name. Otherwise, if this file is
1522 found and it contains a line of the form name=value in the first or
1523 second line, then the environment variable name is modified by prepend‐
1524 ing the directory specified by value to the directory list. If value
1525 is not an absolute directory, then it specifies a directory relative to
1526 the directory that the executable was found. If the environment vari‐
1527 able name does not already exist it will be added to the environment
1528 list for the specified command.
1529
1530 If the file has execute permission but is not an a.out file, it is
1531 assumed to be a file containing shell commands. A separate shell is
1532 spawned to read it. All non-exported variables are removed in this
1533 case. If the shell command file doesn't have read permission, or if
1534 the setuid and/or setgid bits are set on the file, then the shell exe‐
1535 cutes an agent whose job it is to set up the permissions and execute
1536 the shell with the shell command file passed down as an open file. A
1537 parenthesized command is executed in a sub-shell without removing non-
1538 exported variables.
1539
1540 Command Re-entry.
1541 The text of the last HISTSIZE (default 512) commands entered from a
1542 terminal device is saved in a history file. The file $HOME/.sh_history
1543 is used if the HISTFILE variable is not set or if the file it names is
1544 not writable. A shell can access the commands of all interactive
1545 shells which use the same named HISTFILE. The built-in command hist is
1546 used to list or edit a portion of this file. The portion of the file
1547 to be edited or listed can be selected by number or by giving the first
1548 character or characters of the command. A single command or range of
1549 commands can be specified. If you do not specify an editor program as
1550 an argument to hist then the value of the variable HISTEDIT is used.
1551 If HISTEDIT is unset, the obsolete variable FCEDIT is used. If FCEDIT
1552 is not defined, then /bin/ed is used. The edited command(s) is printed
1553 and re-executed upon leaving the editor unless you quit without writ‐
1554 ing. The -s option (and in obsolete versions, the editor name -) is
1555 used to skip the editing phase and to re-execute the command. In this
1556 case a substitution parameter of the form old=new can be used to modify
1557 the command before execution. For example, with the preset alias r,
1558 which is aliased to ′hist -s′, typing `r bad=good c' will re-execute
1559 the most recent command which starts with the letter c, replacing the
1560 first occurrence of the string bad with the string good.
1561
1562 In-line Editing Options.
1563 Normally, each command line entered from a terminal device is simply
1564 typed followed by a new-line (`RETURN' or `LINE FEED'). If either the
1565 emacs, gmacs, or vi option is active, the user can edit the command
1566 line. To be in either of these edit modes set the corresponding
1567 option. An editing option is automatically selected each time the VIS‐
1568 UAL or EDITOR variable is assigned a value ending in either of these
1569 option names.
1570
1571 The editing features require that the user's terminal accept `RETURN'
1572 as carriage return without line feed and that a space (` ') must over‐
1573 write the current character on the screen.
1574
1575 Unless the multiline option is on, the editing modes implement a con‐
1576 cept where the user is looking through a window at the current line.
1577 The window width is the value of COLUMNS if it is defined, otherwise
1578 80. If the window width is too small to display the prompt and leave
1579 at least 8 columns to enter input, the prompt is truncated from the
1580 left. If the line is longer than the window width minus two, a mark is
1581 displayed at the end of the window to notify the user. As the cursor
1582 moves and reaches the window boundaries the window will be centered
1583 about the cursor. The mark is a > (<, *) if the line extends on the
1584 right (left, both) side(s) of the window.
1585
1586 The search commands in each edit mode provide access to the history
1587 file. Only strings are matched, not patterns, although a leading ^ in
1588 the string restricts the match to begin at the first character in the
1589 line.
1590
1591 Each of the edit modes has an operation to list the files or commands
1592 that match a partially entered word. When applied to the first word on
1593 the line, or the first word after a ;, ⎪, &, or (, and the word does
1594 not begin with ∼ or contain a /, the list of aliases, functions, and
1595 executable commands defined by the PATH variable that could match the
1596 partial word is displayed. Otherwise, the list of files that match the
1597 given word is displayed. If the partially entered word does not con‐
1598 tain any file expansion characters, a * is appended before generating
1599 these lists. After displaying the generated list, the input line is
1600 redrawn. These operations are called command name listing and file
1601 name listing, respectively. There are additional operations, referred
1602 to as command name completion and file name completion, which compute
1603 the list of matching commands or files, but instead of printing the
1604 list, replace the current word with a complete or partial match. For
1605 file name completion, if the match is unique, a / is appended if the
1606 file is a directory and a space is appended if the file is not a direc‐
1607 tory. Otherwise, the longest common prefix for all the matching files
1608 replaces the word. For command name completion, only the portion of
1609 the file names after the last / are used to find the longest command
1610 prefix. If only a single name matches this prefix, then the word is
1611 replaced with the command name followed by a space. When using a tab
1612 for completion that does not yield a unique match, a subsequent tab
1613 will provide a numbered list of matching alternatives. A specific
1614 selection can be made by entering the selection number followed by a
1615 tab.
1616
1617 Key Bindings.
1618 The KEYBD trap can be used to intercept keys as they are typed and
1619 change the characters that are actually seen by the shell. This trap
1620 is executed after each character (or sequence of characters when the
1621 first character is ESC) is entered while reading from a terminal. The
1622 variable .sh.edchar contains the character or character sequence which
1623 generated the trap. Changing the value of .sh.edchar in the trap
1624 action causes the shell to behave as if the new value were entered from
1625 the keyboard rather than the original value.
1626
1627 The variable .sh.edcol is set to the input column number of the cursor
1628 at the time of the input. The variable .sh.edmode is set to ESC when
1629 in vi insert mode (see below) and is null otherwise. By prepending
1630 ${.sh.editmode} to a value assigned to .sh.edchar it will cause the
1631 shell to change to control mode if it is not already in this mode.
1632
1633 This trap is not invoked for characters entered as arguments to editing
1634 directives, or while reading input for a character search.
1635
1636 Emacs Editing Mode.
1637 This mode is entered by enabling either the emacs or gmacs option. The
1638 only difference between these two modes is the way they handle ^T. To
1639 edit, the user moves the cursor to the point needing correction and
1640 then inserts or deletes characters or words as needed. All the editing
1641 commands are control characters or escape sequences. The notation for
1642 control characters is caret (^) followed by the character. For exam‐
1643 ple, ^F is the notation for control F. This is entered by depressing
1644 `f' while holding down the `CTRL' (control) key. The `SHIFT' key is
1645 not depressed. (The notation ^? indicates the DEL (delete) key.)
1646
1647 The notation for escape sequences is M- followed by a character. For
1648 example, M-f (pronounced Meta f) is entered by depressing ESC (ascii
1649 033) followed by `f'. (M-F would be the notation for ESC followed by
1650 `SHIFT' (capital) `F'.)
1651
1652 All edit commands operate from any place on the line (not just at the
1653 beginning). Neither the `RETURN' nor the `LINE FEED' key is entered
1654 after edit commands except when noted.
1655
1656 ^F Move cursor forward (right) one character.
1657 M-[C Move cursor forward (right) one character.
1658 M-f Move cursor forward one word. (The emacs editor's idea of a
1659 word is a string of characters consisting of only letters,
1660 digits and underscores.)
1661 ^B Move cursor backward (left) one character.
1662 M-[D Move cursor backward (left) one character.
1663 M-b Move cursor backward one word.
1664 ^A Move cursor to start of line.
1665 M-[H Move cursor to start of line.
1666 ^E Move cursor to end of line.
1667 M-[Y Move cursor to end of line.
1668 ^]char Move cursor forward to character char on current line.
1669 M-^]char Move cursor backward to character char on current line.
1670 ^X^X Interchange the cursor and mark.
1671 erase (User defined erase character as defined by the stty(1) com‐
1672 mand, usually ^H or #.) Delete previous character.
1673 lnext (User defined literal next character as defined by the
1674 stty(1) command. or ^V if not defined.) Removes the next
1675 character's editing features (if any).
1676 ^D Delete current character.
1677 M-d Delete current word.
1678 M-^H (Meta-backspace) Delete previous word.
1679 M-h Delete previous word.
1680 M-^? (Meta-DEL) Delete previous word (if your interrupt character
1681 is ^? (DEL, the default) then this command will not work).
1682 ^T Transpose current character with previous character and
1683 advance the cursor in emacs mode. Transpose two previous
1684 characters in gmacs mode.
1685 ^C Capitalize current character.
1686 M-c Capitalize current word.
1687 M-l Change the current word to lower case.
1688 ^K Delete from the cursor to the end of the line. If preceded
1689 by a numerical parameter whose value is less than the current
1690 cursor position, then delete from given position up to the
1691 cursor. If preceded by a numerical parameter whose value is
1692 greater than the current cursor position, then delete from
1693 cursor up to given cursor position.
1694 ^W Kill from the cursor to the mark.
1695 M-p Push the region from the cursor to the mark on the stack.
1696 kill (User defined kill character as defined by the stty command,
1697 usually ^G or @.) Kill the entire current line. If two kill
1698 characters are entered in succession, all kill characters
1699 from then on cause a line feed (useful when using paper ter‐
1700 minals).
1701 ^Y Restore last item removed from line. (Yank item back to the
1702 line.)
1703 ^L Line feed and print current line.
1704 ^@ (Null character) Set mark.
1705 M-space (Meta space) Set mark.
1706 ^J (New line) Execute the current line.
1707 ^M (Return) Execute the current line.
1708 eof End-of-file character, normally ^D, is processed as an End-
1709 of-file only if the current line is null.
1710 ^P Fetch previous command. Each time ^P is entered the previous
1711 command back in time is accessed. Moves back one line when
1712 not on the first line of a multi-line command.
1713 M-[A Equivalent to ^P.
1714 M-< Fetch the least recent (oldest) history line.
1715 M-> Fetch the most recent (youngest) history line.
1716 ^N Fetch next command line. Each time ^N is entered the next
1717 command line forward in time is accessed.
1718 M-[B Equivalent to ^N.
1719 ^Rstring Reverse search history for a previous command line containing
1720 string. If a parameter of zero is given, the search is for‐
1721 ward. String is terminated by a `RETURN' or `NEW LINE'. If
1722 string is preceded by a ^, the matched line must begin with
1723 string. If string is omitted, then the next command line
1724 containing the most recent string is accessed. In this case
1725 a parameter of zero reverses the direction of the search.
1726 ^O Operate - Execute the current line and fetch the next line
1727 relative to current line from the history file.
1728 M-digits (Escape) Define numeric parameter, the digits are taken as a
1729 parameter to the next command. The commands that accept a
1730 parameter are ^F, ^B, erase, ^C, ^D, ^K, ^R, ^P, ^N, ^], M-.,
1731 M-^], M-_, M-=, M-b, M-c, M-d, M-f, M-h, M-l and M-^H.
1732 M-letter Soft-key - Your alias list is searched for an alias by the
1733 name _letter and if an alias of this name is defined, its
1734 value will be inserted on the input queue. The letter must
1735 not be one of the above meta-functions.
1736 M-[letter Soft-key - Your alias list is searched for an alias by the
1737 name __letter and if an alias of this name is defined, its
1738 value will be inserted on the input queue. The can be used
1739 to program functions keys on many terminals.
1740 M-. The last word of the previous command is inserted on the
1741 line. If preceded by a numeric parameter, the value of this
1742 parameter determines which word to insert rather than the
1743 last word.
1744 M-_ Same as M-..
1745 M-* Attempt file name generation on the current word. An aster‐
1746 isk is appended if the word doesn't match any file or contain
1747 any special pattern characters.
1748 M-ESC Command or file name completion as described above.
1749 ^I tab Attempts command or file name completion as described above.
1750 If a partial completion occurs, repeating this will behave as
1751 if M-= were entered. If no match is found or entered after
1752 space, a tab is inserted.
1753 M-= If not preceded by a numeric parameter, it generates the list
1754 of matching commands or file names as described above. Oth‐
1755 erwise, the word under the cursor is replaced by the item
1756 corresponding to the value of the numeric parameter from the
1757 most recently generated command or file list. If the cursor
1758 is not on a word, it is inserted instead.
1759 ^U Multiply parameter of next command by 4.
1760 \ Escape next character. Editing characters, the user's erase,
1761 kill and interrupt (normally ^?) characters may be entered
1762 in a command line or in a search string if preceded by a \.
1763 The \ removes the next character's editing features (if any).
1764 M-^V Display version of the shell.
1765 M-# If the line does not begin with a #, a # is inserted at the
1766 beginning of the line and after each new-line, and the line
1767 is entered. This causes a comment to be inserted in the his‐
1768 tory file. If the line begins with a #, the # is deleted and
1769 one # after each new-line is also deleted.
1770
1771 Vi Editing Mode.
1772 There are two typing modes. Initially, when you enter a command you
1773 are in the input mode. To edit, the user enters control mode by typing
1774 ESC (033) and moves the cursor to the point needing correction and then
1775 inserts or deletes characters or words as needed. Most control com‐
1776 mands accept an optional repeat count prior to the command.
1777
1778 When in vi mode on most systems, canonical processing is initially
1779 enabled and the command will be echoed again if the speed is 1200 baud
1780 or greater and it contains any control characters or less than one sec‐
1781 ond has elapsed since the prompt was printed. The ESC character termi‐
1782 nates canonical processing for the remainder of the command and the
1783 user can then modify the command line. This scheme has the advantages
1784 of canonical processing with the type-ahead echoing of raw mode.
1785
1786 If the option viraw is also set, the terminal will always have canoni‐
1787 cal processing disabled. This mode is implicit for systems that do not
1788 support two alternate end of line delimiters, and may be helpful for
1789 certain terminals.
1790
1791 Input Edit Commands
1792 By default the editor is in input mode.
1793 erase (User defined erase character as defined by the stty
1794 command, usually ^H or #.) Delete previous character.
1795 ^W Delete the previous blank separated word. On some
1796 systems the viraw option may be required for this to
1797 work.
1798 eof As the first character of the line causes the shell to
1799 terminate unless the ignoreeof option is set. Other‐
1800 wise this character is ignored.
1801 lnext (User defined literal next character as defined by the
1802 stty(1) or ^V if not defined.) Removes the next char‐
1803 acter's editing features (if any). On some systems
1804 the viraw option may be required for this to work.
1805 \ Escape the next erase or kill character.
1806 ^I tab Attempts command or file name completion as described
1807 above and returns to input mode. If a partial comple‐
1808 tion occurs, repeating this will behave as if = were
1809 entered from control mode. If no match is found or
1810 entered after space, a tab is inserted.
1811 Motion Edit Commands
1812 These commands will move the cursor.
1813 [count]l Cursor forward (right) one character.
1814 [count][C Cursor forward (right) one character.
1815 [count]w Cursor forward one alpha-numeric word.
1816 [count]W Cursor to the beginning of the next word that follows
1817 a blank.
1818 [count]e Cursor to end of word.
1819 [count]E Cursor to end of the current blank delimited word.
1820 [count]h Cursor backward (left) one character.
1821 [count][D Cursor backward (left) one character.
1822 [count]b Cursor backward one word.
1823 [count]B Cursor to preceding blank separated word.
1824 [count]⎪ Cursor to column count.
1825 [count]fc Find the next character c in the current line.
1826 [count]Fc Find the previous character c in the current line.
1827 [count]tc Equivalent to f followed by h.
1828 [count]Tc Equivalent to F followed by l.
1829 [count]; Repeats count times, the last single character find
1830 command, f, F, t, or T.
1831 [count], Reverses the last single character find command count
1832 times.
1833 0 Cursor to start of line.
1834 ^ Cursor to start of line.
1835 [H Cursor to first non-blank character in line.
1836 $ Cursor to end of line.
1837 [Y Cursor to end of line.
1838 % Moves to balancing (, ), {, }, [, or ]. If cursor is
1839 not on one of the above characters, the remainder of
1840 the line is searched for the first occurrence of one
1841 of the above characters first.
1842 Search Edit Commands
1843 These commands access your command history.
1844 [count]k Fetch previous command. Each time k is entered the
1845 previous command back in time is accessed.
1846 [count]- Equivalent to k.
1847 [count][A Equivalent to k.
1848 [count]j Fetch next command. Each time j is entered the next
1849 command forward in time is accessed.
1850 [count]+ Equivalent to j.
1851 [count][B Equivalent to j.
1852 [count]G The command number count is fetched. The default is
1853 the least recent history command.
1854 /string Search backward through history for a previous command
1855 containing string. String is terminated by a `RETURN'
1856 or `NEW LINE'. If string is preceded by a ^, the
1857 matched line must begin with string. If string is
1858 null, the previous string will be used.
1859 ?string Same as / except that search will be in the forward
1860 direction.
1861 n Search for next match of the last pattern to / or ?
1862 commands.
1863 N Search for next match of the last pattern to / or ?,
1864 but in reverse direction.
1865 Text Modification Edit Commands
1866 These commands will modify the line.
1867 a Enter input mode and enter text after the current
1868 character.
1869 A Append text to the end of the line. Equivalent to $a.
1870 [count]cmotion
1871 c[count]motion
1872 Delete current character through the character that
1873 motion would move the cursor to and enter input mode.
1874 If motion is c, the entire line will be deleted and
1875 input mode entered.
1876 C Delete the current character through the end of line
1877 and enter input mode. Equivalent to c$.
1878 S Equivalent to cc.
1879 [count]s Replace characters under the cursor in input mode.
1880 D Delete the current character through the end of line.
1881 Equivalent to d$.
1882 [count]dmotion
1883 d[count]motion
1884 Delete current character through the character that
1885 motion would move to. If motion is d , the entire
1886 line will be deleted.
1887 i Enter input mode and insert text before the current
1888 character.
1889 I Insert text before the beginning of the line. Equiva‐
1890 lent to 0i.
1891 [count]P Place the previous text modification before the cur‐
1892 sor.
1893 [count]p Place the previous text modification after the cursor.
1894 R Enter input mode and replace characters on the screen
1895 with characters you type overlay fashion.
1896 [count]rc Replace the count character(s) starting at the current
1897 cursor position with c, and advance the cursor.
1898 [count]x Delete current character.
1899 [count]X Delete preceding character.
1900 [count]. Repeat the previous text modification command.
1901 [count]∼ Invert the case of the count character(s) starting at
1902 the current cursor position and advance the cursor.
1903 [count]_ Causes the count word of the previous command to be
1904 appended and input mode entered. The last word is
1905 used if count is omitted.
1906 * Causes an * to be appended to the current word and
1907 file name generation attempted. If no match is found,
1908 it rings the bell. Otherwise, the word is replaced by
1909 the matching pattern and input mode is entered.
1910 \ Command or file name completion as described above.
1911 Other Edit Commands
1912 Miscellaneous commands.
1913 [count]ymotion
1914 y[count]motion
1915 Yank current character through character that motion
1916 would move the cursor to and puts them into the delete
1917 buffer. The text and cursor are unchanged.
1918 yy Yanks the entire line.
1919 Y Yanks from current position to end of line. Equiva‐
1920 lent to y$.
1921 u Undo the last text modifying command.
1922 U Undo all the text modifying commands performed on the
1923 line.
1924 [count]v Returns the command hist -e ${VISUAL:-${EDITOR:-vi}}
1925 count in the input buffer. If count is omitted, then
1926 the current line is used.
1927 ^L Line feed and print current line. Has effect only in
1928 control mode.
1929 ^J (New line) Execute the current line, regardless of
1930 mode.
1931 ^M (Return) Execute the current line, regardless of mode.
1932 # If the first character of the command is a #, then
1933 this command deletes this # and each # that follows a
1934 newline. Otherwise, sends the line after inserting a
1935 # in front of each line in the command. Useful for
1936 causing the current line to be inserted in the history
1937 as a comment and uncommenting previously commented
1938 commands in the history file.
1939 [count]= If count is not specified, it generates the list of
1940 matching commands or file names as described above.
1941 Otherwise, the word under the the cursor is replaced
1942 by the count item from the most recently generated
1943 command or file list. If the cursor is not on a word,
1944 it is inserted instead.
1945 @letter Your alias list is searched for an alias by the name
1946 _letter and if an alias of this name is defined, its
1947 value will be inserted on the input queue for process‐
1948 ing.
1949 ^V Display version of the shell.
1950
1951 Built-in Commands.
1952 The following simple-commands are executed in the shell process.
1953 Input/Output redirection is permitted. Unless otherwise indicated, the
1954 output is written on file descriptor 1 and the exit status, when there
1955 is no syntax error, is zero. Except for :, true, false, echo, newgrp,
1956 and login, all built-in commands accept -- to indicate end of options.
1957 They also interpret the option --man as a request to display the man
1958 page onto standard error and -? as a help request which prints a usage
1959 message on standard error. Commands that are preceded by one or two †
1960 symbols are special built-in commands and are treated specially in the
1961 following ways:
1962 1. Variable assignment lists preceding the command remain in effect
1963 when the command completes.
1964 2. I/O redirections are processed after variable assignments.
1965 3. Errors cause a script that contains them to abort.
1966 4. They are not valid function names.
1967 5. Words following a command preceded by †† that are in the format
1968 of a variable assignment are expanded with the same rules as a
1969 variable assignment. This means that tilde substitution is per‐
1970 formed after the = sign and field splitting and file name gener‐
1971 ation are not performed.
1972
1973 † : [ arg ... ]
1974 The command only expands parameters.
1975
1976 † . name [ arg ... ]
1977 If name is a function defined with the function name reserved
1978 word syntax, the function is executed in the current environment
1979 (as if it had been defined with the name() syntax.) Otherwise
1980 if name refers to a file, the file is read in its entirety and
1981 the commands are executed in the current shell environment. The
1982 search path specified by PATH is used to find the directory con‐
1983 taining the file. If any arguments arg are given, they become
1984 the positional parameters while processing the . command and
1985 the original positional parameters are restored upon completion.
1986 Otherwise the positional parameters are unchanged. The exit
1987 status is the exit status of the last command executed.
1988
1989 †† alias [ -ptx ] [ name[ =value ] ] ...
1990 alias with no arguments prints the list of aliases in the form
1991 name=value on standard output. The -p option causes the word
1992 alias to be inserted before each one. When one or more argu‐
1993 ments are given, an alias is defined for each name whose value
1994 is given. A trailing space in value causes the next word to be
1995 checked for alias substitution. The obsolete -t option is used
1996 to set and list tracked aliases. The value of a tracked alias
1997 is the full pathname corresponding to the given name. The value
1998 becomes undefined when the value of PATH is reset but the alias
1999 remains tracked. Without the -t option, for each name in the
2000 argument list for which no value is given, the name and value of
2001 the alias is printed. The obsolete -x option has no effect.
2002 The exit status is non-zero if a name is given, but no value,
2003 and no alias has been defined for the name.
2004
2005 bg [ job... ]
2006 This command is only on systems that support job control. Puts
2007 each specified job into the background. The current job is put
2008 in the background if job is not specified. See Jobs for a
2009 description of the format of job.
2010
2011 † break [ n ]
2012 Exit from the enclosing for, while, until, or select loop, if
2013 any. If n is specified, then break n levels.
2014
2015 builtin [ -ds ] [ -f file ] [ name ... ]
2016 If name is not specified, and no -f option is specified, the
2017 built-ins are printed on standard output. The -s option prints
2018 only the special built-ins. Otherwise, each name represents the
2019 pathname whose basename is the name of the built-in. The entry
2020 point function name is determined by prepending b_ to the built-
2021 in name. Special built-ins cannot be bound to a pathname or
2022 deleted. The -d option deletes each of the given built-ins. On
2023 systems that support dynamic loading, the -f option names a
2024 shared library containing the code for built-ins. The shared
2025 library prefix and/or suffix, which depend on the system, can be
2026 omitted. Once a library is loaded, its symbols become available
2027 for subsequent invocations of builtin. Multiple libraries can
2028 be specified with separate invocations of the builtin command.
2029 Libraries are searched in the reverse order in which they are
2030 specified. When a library is loaded, it looks for a function in
2031 the library whose name is lib_init() and invokes this function
2032 with an argument of 0.
2033
2034 cd [ -LP ] [ arg ]
2035 cd [ -LP ] old new
2036 This command can be in either of two forms. In the first form
2037 it changes the current directory to arg. If arg is - the direc‐
2038 tory is changed to the previous directory. The shell variable
2039 HOME is the default arg. The variable PWD is set to the current
2040 directory. The shell variable CDPATH defines the search path
2041 for the directory containing arg. Alternative directory names
2042 are separated by a colon (:). The default path is <null> (spec‐
2043 ifying the current directory). Note that the current directory
2044 is specified by a null path name, which can appear immediately
2045 after the equal sign or between the colon delimiters anywhere
2046 else in the path list. If arg begins with a / then the search
2047 path is not used. Otherwise, each directory in the path is
2048 searched for arg.
2049 The second form of cd substitutes the string new for the string
2050 old in the current directory name, PWD, and tries to change to
2051 this new directory.
2052 By default, symbolic link names are treated literally when find‐
2053 ing the directory name. This is equivalent to the -L option.
2054 The -P option causes symbolic links to be resolved when deter‐
2055 mining the directory. The last instance of -L or -P on the com‐
2056 mand line determines which method is used.
2057 The cd command may not be executed by rksh. rksh93.
2058
2059 command [ -pvxV ] name [ arg ... ]
2060 Without the -v or -V options, command executes name with the
2061 arguments given by arg. The -p option causes a default path to
2062 be searched rather than the one defined by the value of PATH.
2063 Functions will not be searched for when finding name. In addi‐
2064 tion, if name refers to a special built-in, none of the special
2065 properties associated with the leading daggers will be honored.
2066 (For example, the predefined alias redirect=′command exec′ pre‐
2067 vents a script from terminating when an invalid redirection is
2068 given.) With the -x option, if command execution would result
2069 in a failure because there are too many arguments, errno E2BIG,
2070 the shell will invoke command name multiple times with a subset
2071 of the arguments on each invocation. Arguments that occur prior
2072 to the first word that expands to multiple arguments and after
2073 the last word that expands to multiple arguments will be passed
2074 on each invocation. The exit status will be the maximum invoca‐
2075 tion exit status. With the -v option, command is equivalent to
2076 the built-in whence command described below. The -V option
2077 causes command to act like whence -v.
2078
2079 † continue [ n ]
2080 Resume the next iteration of the enclosing for, while, until, or
2081 select loop. If n is specified, then resume at the n-th enclos‐
2082 ing loop.
2083
2084 disown [ job... ]
2085 Causes the shell not to send a HUP signal to each given job, or
2086 all active jobs if job is omitted, when a login shell termi‐
2087 nates.
2088
2089 echo [ arg ... ]
2090 When the first arg does not begin with a -, and none of the
2091 arguments contain a \, then echo prints each of its arguments
2092 separated by a space and terminated by a new-line. Otherwise,
2093 the behavior of echo is system dependent and print or printf
2094 described below should be used. See echo(1) for usage and
2095 description.
2096
2097 † eval [ arg ... ]
2098 The arguments are read as input to the shell and the resulting
2099 command(s) executed.
2100
2101 † exec [ -c ] [ -a name ] [ arg ... ]
2102 If arg is given, the command specified by the arguments is exe‐
2103 cuted in place of this shell without creating a new process.
2104 The -c option causes the environment to be cleared before apply‐
2105 ing variable assignments associated with the exec invocation.
2106 The -a option causes name rather than the first arg, to become
2107 argv[0] for the new process. Input/output arguments may appear
2108 and affect the current process. If arg is not given, the effect
2109 of this command is to modify file descriptors as prescribed by
2110 the input/output redirection list. In this case, any file
2111 descriptor numbers greater than 2 that are opened with this
2112 mechanism are closed when invoking another program.
2113
2114 † exit [ n ]
2115 Causes the shell to exit with the exit status specified by n.
2116 The value will be the least significant 8 bits of the specified
2117 status. If n is omitted, then the exit status is that of the
2118 last command executed. An end-of-file will also cause the shell
2119 to exit except for a shell which has the ignoreeof option (see
2120 set below) turned on.
2121
2122 †† export [ -p ] [ name[=value] ] ...
2123 If name is not given, the names and values of each variable with
2124 the export attribute are printed with the values quoted in a
2125 manner that allows them to be re-input. The -p option causes
2126 the word export to be inserted before each one. Otherwise, the
2127 given names are marked for automatic export to the environment
2128 of subsequently-executed commands.
2129
2130 false Does nothing, and exits 1. Used with until for infinite loops.
2131
2132 fg [ job... ]
2133 This command is only on systems that support job control. Each
2134 job specified is brought to the foreground and waited for in the
2135 specified order. Otherwise, the current job is brought into the
2136 foreground. See Jobs for a description of the format of job.
2137
2138 getconf [ name [ pathname ] ]
2139 Prints the current value of the configuration parameter given by
2140 name. The configuration parameters are defined by the IEEE
2141 POSIX 1003.1 and IEEE POSIX 1003.2 standards. (See pathconf(2)
2142 and sysconf(2).) The pathname argument is required for parame‐
2143 ters whose value depends on the location in the file system. If
2144 no arguments are given, getconf prints the names and values of
2145 the current configuration parameters. The pathname / is used
2146 for each of the parameters that requires pathname.
2147
2148 getopts [ -a name ] optstring vname [ arg ... ]
2149 Checks arg for legal options. If arg is omitted, the positional
2150 parameters are used. An option argument begins with a + or a -.
2151 An option not beginning with + or - or the argument -- ends the
2152 options. Options beginning with + are only recognized when opt‐
2153 string begins with a +. optstring contains the letters that
2154 getopts recognizes. If a letter is followed by a :, that option
2155 is expected to have an argument. The options can be separated
2156 from the argument by blanks. The option -? causes getopts to
2157 generate a usage message on standard error. The -a argument can
2158 be used to specify the name to use for the usage message, which
2159 defaults to $0.
2160 getopts places the next option letter it finds inside variable
2161 vname each time it is invoked. The option letter will be
2162 prepended with a + when arg begins with a +. The index of the
2163 next arg is stored in OPTIND. The option argument, if any, gets
2164 stored in OPTARG.
2165 A leading : in optstring causes getopts to store the letter of
2166 an invalid option in OPTARG, and to set vname to ? for an
2167 unknown option and to : when a required option argument is miss‐
2168 ing. Otherwise, getopts prints an error message. The exit sta‐
2169 tus is non-zero when there are no more options.
2170 There is no way to specify any of the options :, +, -, ?, [, and
2171 ]. The option # can only be specified as the first option.
2172
2173 hist [ -e ename ] [ -nlr ] [ first [ last ] ]
2174 hist -s [ old=new ] [ command ]
2175 In the first form, a range of commands from first to last is
2176 selected from the last HISTSIZE commands that were typed at the
2177 terminal. The arguments first and last may be specified as a
2178 number or as a string. A string is used to locate the most
2179 recent command starting with the given string. A negative num‐
2180 ber is used as an offset to the current command number. If the
2181 -l option is selected, the commands are listed on standard out‐
2182 put. Otherwise, the editor program ename is invoked on a file
2183 containing these keyboard commands. If ename is not supplied,
2184 then the value of the variable HISTEDIT is used. If HISTEDIT is
2185 not set, then FCEDIT (default /bin/ed) is used as the editor.
2186 When editing is complete, the edited command(s) is executed if
2187 the changes have been saved. If last is not specified, then it
2188 will be set to first. If first is not specified, the default is
2189 the previous command for editing and -16 for listing. The
2190 option -r reverses the order of the commands and the option -n
2191 suppresses command numbers when listing. In the second form,
2192 command is interpreted as first described above and defaults to
2193 the last command executed. The resulting command is executed
2194 after the optional substitution old=new is performed.
2195
2196 jobs [ -lnp ] [ job ... ]
2197 Lists information about each given job; or all active jobs if
2198 job is omitted. The -l option lists process ids in addition to
2199 the normal information. The -n option only displays jobs that
2200 have stopped or exited since last notified. The -p option
2201 causes only the process group to be listed. See Jobs for a
2202 description of the format of job.
2203
2204 kill [ -s signame ] job ...
2205 kill [ -n signum ] job ...
2206 kill -l [ sig ... ]
2207 Sends either the TERM (terminate) signal or the specified signal
2208 to the specified jobs or processes. Signals are either given by
2209 number with the -n option or by name with the -s option (as
2210 given in <signal.h>, stripped of the prefix ``SIG'' with the
2211 exception that SIGCLD is named CHLD). For backward compatibil‐
2212 ity, the n and s can be omitted and the number or name placed
2213 immediately after the -. If the signal being sent is TERM (ter‐
2214 minate) or HUP (hangup), then the job or process will be sent a
2215 CONT (continue) signal if it is stopped. The argument job can
2216 be the process id of a process that is not a member of one of
2217 the active jobs. See Jobs for a description of the format of
2218 job. In the third form, kill -l, if sig is not specified, the
2219 signal names are listed. Otherwise, for each sig that is a
2220 name, the corresponding signal number is listed. For each sig
2221 that is a number, the signal name corresponding to the least
2222 significant 8 bits of sig is listed.
2223
2224 let arg ...
2225 Each arg is a separate arithmetic expression to be evaluated.
2226 See Arithmetic Evaluation above, for a description of arithmetic
2227 expression evaluation.
2228 The exit status is 0 if the value of the last expression is non-
2229 zero, and 1 otherwise.
2230
2231 † newgrp [ arg ... ]
2232 Equivalent to exec /bin/newgrp arg ....
2233
2234 print [ -Renprs ] [ -u unit] [ -f format ] [ arg ... ]
2235 With no options or with option - or --, each arg is printed on
2236 standard output. The -f option causes the arguments to be
2237 printed as described by printf. In this case, any e, n, r, R
2238 options are ignored. Otherwise, unless the -R or -r, are speci‐
2239 fied, the following escape conventions will be applied:
2240 \a The alert character (ascii 07).
2241 \b The backspace character (ascii 010).
2242 \c Causes print to end without processing more arguments and
2243 not adding a new-line.
2244 \f The formfeed character (ascii 014).
2245 \n The new-line character (ascii 012).
2246 \r The carriage return character (ascii 015).
2247 \t The tab character (ascii 011).
2248 \v The vertical tab character (ascii 013).
2249 \E The escape character (ascii 033).
2250 \\ The backslash character \.
2251 \0x The character defined by the 1, 2, or 3-digit octal
2252 string given by x.
2253
2254 The -R option will print all subsequent arguments and options
2255 other than -n. The -e causes the above escape conventions to be
2256 applied This is the default behavior. It reverses the effect of
2257 an earlier -r. The -p option causes the arguments to be written
2258 onto the pipe of the process spawned with ⎪& instead of standard
2259 output. The -s option causes the arguments to be written onto
2260 the history file instead of standard output. The -u option can
2261 be used to specify a one digit file descriptor unit number unit
2262 on which the output will be placed. The default is 1. If the
2263 option -n is used, no new-line is added to the output.
2264
2265 printf format [ arg ... ]
2266 The arguments arg are printed on standard output in accordance
2267 with the ANSI-C formatting rules associated with the format
2268 string format. If the number of arguments exceeds the number of
2269 format specifications, the format string is reused to format
2270 remaining arguments. The following extensions can also be used:
2271 A %b format can be used instead of %s to cause escape sequences
2272 in the corresponding arg to be expanded as described in print.
2273 A %B option causes each of the arguments to be treated as vari‐
2274 able names and the binary value of variable will be printed.
2275 This is most useful for variables whose attribute is -b. A %H
2276 format can be used instead of %s to cause characters in arg that
2277 are special in HTML and XML to be output to be output as their
2278 entity name. A %P format can be used instead of %s to cause arg
2279 to be interpreted as an extended regular expression and be
2280 printed as a shell pattern. A %R format can be used instead of
2281 %s to cause arg interpreted as a shell pattern and to be printed
2282 as an extended regular expression. A %q format can be used
2283 instead of %s to cause the resulting string to be quoted in a
2284 manner than can be reinput to the shell. A %(date-format)T for‐
2285 mat can be use to treat an argument as a date/time string and to
2286 format the date/time according to the date-format as defined for
2287 the date(1) command. A %Z format will output a byte whose value
2288 is 0. The precision field of the %d format can be followed by a
2289 . and the output base. In this case, the # flag character
2290 caues base# to be prepended. The # flag when used with the d
2291 specifier without an output base, causes the output to be dis‐
2292 played in thousands units with one of the suffixes k M G T P E
2293 to indicate the unit. The # flag when used with the i specifier
2294 causes the output to be displayed in 1024 with one of the suf‐
2295 fixes Ki Mi Gi Ti Pi Ei to indicate the unit.
2296
2297 pwd [ -LP ]
2298 Outputs the value of the current working directory. The -L
2299 option is the default; it prints the logical name of the current
2300 directory. If the -P option is given, all symbolic links are
2301 resolved from the name. The last instance of -L or -P on the
2302 command line determines which method is used.
2303
2304 read [ -Aprs ] [ -d delim] [ -n n] [ [ -N n] [ [ -t timeout] [ -u unit]
2305 [ vname?prompt ] [ vname ... ]
2306 The shell input mechanism. One line is read and is broken up
2307 into fields using the characters in IFS as separators. The
2308 escape character, \, is used to remove any special meaning for
2309 the next character and for line continuation. The -d option
2310 causes the read to continue to the first character of delim
2311 rather than new-line. The -n option causes at most n bytes to
2312 read rather a full line but will return when reading from a slow
2313 device as soon as any characters have been read. The -N option
2314 causes exactly n to be read unless an end-of-file has been
2315 encountered or the read times out because of the -t option. In
2316 raw mode, -r, the \ character is not treated specially. The
2317 first field is assigned to the first vname, the second field to
2318 the second vname, etc., with leftover fields assigned to the
2319 last vname. When vname has the binary attribute and -n or -N is
2320 specified, the bytes that are read are stored directly into the
2321 variable. If the -v is specified, then the value of the first
2322 vname will be used as a default value when reading from a termi‐
2323 nal device. The -A option causes the variable vname to be unset
2324 and each field that is read to be stored in successive elements
2325 of the indexed array vname. The -p option causes the input line
2326 to be taken from the input pipe of a process spawned by the
2327 shell using ⎪&. If the -s option is present, the input will be
2328 saved as a command in the history file. The option -u can be
2329 used to specify a one digit file descriptor unit unit to read
2330 from. The file descriptor can be opened with the exec special
2331 built-in command. The default value of unit n is 0. The option
2332 -t is used to specify a timeout in seconds when reading from a
2333 terminal or pipe. If vname is omitted, then REPLY is used as
2334 the default vname. An end-of-file with the -p option causes
2335 cleanup for this process so that another can be spawned. If the
2336 first argument contains a ?, the remainder of this word is used
2337 as a prompt on standard error when the shell is interactive.
2338 The exit status is 0 unless an end-of-file is encountered or
2339 read has timed out.
2340
2341 †† readonly [ -p ] [ vname[=value] ] ...
2342 If vname is not given, the names and values of each variable
2343 with the readonly attribute is printed with the values quoted in
2344 a manner that allows them to be re-inputted. The -p option
2345 causes the word readonly to be inserted before each one. Other‐
2346 wise, the given vnames are marked readonly and these names can‐
2347 not be changed by subsequent assignment.
2348
2349 † return [ n ]
2350 Causes a shell function or . script to return to the invoking
2351 script with the exit status specified by n. The value will be
2352 the least significant 8 bits of the specified status. If n is
2353 omitted, then the return status is that of the last command exe‐
2354 cuted. If return is invoked while not in a function or a .
2355 script, then it behaves the same as exit.
2356
2357 † set [ ±CGabefhkmnoprstuvx ] [ ±o [ option ] ] ... [ ±A vname ] [ arg
2358 ... ]
2359 The options for this command have meaning as follows:
2360 -A Array assignment. Unset the variable vname and assign
2361 values sequentially from the arg list. If +A is used,
2362 the variable vname is not unset first.
2363 -B Enable brace pattern field generation. This is the
2364 default behavior.
2365 -C Prevents redirection > from truncating existing files.
2366 Files that are created are opened with the O_EXCL mode.
2367 Requires >⎪ to truncate a file when turned on.
2368 -G Causes the pattern ∗∗ by itself to match files and zero
2369 or more directories and sub-directories when used for
2370 file name generation. If followed by a / only directo‐
2371 ries and sub-directories are matched.
2372 -a All subsequent variables that are defined are automati‐
2373 cally exported.
2374 -b Prints job completion messages as soon as a background
2375 job changes state rather than waiting for the next
2376 prompt.
2377 -e If a command has a non-zero exit status, execute the ERR
2378 trap, if set, and exit. This mode is disabled while
2379 reading profiles.
2380 -f Disables file name generation.
2381 -h Each command becomes a tracked alias when first encoun‐
2382 tered.
2383 -k (Obsolete). All variable assignment arguments are placed
2384 in the environment for a command, not just those that
2385 precede the command name.
2386 -m Background jobs will run in a separate process group and
2387 a line will print upon completion. The exit status of
2388 background jobs is reported in a completion message. On
2389 systems with job control, this option is turned on auto‐
2390 matically for interactive shells.
2391 -n Read commands and check them for syntax errors, but do
2392 not execute them. Ignored for interactive shells.
2393 -o The following argument can be one of the following
2394 option names:
2395 allexport
2396 Same as -a.
2397 errexit Same as -e.
2398 bgnice All background jobs are run at a lower priority.
2399 This is the default mode.
2400 bracexpand
2401 Sans as -B.
2402 emacs Puts you in an emacs style in-line editor for
2403 command entry.
2404 globstar
2405 Same as -G.
2406 gmacs Puts you in a gmacs style in-line editor for
2407 command entry.
2408 ignoreeof
2409 The shell will not exit on end-of-file. The
2410 command exit must be used.
2411 keyword Same as -k.
2412 markdirs
2413 All directory names resulting from file name
2414 generation have a trailing / appended.
2415 monitor Same as -m.
2416 multiline
2417 The built-in editors will use multiple lines on
2418 the screen for lines that are longer than the
2419 width of the screen. This may not work for all
2420 terminals.
2421 noclobber
2422 Same as -C.
2423 noexec Same as -n.
2424 noglob Same as -f.
2425 nolog Do not save function definitions in the history
2426 file.
2427 notify Same as -b.
2428 nounset Same as -u.
2429 pipefail
2430 A pipeline will not complete until all compo‐
2431 nents of the pipeline have completed, and the
2432 return value will be the value of the last non-
2433 zero command to fail or zero of no command has
2434 failed.
2435 showme When enabled, simple commands or pipelines pre‐
2436 ceded by a a semicolon (;) will be displayed as
2437 if the xtrace option were enabled but will not
2438 be executed. Otherwise, the leading ; will be
2439 ignored.
2440 privileged
2441 Same as -p.
2442 verbose Same as -v.
2443 trackall
2444 Same as -h.
2445 vi Puts you in insert mode of a vi style in-line
2446 editor until you hit the escape character 033.
2447 This puts you in control mode. A return sends
2448 the line.
2449 viraw Each character is processed as it is typed in vi
2450 mode.
2451 xtrace Same as -x.
2452 If no option name is supplied, then the current option
2453 settings are printed.
2454 -p Disables processing of the $HOME/.profile file and uses
2455 the file /etc/suid_profile instead of the ENV file.
2456 This mode is on whenever the effective uid (gid) is not
2457 equal to the real uid (gid). Turning this off causes
2458 the effective uid and gid to be set to the real uid and
2459 gid.
2460 -r Enables the restricted shell. This option cannot be
2461 unset once set.
2462 -s Sort the positional parameters lexicographically.
2463 -t (Obsolete). Exit after reading and executing one com‐
2464 mand.
2465 -u Treat unset parameters as an error when substituting.
2466 -v Print shell input lines as they are read.
2467 -x Print commands and their arguments as they are executed.
2468 -- Do not change any of the options; useful in setting $1
2469 to a value beginning with -. If no arguments follow
2470 this option then the positional parameters are unset.
2471
2472 As an obsolete feature, if the first arg is - then the -x and -v
2473 options are turned off and the next arg is treated as the first
2474 argument. Using + rather than - causes these options to be
2475 turned off. These options can also be used upon invocation of
2476 the shell. The current set of options may be found in $-.
2477 Unless -A is specified, the remaining arguments are positional
2478 parameters and are assigned, in order, to $1 $2 .... If no
2479 arguments are given, then the names and values of all variables
2480 are printed on the standard output.
2481
2482 † shift [ n ]
2483 The positional parameters from $n+1 ... are renamed $1 ... ,
2484 default n is 1. The parameter n can be any arithmetic expres‐
2485 sion that evaluates to a non-negative number less than or equal
2486 to $#.
2487
2488 sleep seconds
2489 Suspends execution for the number of decimal seconds or frac‐
2490 tions of a second given by seconds.
2491
2492 † trap [ -p ] [ action ] [ sig ] ...
2493 The -p option causes the trap action associated with each trap
2494 as specified by the arguments to be printed with appropriate
2495 quoting. Otherwise, action will be processed as if it were an
2496 argument to eval when the shell receives signal(s) sig. Each
2497 sig can be given as a number or as the name of the signal. Trap
2498 commands are executed in order of signal number. Any attempt to
2499 set a trap on a signal that was ignored on entry to the current
2500 shell is ineffective. If action is omitted and the first sig is
2501 a number, or if action is -, then the trap(s) for each sig are
2502 reset to their original values. If action is the null string
2503 then this signal is ignored by the shell and by the commands it
2504 invokes. If sig is ERR then action will be executed whenever a
2505 command has a non-zero exit status. If sig is DEBUG then action
2506 will be executed before each command. The variable .sh.command
2507 will contain the contents of the current command line when
2508 action is running. If sig is 0 or EXIT and the trap statement
2509 is executed inside the body of a function defined with the func‐
2510 tion name syntax, then the command action is executed after the
2511 function completes. If sig is 0 or EXIT for a trap set outside
2512 any function then the command action is executed on exit from
2513 the shell. If sig is KEYBD, then action will be executed when‐
2514 ever a key is read while in emacs, gmacs, or vi mode. The trap
2515 command with no arguments prints a list of commands associated
2516 with each signal number.
2517
2518 true Does nothing, and exits 0. Used with while for infinite loops.
2519
2520 †† typeset [ ±AHflabnprtux ] [ ±EFLRZi[n] ] [ vname[=value ] ] ...
2521 Sets attributes and values for shell variables and functions.
2522 When invoked inside a function defined with the function name
2523 syntax, a new instance of the variable vname is created, and the
2524 variable's value and type are restored when the function com‐
2525 pletes. The following list of attributes may be specified:
2526 -A Declares vname to be an associative array. Subscripts
2527 are strings rather than arithmetic expressions.
2528 -a Declares vname to be an indexed array. This is optional
2529 unless except for compound variable assignments.
2530 -E Declares vname to be a double precision floating point
2531 number. If n is non-zero, it defines the number of sig‐
2532 nificant figures that are used when expanding vname.
2533 Otherwise, ten significant figures will be used.
2534 -F Declares vname to be a double precision floating point
2535 number. If n is non-zero, it defines the number of
2536 places after the decimal point that are used when expand‐
2537 ing vname. Otherwise ten places after the decimal point
2538 will be used.
2539 -H This option provides UNIX to host-name file mapping on
2540 non-UNIX machines.
2541 -L Left justify and remove leading blanks from value. If n
2542 is non-zero, it defines the width of the field, otherwise
2543 it is determined by the width of the value of first
2544 assignment. When the variable is assigned to, it is
2545 filled on the right with blanks or truncated, if neces‐
2546 sary, to fit into the field. The -R option is turned
2547 off.
2548 -R Right justify and fill with leading blanks. If n is non-
2549 zero, it defines the width of the field, otherwise it is
2550 determined by the width of the value of first assignment.
2551 The field is left filled with blanks or truncated from
2552 the end if the variable is reassigned. The -L option is
2553 turned off.
2554 -Z Right justify and fill with leading zeros if the first
2555 non-blank character is a digit and the -L option has not
2556 been set. Remove leading zeros if the -L option is also
2557 set. If n is non-zero, it defines the width of the
2558 field, otherwise it is determined by the width of the
2559 value of first assignment.
2560 -f The names refer to function names rather than variable
2561 names. No assignments can be made and the only other
2562 valid options are -t, -u and -x. The -t option turns on
2563 execution tracing for this function. The -u option
2564 causes this function to be marked undefined. The FPATH
2565 variable will be searched to find the function definition
2566 when the function is referenced. If no options other
2567 than -f is specified, then the function definition will
2568 be displayed on standard output. If +f is specified,
2569 then a line containing the function name followed by a
2570 shell comment containing the line number and path name of
2571 the file where this function was defined, if any, is dis‐
2572 played.
2573 -b The variable can hold any number of bytes of data. The
2574 data can be text or binary. The value is represented by
2575 the base64 encoding of the data. If -Z is also speci‐
2576 fied, the size in bytes of the data in the buffer will be
2577 determined by the size associated with the -Z. If the
2578 base64 string assigned results in more data, it will be
2579 truncated. Otherwise, it will be filled with bytes whose
2580 value is zero. The printf format %B can be used to out‐
2581 put the actual data in this buffer instead of the base64
2582 encoding of the data.
2583 -i Declares vname to be represented internally as integer.
2584 The right hand side of an assignment is evaluated as an
2585 arithmetic expression when assigning to an integer. If n
2586 is non-zero, it defines the output arithmetic base, oth‐
2587 erwise the output base will be ten.
2588 -l All upper-case characters are converted to lower-case.
2589 The upper-case option, -u, is turned off.
2590 -n Declares vname to be a reference to the variable whose
2591 name is defined by the value of variable vname. This is
2592 usually used to reference a variable inside a function
2593 whose name has been passed as an argument.
2594 -r The given vnames are marked readonly and these names can‐
2595 not be changed by subsequent assignment.
2596 -t Tags the variables. Tags are user definable and have no
2597 special meaning to the shell.
2598 -u All lower-case characters are converted to upper-case.
2599 The lower-case option, -l, is turned off.
2600 -x The given vnames are marked for automatic export to the
2601 environment of subsequently-executed commands. Variables
2602 whose names contain a . cannot be exported.
2603
2604 The -i attribute cannot be specified along with -R, -L, -Z, or
2605 -f.
2606
2607 Using + rather than - causes these options to be turned off. If
2608 no vname arguments are given, a list of vnames (and optionally
2609 the values) of the variables is printed. (Using + rather than -
2610 keeps the values from being printed.) The -p option causes
2611 typeset followed by the option letters to be printed before each
2612 name rather than the names of the options. If any option other
2613 than -p is given, only those variables which have all of the
2614 given options are printed. Otherwise, the vnames and attributes
2615 of all variables that have attributes are printed.
2616
2617 ulimit [ -HSacdfmnpstv ] [ limit ]
2618 Set or display a resource limit. The available resource limits
2619 are listed below. Many systems do not support one or more of
2620 these limits. The limit for a specified resource is set when
2621 limit is specified. The value of limit can be a number in the
2622 unit specified below with each resource, or the value unlimited.
2623 The -H and -S options specify whether the hard limit or the soft
2624 limit for the given resource is set. A hard limit cannot be
2625 increased once it is set. A soft limit can be increased up to
2626 the value of the hard limit. If neither the H nor S options is
2627 specified, the limit applies to both. The current resource
2628 limit is printed when limit is omitted. In this case, the soft
2629 limit is printed unless H is specified. When more than one
2630 resource is specified, then the limit name and unit is printed
2631 before the value.
2632 -a Lists all of the current resource limits.
2633 -c The number of 512-byte blocks on the size of core dumps.
2634 -d The number of K-bytes on the size of the data area.
2635 -f The number of 512-byte blocks on files that can be writ‐
2636 ten by the current process or by child processes (files
2637 of any size may be read).
2638 -m The number of K-bytes on the size of physical memory.
2639 -n The number of file descriptors plus 1.
2640 -p The number of 512-byte blocks for pipe buffering.
2641 -s The number of K-bytes on the size of the stack area.
2642 -t The number of CPU seconds to be used by each process.
2643 -v The number of K-bytes for virtual memory.
2644
2645 If no option is given, -f is assumed.
2646
2647 umask [ -S ] [ mask ]
2648 The user file-creation mask is set to mask (see umask(2)). mask
2649 can either be an octal number or a symbolic value as described
2650 in chmod(1). If a symbolic value is given, the new umask value
2651 is the complement of the result of applying mask to the comple‐
2652 ment of the previous umask value. If mask is omitted, the cur‐
2653 rent value of the mask is printed. The -S option causes the
2654 mode to be printed as a symbolic value. Otherwise, the mask is
2655 printed in octal.
2656
2657 † unalias [ -a ] name ...
2658 The aliases given by the list of names are removed from the
2659 alias list. The -a option causes all the aliases to be unset.
2660
2661 †unset [ -fnv ] vname ...
2662 The variables given by the list of vnames are unassigned, i.e.,
2663 their values and attributes are erased. Readonly variables can‐
2664 not be unset. If the -f option is set, then the names refer to
2665 function names. If the -v option is set, then the names refer
2666 to variable names. The -f option overrides -v. If -n is set
2667 and name is a name reference, then name will be unset rather
2668 than the variable that it references. The default is equivalent
2669 to -v. Unsetting LINENO, MAILCHECK, OPTARG, OPTIND, RANDOM,
2670 SECONDS, TMOUT, and _ removes their special meaning even if they
2671 are subsequently assigned to.
2672
2673 wait [ job ... ]
2674 Wait for the specified job and report its termination status.
2675 If job is not given, then all currently active child processes
2676 are waited for. The exit status from this command is that of
2677 the last process waited for if job is specified; otherwise it is
2678 zero. See Jobs for a description of the format of job.
2679
2680 whence [ -afpv ] name ...
2681 For each name, indicate how it would be interpreted if used as a
2682 command name.
2683 The -v option produces a more verbose report. The -f options
2684 skips the search for functions. The -p option does a path
2685 search for name even if name is an alias, a function, or a
2686 reserved word. The -a option is similar to the -v option but
2687 causes all interpretations of the given name to be reported.
2688
2689 Invocation.
2690 If the shell is invoked by exec(2), and the first character of argument
2691 zero ($0) is -, then the shell is assumed to be a login shell and com‐
2692 mands are read from /etc/profile and then from either .profile in the
2693 current directory or $HOME/.profile, if either file exists. Next, for
2694 interactive shells, commands are read from the file named by performing
2695 parameter expansion, command substitution, and arithmetic substitution
2696 on the value of the environment variable ENV if the file exists. If
2697 the -s option is not present and arg and a file by the name of arg
2698 exits, then it reads and executes this script. Otherwise, if the first
2699 arg does not contain a /, a path search is performed on the first arg
2700 to determine the name of the script to execute. The script arg must
2701 have execute permission and any setuid and setgid settings will be
2702 ignored. If the script is not found on the path, arg is processed as
2703 if it named a built-in command or function. Commands are then read as
2704 described below; the following options are interpreted by the shell
2705 when it is invoked:
2706
2707 -c If the -c option is present, then commands are read from the
2708 first arg. Any remaining arguments become positional parame‐
2709 ters starting at 0.
2710 -s If the -s option is present or if no arguments remain, then
2711 commands are read from the standard input. Shell output,
2712 except for the output of the Special Commands listed above,
2713 is written to file descriptor 2.
2714 -i If the -i option is present or if the shell input and output
2715 are attached to a terminal (as told by tcgetattr(2)), then
2716 this shell is interactive. In this case TERM is ignored (so
2717 that kill 0 does not kill an interactive shell) and INTR is
2718 caught and ignored (so that wait is interruptible). In all
2719 cases, QUIT is ignored by the shell.
2720 -r If the -r option is present, the shell is a restricted shell.
2721 -D A list of all double quoted strings that are preceded by a $
2722 will be printed on standard output and the shell will exit.
2723 This set of strings will be subject to language translation
2724 when the locale is not C or POSIX. No commands will be exe‐
2725 cuted.
2726
2727 -P If -P or -o profile is present, the shell is a profile shell
2728 (see pfexec(1)).
2729
2730 -R filename
2731 The -R filename option is used to generate a cross reference
2732 database that can be used by a separate utility to find defi‐
2733 nitions and references for variables and commands.
2734
2735 The remaining options and arguments are described under the set command
2736 above. An optional - as the first argument is ignored.
2737
2738 Rksh Only.
2739 Rksh is used to set up login names and execution environments whose
2740 capabilities are more controlled than those of the standard shell. The
2741 actions of rksh are identical to those of ksh, except that the follow‐
2742 ing are disallowed:
2743 Unsetting the restricted option.
2744 changing directory (see cd(1)),
2745 setting or unsetting the value or attributes of SHELL, ENV,
2746 FPATH, or PATH,
2747 specifying path or command names containing /,
2748 redirecting output (>, >|, <>, and >>).
2749 adding or deleting built-in commands.
2750 using command -p to invoke a command.
2751
2752 The restrictions above are enforced after .profile and the ENV files
2753 are interpreted.
2754
2755 When a command to be executed is found to be a shell procedure, rksh
2756 invokes ksh to execute it. Thus, it is possible to provide to the end-
2757 user shell procedures that have access to the full power of the stan‐
2758 dard shell, while imposing a limited menu of commands; this scheme
2759 assumes that the end-user does not have write and execute permissions
2760 in the same directory.
2761
2762 The net effect of these rules is that the writer of the .profile has
2763 complete control over user actions, by performing guaranteed setup
2764 actions and leaving the user in an appropriate directory (probably not
2765 the login directory).
2766
2767 The system administrator often sets up a directory of commands (e.g.,
2768 /usr/rbin) that can be safely invoked by rksh.
2769
2771 Errors detected by the shell, such as syntax errors, cause the shell to
2772 return a non-zero exit status. If the shell is being used non-interac‐
2773 tively, then execution of the shell file is abandoned unless the error
2774 occurs inside a subshell in which case the subshell is abandoned. Oth‐
2775 erwise, the shell returns the exit status of the last command executed
2776 (see also the exit command above). Run time errors detected by the
2777 shell are reported by printing the command or function name and the
2778 error condition. If the line number that the error occurred on is
2779 greater than one, then the line number is also printed in square brack‐
2780 ets ([]) after the command or function name.
2781
2783 /etc/profile The system wide initialization file, executed for login
2784 shells.
2785 $HOME/.profile
2786 The personal initialization file, executed for login shells
2787 after /etc/profile.
2788 $HOME/..kshrc
2789 Default personal initialization file, executed for interactive
2790 shells when ENV is not set.
2791 /etc/suid_profile
2792 Alternative initialization file, executed when instead of per‐
2793 sonal initialization file when the real and effective user or
2794 group id do not match.
2795 /dev/null
2796 NULL device
2797
2799 cat(1), cd(1), chmod(1), cut(1), egrep(1), echo(1), emacs(1), env(1),
2800 fgrep(1), gmacs(1), grep(1), newgrp(1), pfexec(1), stty(1), test(1),
2801 umask(1), vi(1), dup(2), exec(2), fork(2), getpwnam(3), ioctl(2),
2802 lseek(2), paste(1), pathconf(2), pipe(2), sysconf(2), umask(2),
2803 ulimit(2), wait(2), rand(3), a.out(5), profile(5), environ(7).
2804
2805 Morris I. Bolsky and David G. Korn, The New KornShell Command and Pro‐
2806 gramming Language, Prentice Hall, 1995.
2807
2808 POSIX - Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC
2809 9945-2, IEEE, 1993.
2810
2812 If a command is executed, and then a command with the same name is
2813 installed in a directory in the search path before the directory where
2814 the original command was found, the shell will continue to exec the
2815 original command. Use the -t option of the alias command to correct
2816 this situation.
2817
2818 Some very old shell scripts contain a ^ as a synonym for the pipe char‐
2819 acter ⎪.
2820
2821 Using the hist built-in command within a compound command will cause
2822 the whole command to disappear from the history file.
2823
2824 The built-in command . file reads the whole file before any commands
2825 are executed. Therefore, alias and unalias commands in the file will
2826 not apply to any commands defined in the file.
2827
2828 Traps are not processed while a job is waiting for a foreground
2829 process. Thus, a trap on CHLD won't be executed until the foreground
2830 job terminates.
2831
2832 It is a good idea to leave a space after the comma operator in arith‐
2833 metic expressions to prevent the comma from being interpreted as the
2834 decimal point character in certain locales.
2835
2836
2837
2838RDS Standard User Environment Utilities KSH(1)