1 .\" $XConsortium: ksh93.man /main/2 1995/07/17 10:51:12 drk $
4 .\" AT&T Bell Laboratories
6 .\" @(#)sh.1 (ulysses!dgk) 01/14/93-beta15
8 .nr Z 1 \" set to 1 when command name is ksh rather than sh
9 .nr Y 0 \" set to 1 for R&D UNIX
13 .ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
14 .ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
19 .if \nZ=1 .TH KSH 1 "User Environment Utilities" "RDS Standard"
21 .if \nZ=0 sh, rsh \- shell, the
22 .if \nZ=1 ksh, rksh \- KornShell, a
23 standard/restricted command and programming language
28 .B \(+-abcefhikmnoprstuvxCP
40 .B \(+-abcefhikmnoprstuvxCP
51 is a command and programming language
52 that executes commands read from a terminal
56 is a restricted version of the
61 it is used to set up login names and execution environments whose
62 capabilities are more controlled than those of the standard shell.
66 for the meaning of arguments to the shell.
70 is one of the following characters:
73 \f3; & ( ) \(bv < > new-line space tab\fP
84 is a sequence of letters, digits, or underscores
85 starting with a letter or underscore.
86 Identifiers are used as components of
91 is a sequence of one or more identifiers
92 separated by a \fB\s+2.\s-2\fP and optionally preceded
94 Vnames are used as function and variable names.
104 is a sequence of characters in the syntax
105 of the shell language.
106 The shell reads each command and
107 carries out the desired action either directly or by invoking
109 A built-in command is a command that is carried out by the
110 shell itself without creating a separate process.
111 Some commands are built-in purely for convenience
112 and are not documented here.
114 side effects in the shell environment and
115 built-ins that are found before performing a
120 For historical reasons, some of
121 these built-ins behave differently than
122 other built-ins and are called
123 .IR "special built-ins" .
127 is a list of variable assignments
129 .I Variable Assignments\^
134 which may be preceded by a list of variable assignments
138 The first word specifies the name of the command to
140 Except as specified below,
141 the remaining words are passed as arguments
142 to the invoked command.
143 The command name is passed as argument 0
148 of a simple-command is its exit status; 0-255
149 if it terminates normally; 256+\f2signum\^\fP if
150 it terminates abnormally (the name of the signal corresponding
151 to the exit status can be
159 .I "arithmetic command"
162 and consists of an arithmetic expression formed by
163 all the characters until a matching
166 .I "Arithmetic evaluation"
168 The exit status of an arithmetic command is 0 when the
169 arithmetic expression evaluates to a non-zero value and
170 is 1 when the arithmetic expression evaluates to 0.
174 is a sequence of one or more
178 The standard output of each command but the last
181 to the standard input of the next command.
183 except possibly the last,
184 is run as a separate process;
185 the shell waits for the last command to terminate.
186 The exit status of a pipeline is the exit
187 status of the last command.
188 Each pipeline can be preceded by the
191 which negates the exit status of the pipeline.
195 is a sequence of one or more
204 and optionally terminated by
209 Of these five symbols,
214 have equal precedence,
215 which is lower than that of
223 also have equal precedence.
226 causes sequential execution of the preceding pipeline; an ampersand
228 causes asynchronous execution of the preceding pipeline (i.e., the shell does
230 wait for that pipeline to finish).
233 causes asynchronous execution of the preceding pipeline
234 with a two-way pipe established to the parent shell;
235 the standard input and output of the spawned pipeline
236 can be written to and read from by the parent shell
238 the redirection operators
244 to commands and by using
247 the built-in commands
254 .RB (\| \(bv\|\(bv \^)
257 following it to be executed only if the preceding
259 returns a zero (non-zero) value.
260 An arbitrary number of new-lines may appear in a
262 instead of a semicolon,
263 to delimit a command.
267 is either a simple-command
268 or one of the following.
269 Unless otherwise stated,
270 the value returned by a command is that of the
271 last simple-command executed in the command.
273 \f3for\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
290 command executes the \f3do\fP \f2list\^\fP once for each positional parameter
293 .I "Parameter Expansion\^"
295 Execution ends when there are no more words in the list.
297 \f3for ((\fP \*(OK\f2expr1\^\fP\*(CK \f3;\fP \*(OK\f2expr2\^\fP\*(CK \f3;\fP \*(OK\f2expr3\^\fP\*(CK \f3))\fP \f3;do\fP \f2list\^\fP \f3;done\fP
298 The arithmetic expression
302 .I "Arithmetic evaluation"
304 The arithmetic expression
306 is repeatedly evaluated until it evalues to zero and when non-zero,
308 is executed and the arithmetic expression
312 is omitted, then it behaves as if it evaluated to 1.
314 \f3select\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
317 command prints on standard error (file descriptor 2) the set of
319 each preceded by a number.
325 positional parameters
328 .I "Parameter Expansion\^"
334 and a line is read from the standard input.
335 If this line consists of the number
338 then the value of the variable
342 corresponding to this number.
343 If this line is empty the selection list is
345 Otherwise the value of the variable
349 The contents of the line read from standard input is
356 is executed for each selection until a
368 then the selection list is printed before
372 prompt for the next selection.
374 \f3case\fP \f2word\^\fP \f3in\fP \*(OK \*(OK\f3(\fP\*(CK\f2pattern\^\fP \*(OK \(bv \f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
379 associated with the first
383 The form of the patterns is
384 the same as that used for
385 file-name generation (see
386 .I "File Name Generation\^"
390 operator causes execution of
397 the next subsequent list, if any, is executed.
400 \f3if\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(OK \
401 \f3elif\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(CK .\|.\|. \
402 \*(OK \f3;else\fP \f2list\^\fP \*(CK \f3;f\&i\fP
406 following \f3if\fP is executed and,
408 returns a zero exit status, the
417 is executed and, if its value is zero,
431 has non-zero exit status
437 command returns a zero exit status.
440 \f3while\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
442 \f3until\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
446 command repeatedly executes the
449 and, if the exit status of the last command in the list is zero, executes
453 otherwise the loop terminates.
454 If no commands in the
457 are executed, then the
459 command returns a zero exit status;
461 may be used in place of
464 the loop termination test.
466 \f3(\fP\f2list\^\fP\f3)\fP
470 in a separate environment.
471 Note, that if two adjacent open parentheses are
472 needed for nesting, a space must be inserted to avoid
473 evaluation as an arithmetic command as described above.
475 \f3{ \fP\f2list\^\fP\f3;}\fP
479 Note that unlike the metacharacters
487 .IR "reserved word" s
489 at the beginning of a line or after a
491 in order to be recognized.
493 \f3[[\fP\f2 expression \^\fP\f3]]\fP
497 and returns a zero exit status when
501 .I "Conditional Expressions\^"
502 below, for a description of
506 \f3function\fP \f2varname\^\fP \f3{\fP \f2list\^\fP \f3;}\fP
508 \f2varname\^\fP \f3() {\fP \f2list\^\fP \f3;}\fP
510 Define a function which is referenced by
516 is called a discipline function and the portion
521 must refer to an existing variable.
522 The body of the function is the
528 A function defined with the \f3function\fP \f2varname\^\fP
529 syntax can also be used as an argument to the \f3.\fP
530 special built-in command to get the equivalent behavior
531 as if the \f2varname\^\fP\f3()\fP syntax were used to define it.
536 \f3time\fP \*(OK \f2pipeline\^\fP \*(CK
538 If \f2pipeline\^\fP is omitted the user and system time for
539 the current shell and completed child processes is printed
543 is executed and the elapsed time as well as
544 the user and system time are printed on standard error.
546 The following reserved words
547 are only recognized as such when they are the first word of a command
552 .if n if then else elif fi case esac for while until do done { } function select time [[ ]] !
553 .if t if then else elif fi case esac for while until do done { } function select time [[ ]] !
555 .SS Variable Assignments.
556 One or more variable assignments can start a simple command
557 or can be an arguments to the
562 special built-in commands.
563 The syntax for an \f2assignment\^\fP is of the form:
566 \f2varname\^\fP\f3=\fP\f2word\^\fP
568 \f2varname\^\fP\f3[\fP\f2word\^\fP\f3]\fP=\fP\f2word\^\fP
570 No space is permitted between \f2varname\^\fP and the \f3=\fP or
571 between \f3=\fP and \fIword\^\fP.
573 \f2varname\^\fP\f3=(\fP\f2assign_list\^\fP\f3)\fP
574 No space is permitted between \f2varname\^\fP and the \f3=\fP.
575 An \f2assign_list\^\fP can be one of the following:
580 Indexed array assignment.
582 \f3[\fP\f2word\^\fP\f3]=\fP\f2word\^\fP .\|.\|.
583 Associative array assignment.
585 \f2assignment\^\fP .\|.\|.
586 Nested variable assignment.
588 \f3typeset\fP \*(OK\f2options\fP\*(CK \f2assignment\^\fP .\|.\|.
589 Nested variable assignment. Multiple assignments
590 can be specified by separating each of them with a \f3;\fP.
595 A word beginning with
597 causes that word and all the following characters up to a new-line
600 The first word of each command is replaced by the text of an
604 for this word has been defined.
607 name consists of any number of characters excluding metacharacters,
609 file expansion characters,
610 parameter expansion and command substitution
614 The replacement string can contain any
616 including the metacharacters listed above.
617 The first word of each command in the
620 any that are in the process of being replaced,
621 will be tested for aliases.
622 If the last character of the alias value is a
624 then the word following the alias will also be checked for alias
626 Aliases can be used to redefine
627 built-in commands but cannot be used to redefine
628 the reserved words listed above.
629 Aliases can be created and listed with the
631 command and can be removed with the
638 not while they are executed.
640 for an alias to take effect
644 definition command has to be executed before
645 the command which references the alias is read.
649 are compiled into the shell
650 but can be unset or redefined:
654 .B "autoload=\(fmtypeset \-fu\(fm"
656 .B "command=\(fmcommand \(fm"
660 .B "float=\(fmtypeset \-E\(fm"
662 .B "functions=\(fmtypeset \-f\(fm"
664 .B "hash=\(fmalias \-t \-\-\(fm"
666 .B "history=\(fmhist \-l\(fm"
668 .B "integer=\(fmtypeset \-i\(fm"
670 .B "nameref=\(fmtypeset \-n\(fm"
672 .B "nohup=\(fmnohup \(fm"
674 .B "r=\(fmhist \-s\(fm"
676 .B "redirect=\(fmcommand exec\(fm"
678 .B "stop=\(fmkill \-s \s-1STOP\s+1\(fm"
680 .B "times=\(fm{ {time;} 2>&1;}\(fm"
682 .B "type=\(fmwhence \-v\(fm"
685 .SS Tilde Substitution.
686 After alias substitution is performed, each word
687 is checked to see if it begins with an unquoted
689 For tilde substitution,
693 portion of parameter expansion
695 .I "Parameter Expansion\^"
697 If it does, then the word up to a
699 is checked to see if it matches a user name in the
704 If a match is found, the
706 and the matched login name are replaced by the
707 login directory of the matched user.
708 If no match is found, the original text is left unchanged.
711 by itself, or in front of a
722 is replaced by the value of
732 .IR "variable assignment" ,
734 substitution is attempted when
735 the value of the assignment
748 On R&D UNIX Systems with RFS, an additional capability,
754 for a complete description of the capability.\}
755 .SS Command Substitution.
756 The standard output from a command enclosed in
757 parentheses preceded by a dollar sign (
760 or a pair of grave accents (\^\f3\*`\^\*`\fP\^)
761 may be used as part or all
763 trailing new-lines are removed.
764 In the second (obsolete) form, the string between the quotes is processed
765 for special quoting characters before the command is executed (see
768 The command substitution
769 \^\f3$(\^cat file\^)\fP\^
770 can be replaced by the equivalent but faster
771 \^\f3$(\^<file\^)\fP\^.
772 .SS Arithmetic Substitution.
773 An arithmetic expression enclosed in double
774 parentheses preceded by a dollar sign (
777 is replaced by the value of the arithmetic expression
778 within the double parentheses.
779 .SS Process Substitution.
780 This feature is only available on
781 versions of the UNIX operating system that support the
783 directory for naming open files.
784 Each command argument of the form
785 \f3<(\fP\f2list\^\fP\f3)\fP
787 \f3>(\fP\f2list\^\fP\f3)\fP
790 asynchronously connected to some file in
792 The name of this file will become the argument to the command.
795 is selected then writing on this file will provide input for
800 then the file passed as an argument will contain the output of the
806 \f3paste <(cut \-f1\fP \f2file1\fP\f3) <(cut \-f3\fP \f2file2\f3) | tee >(\fP\f2process1\fP\f3) >(\fP\f2process2\fP\f3)\fP
817 the results together, and
823 as well as putting it onto the standard output.
824 Note that the file, which is passed as an argument to the command,
827 so programs that expect to
829 on the file will not work.
830 .SS Parameter Expansion.
836 or any of the characters
847 is denoted by a \f2vname\fP.
848 To create a variable whose
850 contains a \f3\s+2.\s-2\fP,
853 consists of everything before the last \f3\s+2.\s-2\fP must already exist.
867 special built-in command.
868 The attributes supported by the shell are described
871 special built-in command.
872 Exported variables pass values and attributes to
875 The shell supports both indexed and associative arrays.
876 An element of an array variable is referenced by a
880 for an indexed array is denoted by
882 .I arithmetic expression\^
884 .I "Arithmetic evaluation"
890 To assign values to an indexed array, use
891 \f3set \-A\fP \f2vname\fP \f2value\fP .\|.\|. .
893 subscripts must be in the
896 Indexed arrays need not be declared.
897 Any reference to a variable
898 with a valid subscript is
899 legal and an array will be created if necessary.
901 An associative array is created with the
907 for an associative array is denoted by
908 a string enclosed between
913 Referencing any array without a subscript
914 is equivalent to referencing the array with subscript 0.
920 may be assigned by writing:
923 .IB vname = value\^\|
933 .IB vname [ subscript ]= value\^\|
935 .IB vname [ subscript ]= value\^
938 Note that no space is allowed before or after the
944 is a variable that is a reference to another variable.
945 A nameref is created with the
949 The value of the variable at the time of the
951 command becomes the variable that will be referenced whenever
952 the nameref variable is used.
953 The name of a nameref variable cannot contain a \fB\s+2.\s-2\fP.
954 When a variable or function name contains a \fB\s+2.\s-2\fP, and the portion
955 of the name up to the first \fB\s+2.\s-2\fP matches the
956 name of a nameref, the variable referred to is obtained by
957 replacing the nameref portion with the name of the variable
958 referenced by the nameref.
959 A nameref provides a convenient way to refer to the variable
960 inside a function whose name is passed as an argument to a function.
961 For example, if the name of a variable is passed as the first
962 argument to a function, the command
968 inside the function causes references and assignments to
970 to be references and assignments to the variable whose
971 name has been passed to the function.
973 If either of the floating point attributes,
977 or the integer attribute,
983 is subject to arithmetic evaluation as described below.
985 Positional parameters,
986 parameters denoted by a number,
987 may be assigned values with the
989 special built-in command.
992 is set from argument zero when the shell
997 is used to introduce substitutable
1000 \f3${\fP\f2parameter\^\fP\f3}\fP
1002 reads all the characters from
1006 as part of the same word even if it contains
1007 braces or metacharacters.
1008 The value, if any, of the parameter is substituted.
1009 The braces are required when
1011 is followed by a letter, digit, or underscore
1012 that is not to be interpreted as part of its name,
1013 when the variable name contains a \fB\s+2.\s-2\fP,
1014 or when a variable is subscripted.
1017 is one or more digits then it is a positional parameter.
1018 A positional parameter of more than one digit must be
1026 then all the positional
1027 parameters, starting with
1030 (separated by a field separator character).
1042 (separated by a field separator character).
1044 \f3${#\fP\f2parameter\^\fP\f3}\fP
1051 the number of positional parameters is substituted.
1052 Otherwise, the length of the value of the
1056 \f3${#\fP\f2vname\fP\f3[*]}\fP
1057 The number of elements in the array
1061 \f3${!\fP\f2vname\^\fP\f3}\fP
1062 Expands to the name of the variable referred to by
1068 is a name reference.
1070 \f3${!\fP\f2vname\^\fP\f3[\f2subscript\^\f3]}\fP
1071 Expands to name of the subscript unless
1081 the list of array subscripts for \f2vname\^\fP
1083 For a variable that is not an array, the value is 0 if the variable
1084 is set. Otherwise it is null.
1089 same as above, except that when used in double quotes,
1090 each array subscript yields a separate
1093 \f3${!\fP\f2prefix\^\fP\f3*}\fP
1094 Expands to the names of the variables whose names begin with
1097 \f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
1100 is set and is non-null then substitute its value;
1101 otherwise substitute
1104 \f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
1107 is not set or is null then set it to
1109 the value of the parameter is then substituted.
1110 Positional parameters may not be assigned to
1113 \f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
1116 is set and is non-null then substitute its value;
1119 and exit from the shell.
1122 is omitted then a standard message is printed.
1124 \f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
1127 is set and is non-null then substitute
1129 otherwise substitute nothing.
1132 \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3:\fP\f2length\^\fP\f3}\fP
1134 \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3}\fP
1135 Expands to the portion of the value of
1137 starting at the character determined by expanding
1139 as an arithmetic expression and consisting of the
1140 number of characters determined by the arithmetic expression
1143 In the second form, the remainder of the value is used.
1150 or is an array name indexed by
1158 refer to the array index and number
1159 of elements respectively.
1162 \f3${\fP\f2parameter\^\fP\f3#\fP\f2pattern\^\fP\f3}\fP
1164 \f3${\fP\f2parameter\^\fP\f3##\fP\f2pattern\^\fP\f3}\fP
1169 matches the beginning of the value of
1172 this expansion is the value of the
1174 with the matched portion deleted;
1175 otherwise the value of this
1178 In the first form the smallest matching pattern is deleted and in the
1179 second form the largest matching pattern is deleted.
1185 or an array variable with subscript
1189 the substring operation is applied to each element in turn.
1192 \f3${\fP\f2parameter\^\fP\f3%\fP\f2pattern\^\fP\f3}\fP
1194 \f3${\fP\f2parameter\^\fP\f3%%\fP\f2pattern\^\fP\f3}\fP
1199 matches the end of the value of
1202 this expansion is the value of the
1204 with the matched part deleted;
1205 otherwise substitute the value of
1207 In the first form the smallest matching pattern is deleted and in the
1208 second form the largest matching pattern is deleted.
1214 or an array variable with subscript
1218 the substring operation is applied to each element in turn.
1221 \f3${\fP\f2parameter\^\fP\f3/\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1223 \f3${\fP\f2parameter\^\fP\f3//\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1232 only the first occurrence of
1238 is replaced by the given
1244 will be deleted and the
1254 or an array variable with subscript
1258 the substitution operation is applied to each element in turn.
1262 is not evaluated unless it is
1263 to be used as the substituted string,
1264 so that, in the following example,
1268 is not set or is null:
1271 print \|${d:\-\^$(\^pwd\^)\^}
1276 is omitted from the above expressions,
1277 then the shell only checks whether
1283 are automatically set by the shell:
1288 The number of positional parameters in decimal.
1291 Options supplied to the shell on invocation or by
1297 The decimal value returned by the last executed command.
1300 The process number of this shell.
1303 Initially, the value of
1305 is an absolute pathname of the shell or script being executed
1308 Subsequently it is assigned the last argument of the previous command.
1309 This parameter is not set for commands which are asynchronous.
1310 This parameter is also used to hold the name of the matching
1313 file when checking for mail.
1316 The process number of the last background command invoked.
1319 This variable contains the value of the keyboard character
1320 (or sequence of characters if the first character is an ESC, ascii
1323 been entered when processing a
1327 If the value is changed as part of the trap action, then the new
1328 value replaces the key (or key sequence) that caused the trap.
1331 The character position of the cursor at the time of the most recent
1337 The value is set to ESC when processing a
1343 .I "Vi Editing Mode"\^
1347 is null when processing a
1353 The characters in the input buffer at the time of the most recent
1357 The value is null when not processing a
1363 Set to the name of the variable at the time of a
1367 discipline is invoked.
1370 Set to the name subscript of the variable at the time of a
1374 discipline is invoked.
1377 Set to the value of the variable at the time of a
1382 Set to a value that identifies the version of this shell.
1386 The line number of the current line within the script or
1387 function being executed.
1391 The previous working directory set by the
1397 The value of the last option argument processed by the
1403 The index of the last option argument processed by the
1409 The process number of the parent of the shell.
1413 The present working directory set by the
1419 Each time this variable is referenced, a random integer,
1420 uniformly distributed between 0 and 32767, is generated.
1421 The sequence of random numbers can be initialized by assigning
1428 This variable is set by the
1433 built-in command when no arguments are supplied.
1437 Each time this variable is referenced, the number of
1438 seconds since shell invocation is returned.
1440 assigned a value, then the value returned upon reference will
1441 be the value that was assigned plus the number of seconds since the assignment.
1447 are used by the shell:
1453 The search path for the
1459 If this variable is set,
1460 the value is used to define the width of the edit window
1461 for the shell edit modes and for printing
1467 If the value of this variable ends in
1475 variable is not set,
1476 then the corresponding option
1477 (see Special Command
1484 If this variable is set, then
1485 parameter expansion, command substitution, and arithmetic substitution,
1487 the value to generate
1488 the pathname of the script that will be
1489 executed when the shell
1494 This file is typically used for
1503 the default editor name for the
1515 A pattern that defines the set of filenames that will be
1516 ignored when performing filename matching.
1520 The search path for function definitions.
1521 This path is searched when a function with the
1523 attribute is referenced and when a command is not found.
1524 If an executable file is found, then it is read and executed
1525 in the current environment.
1529 Internal field separators,
1535 that are used to separate the results of
1536 command substitution or parameter expansion
1537 and to separate fields with the built-in command
1539 The first character of the
1542 variable is used to separate arguments for the
1548 Each single occurrence of
1552 character in the string to be split,
1564 characters separate a field.
1569 the default editor name for the
1575 If this variable is set when the shell is invoked, then
1576 the value is the pathname of the file that will be
1577 used to store the command history.
1579 .I "Command re-entry\^"
1584 If this variable is set when the shell is invoked, then
1585 the number of previously entered commands that
1586 are accessible by this shell
1587 will be greater than or equal to this number.
1592 The default argument (home directory) for the
1598 If this variable is set,
1599 the value is used to determine the column length for printing
1602 Select lists will print vertically until about two-thirds of
1609 If this variable is set to the name of a mail file
1614 variable is not set,
1615 then the shell informs the user of arrival of mail
1616 in the specified file.
1620 This variable specifies how often (in seconds) the
1621 shell will check for changes in the modification time
1622 of any of the files specified by the
1629 The default value is 600 seconds.
1630 When the time has elapsed
1631 the shell will check before issuing the next prompt.
1638 separated list of file names.
1639 If this variable is set
1640 then the shell informs the user of
1641 any modifications to the specified files
1642 that have occurred within the last
1646 Each file name can be followed by a
1648 and a message that will be printed.
1649 The message will undergo parameter expansion, command substitution,
1650 and arithmetic substitution
1653 defined as the name of the file that has changed.
1654 The default message is
1655 .I you have mail in $_\^.
1659 The search path for commands (see
1662 The user may not change
1672 The value of this variable is expanded for parameter
1673 expansion, command substitution, and arithmetic substitution to define the
1674 primary prompt string which by default is
1675 .RB `` "$\|\|\|" ''.
1678 in the primary prompt string is replaced by the
1681 .I "Command Re-entry"\^
1683 Two successive occurrences of
1685 will produce a single
1687 when the prompt string is printed.
1691 Secondary prompt string, by default
1696 Selection prompt string
1704 The value of this variable is expanded for parameter evaluation,
1705 command substitution, and arithmetic substitution
1706 and precedes each line of an execution trace.
1707 If omitted, the execution trace prompt is
1714 is kept in the environment.
1715 At invocation, if the basename of this variable is
1720 then the shell becomes restricted.
1724 If set to a value greater than zero,
1727 built-in command terminates after
1730 seconds when input is from a terminal.
1732 the shell will terminate if a line is not entered within
1733 the prescribed number of seconds while reading from a terminal.
1734 (Note that the shell can be compiled with a maximum bound
1735 for this value which cannot be exceeded.)
1739 If the value of this variable ends in
1744 then the corresponding option
1745 (see Special Command
1752 The shell gives default values to
1753 \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP,
1754 \f3\s-1PS3\s+1\fP, \f3\s-1PS4\s+1\fP, \f3\s-1MAILCHECK\s+1\fP, \f3\s-1HISTEDIT\s+1\fP,
1755 \f3\s-1TMOUT\s+1\fP and \f3\s-1IFS\s+1\fP,
1767 not set at all by the shell (although
1783 After parameter expansion and command substitution,
1784 the results of substitutions are scanned for the field separator
1785 characters (those found in
1789 and split into distinct fields where such characters are found.
1790 Explicit null fields (\^\f3"\^"\fP or \f3\*\(fm\^\*\(fm\fP\^) are retained.
1791 Implicit null fields
1792 (those resulting from
1794 that have no values or command substitutions with no output) are removed.
1795 .SS File Name Generation.
1796 Following splitting, each field is scanned for the characters
1804 option has been set.
1805 If one of these characters appears
1806 then the word is regarded as a
1808 Each file name component that contains any pattern character
1809 is replaced with a lexicographically sorted set of names
1810 that matches the pattern
1813 If no file name is found that matches the pattern, then
1814 that component of the filename is left unchanged.
1819 then each file name component
1820 that matches the pattern defined by the value of
1823 is ignored when generating the matching filenames.
1835 at the start of each file name component
1836 will be ignored unless the first character of the pattern
1837 corresponding to this component is the character
1840 Note, that for other
1841 uses of pattern matching the
1845 are not treated specially.
1851 Matches any string, including the null string.
1854 Matches any single character.
1856 .BR \*(OK \^.\|.\|.\^ \*(CK
1857 Matches any one of the enclosed characters.
1858 A pair of characters separated by
1861 character lexically between the pair, inclusive.
1862 If the first character following the opening
1866 then any character not enclosed is matched.
1869 can be included in the character set by putting it as the
1870 first or last character.
1876 character classes can be specified with the syntax
1877 \f3[:\fP\f2class\fP\f3:]\fP
1878 where class is one of the following:
1882 .if n alnum alpha cntrl digit graph lower print punct space upper xdigit
1883 .if t alnum alpha cntrl digit graph lower print punct space upper xdigit
1889 is a list of one or more patterns separated from each other
1892 Composite patterns can be formed with one or more of the following:
1896 \f3?(\fP\f2pattern-list\^\fP\f3)\fP
1897 Optionally matches any one of the given patterns.
1899 \f3*(\fP\f2pattern-list\^\fP\f3)\fP
1900 Matches zero or more occurrences of the given patterns.
1902 \f3+(\fP\f2pattern-list\^\fP\f3)\fP
1903 Matches one or more occurrences of the given patterns.
1905 \f3\&@\&(\fP\f2pattern-list\^\fP\f3)\fP
1906 Matches exactly one of the given patterns.
1909 \f3!(\fP\f2pattern-list\^\fP\f3)\fP
1910 Matches anything except one of the given patterns.
1919 has a special meaning to the shell
1920 and causes termination of a word unless quoted.
1923 (i.e., made to stand for itself)
1930 All characters enclosed between a pair of single quote marks
1931 (\^\f3\(fm\^\(fm\fP\^)
1932 that is not preceded by a
1935 A single quote cannot appear within the single quotes.
1936 A single quoted string preceded an unquoted
1938 is processed as an ANSI-C string
1941 within the string causes the remainder of the
1942 string to be ignored and
1944 is equivalent to the escape characer
1947 Inside double quote marks
1949 parameter and command substitution occur and
1951 quotes the characters
1961 is identical when not quoted or when used as a variable assignment value
1963 However, when used as a command argument,
1967 \f3"$1\fP\f2d\fP\f3\|$2\fP\f2d\fP\|.\|.\|.\f3"\fP,
1970 is the first character of the
1982 Inside grave quote marks
1985 quotes the characters
1990 If the grave quotes occur within double quotes then
1992 also quotes the character
1995 The special meaning of reserved words or aliases can be removed by quoting any
1996 character of the reserved word.
1997 The recognition of function names or built-in command names listed below
1998 cannot be altered by quoting them.
1999 .SS Arithmetic Evaluation.
2000 The shell performs arithmetic evaluation for
2001 arithmetic substitution, to evaluate an arithmetic command,
2002 to evaluate an indexed array subscript,
2003 and to evaluate arguments to
2004 the built-in commands
2008 Evaluations are performed using
2009 double precision floating point
2011 Floating point constants follow the ANSI-C programming language
2013 Integer constants are of the form
2014 \*(OK\f2base\f3#\^\f1\*(CK\f2n\^\fP
2017 is a decimal number between two and sixty-four
2018 representing the arithmetic base
2021 is a number in that base.
2022 The digits above 9 are represented
2023 by the lower case characters, the upper case characters,
2028 For bases less than 36, upper and lower case
2029 character can be used interchangeably.
2033 then base 10 is used.
2035 An arithmetic expression uses the same syntax, precedence, and
2037 expression as the C language.
2038 All the C language operators
2039 that apply to floating point quantities can be used.
2040 In addition, when the value of an arithmetic variable
2041 or sub-expression can be represented as a long integer,
2042 all C language integer arithmetic operations can be performed.
2043 Variables can be referenced by name within an arithmetic expression
2044 without using the parameter expansion syntax.
2045 When a variable is referenced, its value is evaluated as
2046 an arithmetic expression.
2047 The following math library functions can be used with an arithmetic
2052 .if n abs acos asin atan cos cosh exp int log sin sinh sqrt tan tanh
2053 .if t abs acos asin atan cos cosh exp int log sin sinh sqrt tan tanh
2056 An internal representation of a
2058 as a double precision floating point can be specified with the
2059 \f3\-E\fP \*(OK\f2n\^\fP\*(CK
2061 \f3\-F\fP \*(OK\f2n\^\fP\*(CK
2064 special built-in command.
2067 option causes the expansion of the value to be represented using
2068 scientific notation when it is expanded.
2069 The optional option argument
2071 defines the number of significant figures.
2074 option causes the expansion to be represented as a floating decimal number
2075 when it is expanded.
2076 The optional option argument
2078 defines the number of places after the decimal point in this case.
2080 An internal integer representation of a
2082 can be specified with the
2083 \f3\-i\fP \*(OK\f2n\^\fP\*(CK
2086 special built-in command.
2087 The optional option argument
2089 specifies an arithmetic base to be used when expanding the variable.
2090 If you do not specify an arithmetic base,
2091 the first assignment to the
2092 variable determines the arithmetic base.
2094 Arithmetic evaluation is performed on the value of each
2095 assignment to a variable with the
2101 Assigning a floating point number to a
2102 variable whose type is an integer causes the fractional
2103 part to be truncated.
2106 When used interactively,
2107 the shell prompts with the value of
2110 after expanding it for parameter expansion, command substitution, and
2111 arithmetic substitution,
2112 before reading a command.
2113 In addition, each single
2115 in the prompt is replaced by the command number.
2118 is required to place
2121 If at any time a new-line is typed and further input is needed
2122 to complete a command, then the secondary prompt
2126 .SS Conditional Expressions.
2128 .I "conditional expression"
2131 compound command to test attributes of files and to compare
2133 Field splitting and file name generation are
2134 not performed on the words between
2138 Each expression can be constructed from one or more
2139 of the following unary or binary expressions:
2147 \f3\-a\fP \f2file\fP
2148 Same is \f3\-e\fP below.
2151 \f3\-b\fP \f2file\fP
2154 exists and is a block special file.
2156 \f3\-c\fP \f2file\fP
2159 exists and is a character special file.
2161 \f3\-d\fP \f2file\fP
2164 exists and is a directory.
2166 \f3\-e\fP \f2file\fP
2171 \f3\-f\fP \f2file\fP
2174 exists and is an ordinary file.
2176 \f3\-g\fP \f2file\fP
2179 exists and is has its setgid bit set.
2181 \f3\-k\fP \f2file\fP
2184 exists and is has its sticky bit set.
2186 \f3\-n\fP \f2string\fP
2191 \f3\-o\fP \f2option\fP
2192 True, if option named
2196 \f3\-p\fP \f2file\fP
2199 exists and is a fifo special file or a pipe.
2201 \f3\-r\fP \f2file\fP
2204 exists and is readable by current process.
2206 \f3\-s\fP \f2file\fP
2209 exists and has size greater than zero.
2211 \f3\-t\fP \f2fildes\fP
2212 True, if file descriptor number
2214 is open and associated with a terminal device.
2216 \f3\-u\fP \f2file\fP
2219 exists and is has its setuid bit set.
2221 \f3\-w\fP \f2file\fP
2224 exists and is writable by current process.
2226 \f3\-x\fP \f2file\fP
2229 exists and is executable by current process.
2232 exists and is a directory, then true if the current process
2233 has permission to search in the directory.
2235 \f3\-z\fP \f2string\fP
2240 \f3\-L\fP \f2file\fP
2243 exists and is a symbolic link.
2245 \f3\-O\fP \f2file\fP
2248 exists and is owned by the effective user id of this process.
2250 \f3\-G\fP \f2file\fP
2253 exists and its group matches the effective group id of this process.
2255 \f3\-S\fP \f2file\fP
2258 exists and is a socket.
2260 \f2file1\fP \f3\-nt\fP \f2file2\fP
2263 exists and is newer than
2266 \f2file1\fP \f3\-ot\fP \f2file2\fP
2269 exists and is older than
2272 \f2file1\fP \f3\-ef\fP \f2file2\fP
2277 exist and refer to the same file.
2279 \f2string\fP \f3==\fP \f2pattern\fP
2286 can be quoted to cause it to be matched as a string.
2288 \f2string\fP \f3=\fP \f2pattern\fP
2289 Same as \f3==\fP above, but is obsolete.
2291 \f2string\fP \f3!=\fP \f2pattern\fP
2297 \f2string1\fP \f3<\fP \f2string2\fP
2302 based on ASCII value of their characters.
2304 \f2string1\fP \f3>\fP \f2string2\fP
2309 based on ASCII value of their characters.
2311 The following obsolete arithmetic comparisons are also permitted:
2314 \f2exp1\fP \f3\-eq\fP \f2exp2\fP
2320 \f2exp1\fP \f3\-ne\fP \f2exp2\fP
2326 \f2exp1\fP \f3\-lt\fP \f2exp2\fP
2332 \f2exp1\fP \f3\-gt\fP \f2exp2\fP
2338 \f2exp1\fP \f3\-le\fP \f2exp2\fP
2341 is less than or equal to
2344 \f2exp1\fP \f3\-ge\fP \f2exp2\fP
2347 is greater than or equal to
2351 In each of the above expressions, if
2354 \f3/dev/fd/\fP\f2n\fP,
2358 then the test is applied to the open file whose
2359 descriptor number is
2362 A compound expression can be constructed from these primitives by
2363 using any of the following, listed in decreasing order of precedence.
2366 \f3(\fP\f2expression\fP\f3)\fP
2370 Used to group expressions.
2372 \f3!\fP \f2expression\fP
2377 \f2expression1\fP \f3&&\fP \f2expression2\fP
2384 \f2expression1\fP \f3\(bv\(bv\fP \f2expression2\fP
2392 Before a command is executed, its input and output
2393 may be redirected using a special notation interpreted by the shell.
2394 The following may appear anywhere in a simple-command
2395 or may precede or follow a
2399 passed on to the invoked command.
2400 Command substitution, parameter expansion,
2401 and arithmetic substitution occur before
2405 is used except as noted below.
2406 File name generation
2407 occurs only if the shell is interactive and
2408 the pattern matches a single file,
2409 Field splitting is not performed.
2414 as standard input (file descriptor 0).
2419 as standard output (file descriptor 1).
2420 If the file does not exist then it is created.
2421 If the file exists, and the
2424 this causes an error;
2425 otherwise, it is truncated to zero length.
2430 except that it overrides the
2438 If the file exists then output is appended to it (by first seeking to the end-of-file);
2439 otherwise, the file is created.
2444 for reading and writing
2447 \f3<<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
2448 The shell input is read up to a line that is the same as
2450 after any quoting has been removed remove,
2451 or to an end-of-file.
2452 No parameter substitution, command substitution, arithmetic substitution or
2453 file name generation is performed on
2455 The resulting document,
2462 is quoted, then no interpretation
2463 is placed upon the characters of the document;
2464 otherwise, parameter expansion, command substitution, and arithmetic
2470 must be used to quote the characters
2478 then all leading tabs are stripped from
2480 and from the document.
2483 The standard input is duplicated from file descriptor
2487 Similarly for the standard output using
2491 The standard input is closed.
2492 Similarly for the standard output using
2496 The input from the co-process is moved to standard input.
2499 The output to the co-process is moved to standard output.
2501 If one of the above is preceded by a digit,
2503 file descriptor number referred to is that specified
2505 (instead of the default 0 or 1).
2512 means file descriptor 2 is to be opened
2513 for writing as a duplicate
2514 of file descriptor 1.
2516 The order in which redirections are specified is significant.
2517 The shell evaluates each redirection in terms of the
2518 .RI ( "file descriptor" ", " file )
2519 association at the time of evaluation.
2523 \&.\|.\|. \|1>\f2fname\^\fP 2>&1
2526 first associates file descriptor 1 with file
2528 It then associates file descriptor 2 with the file associated with file
2531 If the order of redirections were reversed, file descriptor 2 would be associated
2532 with the terminal (assuming file descriptor 1 had been) and then file descriptor
2533 1 would be associated with file
2536 If a command is followed by
2538 and job control is not active,
2539 then the default standard input
2543 Otherwise, the environment for the execution of a command contains the
2544 file descriptors of the invoking shell as modified by
2545 input/output specifications.
2551 is a list of name-value pairs that is passed to
2552 an executed program in the same way as a normal argument list.
2555 and the values are character strings.
2556 The shell interacts with the environment in several ways.
2557 On invocation, the shell scans the environment
2560 for each name found,
2561 giving it the corresponding value and attributes and marking it
2563 Executed commands inherit the environment.
2564 If the user modifies the values of these
2566 or creates new ones,
2571 commands they become part of the
2573 The environment seen by any executed command is thus composed
2574 of any name-value pairs originally inherited by the shell,
2575 whose values may be modified by the current shell,
2577 which must be noted in
2583 The environment for any
2586 may be augmented by prefixing it with one or more variable assignments.
2587 A variable assignment argument is a word of the form
2588 .IR identifier=value .
2592 \s-1TERM\s+1=450 \|cmd \|args and
2594 (export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)
2597 are equivalent (as far as the above execution of
2599 is concerned except for special built-in commands listed below \-
2601 preceded with a dagger).
2607 variable assignment arguments are placed in the environment,
2608 even if they occur after the command name.
2622 This feature is intended for use with scripts written
2623 for early versions of the shell and its use in new scripts
2624 is strongly discouraged.
2625 It is likely to disappear someday.
2628 For historical reasons, there are two
2629 ways to define functions,
2636 syntax, described in the
2639 Shell functions are read in and stored internally.
2640 Alias names are resolved when the function is read.
2641 Functions are executed like commands with the arguments
2642 passed as positional parameters.
2647 Functions defined by the
2650 syntax and called by name execute in the same process as the caller and
2652 and present working directory with the
2654 Traps caught by the caller are reset to their default action
2655 inside the function.
2656 A trap condition that is not caught or ignored by the
2657 function causes the function to terminate and the condition
2658 to be passed on to the caller.
2662 set inside a function
2663 is executed after the function completes in the environment
2666 variables are shared between the calling program
2671 special built-in command used within a function
2672 defines local variables whose scope includes
2673 the current function and
2674 all functions it calls.
2675 Errors within functions return control to the caller.
2677 Functions defined with the
2679 syntax and functions defined with the
2682 syntax that are invoked with the \f3\s+2.\s-2\fP
2684 are executed in the caller's
2685 environment and share all variables
2686 and traps with the caller.
2687 Errors within these function executions cause the script that contains
2690 The special built-in command
2693 from function calls.
2696 can be listed with the
2702 special built-in command.
2703 The text of functions, when available, will also
2706 Functions can be undefined with the
2710 special built-in command.
2712 Ordinarily, functions are unset when the shell executes a shell script.
2713 Functions that need to be defined across separate
2714 invocations of the shell should
2715 be placed in a directory and the
2719 variable should contains the name of this directory.
2732 command is turned on,
2733 an interactive shell associates a \fIjob\fR with each pipeline.
2735 a table of current jobs, printed by the
2737 command, and assigns them small integer numbers.
2738 When a job is started asynchronously with
2740 the shell prints a line which looks
2746 indicating that the job which was started asynchronously was job number
2747 1 and had one (top-level) process, whose process id was 1234.
2749 This paragraph and the next require features that are
2750 not in all versions of UNIX and may not apply.
2751 If you are running a job and wish to do something else you may hit the key
2752 \fB^Z\fR (control-Z) which sends a STOP signal to the current job.
2753 The shell will then normally indicate that the job has been `Stopped',
2754 and print another prompt.
2755 You can then manipulate the state of this job,
2756 putting it in the background with the
2758 command, or run some other
2759 commands and then eventually bring the job back into the foreground with
2760 the foreground command
2762 A \fB^Z\fR takes effect immediately and
2763 is like an interrupt in that pending output and unread input are discarded
2766 A job being run in the background will stop if it tries to read
2768 Background jobs are normally allowed to produce output,
2769 but this can be disabled by giving the command ``stty tostop''.
2771 tty option, then background jobs will stop when they try to produce
2772 output like they do when they try to read input.
2774 There are several ways to refer to jobs in the shell.
2775 A job can be referred to by the process id of any process of the job
2776 or by one of the following:
2780 The job with the given number.
2783 Any job whose command line begins with
2787 Any job whose command line contains
2801 The shell learns immediately whenever a process changes state.
2802 It normally informs you whenever a job becomes blocked so that
2803 no further progress is possible, but only just before it prints
2805 This is done so that it does not otherwise disturb your work.
2809 the shell to print these job change messages
2810 as soon as they occur.
2814 option is on, each background job that completes
2815 triggers any trap set for
2818 When you try to leave the shell while jobs are running or stopped, you will
2819 be warned that `You have stopped(running) jobs.'
2822 command to see what they are.
2823 If you immediately try to
2824 exit again, the shell will not warn you a second time, and the stopped
2825 jobs will be terminated.
2826 When a login shell receives a HUP signal, it sends
2827 a HUP signal to each job that has not been disowned witha the
2829 built-in command described below.
2831 The \s-1INT\s+1 and \s-1QUIT\s+1 signals for an invoked
2832 command are ignored if the command is followed by
2836 option is not active.
2837 Otherwise, signals have the values
2838 inherited by the shell from its parent
2842 built-in command below).
2844 Each time a command is read, the above substitutions
2846 If the command name matches one
2848 .I "Special built-in Commands\^"
2850 it is executed within the
2851 current shell process.
2852 Next, the command name is checked to see if
2853 it matches a user defined function.
2855 the positional parameters are saved
2856 and then reset to the arguments of the
2861 completes or issues a
2863 the positional parameter list is restored.
2864 For functions defined with the
2871 within the function is executed.
2874 is the value of the last command executed.
2875 A function is also executed in the
2876 current shell process.
2877 If a command name is not a
2878 .I "special built-in command\^"
2881 but it is one of the built-in commands listed below
2882 it is executed in the current shell process.
2887 defines the search path for
2888 the directory containing the command.
2889 Alternative directory names are separated by
2897 and the current directory
2899 The current directory can be specified by
2900 two or more adjacent colons, or by a colon
2901 at the beginning or end of the path list.
2902 If the command name contains a \f3/\fP then the search path
2904 Otherwise, each directory in the path is
2905 searched for an executable file that is not a directory.
2907 determines that there is a built-in version
2908 of a command corresponding to a given pathname,
2909 this built-in is invoked in the current process.
2910 A process is created and
2911 an attempt is made to execute the command via
2913 If the file has execute permission but is not an
2916 it is assumed to be a file containing shell commands.
2917 A separate shell is spawned to read it.
2918 All non-exported variables are removed in this case.
2919 If the shell command
2920 file doesn't have read permission,
2925 bits are set on the file,
2926 then the shell executes an agent whose job it is to
2927 set up the permissions and execute the shell with the
2928 shell command file passed down as an open file.
2929 A parenthesized command is executed in
2930 a sub-shell without removing non-exported variables.
2931 .SS Command Re-entry.
2932 The text of the last
2937 commands entered from a terminal device
2942 .B \s-1$HOME\s+1/.sh_history
2948 or if the file it names is not writable.
2949 A shell can access the commands of
2952 shells which use the same named
2955 The built-in command
2958 edit a portion of this file.
2959 The portion of the file to be edited or listed can be selected by
2960 number or by giving the first character or
2961 characters of the command.
2962 A single command or range of commands can be specified.
2963 If you do not specify an editor program as
2966 then the value of the variable
2973 is unset, the obsolete variable
2983 The edited command(s) is printed and re-executed upon
2984 leaving the editor unless you quit without writing.
2989 an in obsolete versions, the editor name
2992 is used to skip the editing phase and
2993 to re-execute the command.
2994 In this case a substitution parameter of the form
2995 \f2old\fP\f3=\fP\f2new\fP
2996 can be used to modify the command before execution.
2997 For example, with the preset alias
3000 .BR "\(fmhist \-s\(fm" ,
3002 `\f3r bad=good c\fP'
3003 will re-execute the most recent command which starts with the letter
3005 replacing the first occurrence of the string
3009 .SS In-line Editing Options
3010 Normally, each command line entered from a terminal device is simply
3011 typed followed by a \f3new-line\fP (`RETURN' or `LINE\ FEED').
3017 option is active, the user can edit the command line.
3018 To be in either of these edit modes
3022 An editing option is automatically selected each time the
3028 variable is assigned a value ending in either of these
3031 The editing features require that the user's terminal
3032 accept `RETURN' as carriage return without line feed
3033 and that a space (`\ ') must overwrite the current character on
3036 The editing modes implement a concept where the user is looking through a
3037 window at the current line.
3038 The window width is the value of
3041 if it is defined, otherwise 80.
3042 If the window width is too small to display the prompt and leave
3043 at least 8 columns to enter input, the prompt is truncated from the
3045 If the line is longer than the window width minus two, a mark is
3046 displayed at the end of the window to notify the user.
3047 As the cursor moves and reaches the window boundaries the window will be
3048 centered about the cursor.
3052 if the line extends on the
3053 right (left, both) side(s) of the window.
3055 The search commands in each edit mode provide access to the history file.
3056 Only strings are matched, not patterns, although a leading
3058 in the string restricts the match
3059 to begin at the first character in the line.
3061 Each of the edit modes has an operation to list the files
3062 or commands that match a partially entered word.
3063 When applied to the first word on the line,
3064 or the first word after a
3070 and the word does not begin with
3074 the list of aliases, functions, and executable commands
3078 variable that could match the partial word is displayed.
3079 Otherwise, the list of files that match the given
3081 If the partially entered word does not contain any
3082 file expansion characters, a
3084 is appended before generating these lists.
3085 After displaying the generated list, the input line
3087 These operations are called command name listing and file name listing,
3089 There are additional operations, referred to as command name
3090 completion and file name completion, which compute the list
3091 of matching commands or files, but instead of printing the list,
3093 the current word with a complete or partial match.
3094 For file name completion,
3095 if the match is unique, a
3097 is appended if the file is a directory and a space is
3098 appended if the file is not a directory.
3099 Otherwise, the longest common prefix for all the matching
3100 files replaces the word.
3101 For command name completion, only the portion of the file names
3104 are used to find the longest command prefix.
3105 If only a single name matches this prefix, then the
3106 word is replaced with the command name followed by a space.
3111 trap can be used to intercept keys as they are typed
3112 and change the characters that are actually seen by
3114 This trap is executed after each character
3115 ( or sequence of characters when the first character is
3117 ) is entered while reading from a terminal.
3120 contains the character or character sequence which
3122 Changing the value of
3124 in the trap action causes the shell to behave as if the
3125 new value were entered from the keyboard rather than
3130 is set to the input column number of the cursor at the time
3136 when in vi insert mode (see below) and is null otherwise.
3139 to a value assigned to
3141 it will cause the shell
3142 to change to control mode if it is not already in this mode.
3144 This trap is not invoked for characters entered as arguments to
3145 editing directives, or while reading input for a character search.
3146 .SS Emacs Editing Mode.
3147 This mode is entered by enabling either the
3152 The only difference between these two modes is the way
3156 moves the cursor to the point needing correction and
3157 then inserts or deletes characters or words as needed.
3158 All the editing commands are control characters or escape
3160 The notation for control characters is caret (
3166 is the notation for control
3168 This is entered by depressing `f' while holding down the
3169 `CTRL' (control) key.
3175 indicates the DEL (delete) key.)
3177 The notation for escape sequences is
3184 is entered by depressing ESC
3189 would be the notation for ESC followed by `SHIFT' (capital) `F'.)
3192 operate from any place on the line
3193 (not just at the beginning).
3194 Neither the "RETURN" nor the "LINE FEED" key is
3195 entered after edit commands except when noted.
3200 Move cursor forward (right) one character.
3204 Move cursor forward one word.
3207 editor's idea of a word is a string of characters
3208 consisting of only letters, digits and underscores.)
3212 Move cursor backward (left) one character.
3216 Move cursor backward one word.
3220 Move cursor to start of line.
3224 Move cursor to end of line.
3228 Move cursor forward to character
3234 Move cursor backward to character
3240 Interchange the cursor and mark.
3244 (User defined erase character as defined
3251 Delete previous character.
3255 Delete current character.
3259 Delete current word.
3263 (Meta-backspace) Delete previous word.
3267 Delete previous word.
3271 (Meta-DEL) Delete previous word (if your interrupt character is
3273 (DEL, the default) then this command will not work).
3277 Transpose current character with next character in
3280 Transpose two previous characters in
3286 Capitalize current character.
3290 Capitalize current word.
3294 Change the current word to lower case.
3298 Delete from the cursor to the end of the line.
3299 If preceded by a numerical parameter whose value is less than the
3300 current cursor position, then delete from given position
3302 If preceded by a numerical parameter whose value is greater than the
3303 current cursor position, then delete from cursor up to
3304 given cursor position.
3308 Kill from the cursor to the mark.
3312 Push the region from the cursor to the mark on the stack.
3316 (User defined kill character as defined
3317 by the stty command, usually
3321 Kill the entire current line.
3324 characters are entered in succession, all
3325 kill characters from then on cause a line feed
3326 (useful when using paper terminals).
3330 Restore last item removed from line. (Yank item back to the line.)
3334 Line feed and print current line.
3338 (Null character) Set mark.
3342 (Meta space) Set mark.
3346 (New\ line) Execute the current line.
3350 (Return) Execute the current line.
3354 End-of-file character,
3357 is processed as an End-of-file only
3358 if the current line is null.
3362 Fetch previous command.
3366 the previous command back in time is accessed.
3367 Moves back one line when not on the first line of a multi-line command.
3371 Fetch the least recent (oldest) history line.
3375 Fetch the most recent (youngest) history line.
3379 Fetch next command line.
3383 the next command line forward in time is accessed.
3387 Reverse search history for a previous command line containing
3389 If a parameter of zero is given, the search is forward.
3391 is terminated by a "RETURN" or "NEW\ LINE".
3392 If string is preceded by a
3394 the matched line must begin with
3399 then the next command line containing the most recent
3402 In this case a parameter of zero
3403 reverses the direction of the search.
3407 Operate \- Execute the current line and fetch
3408 the next line relative to current line from the
3413 (Escape) Define numeric parameter, the digits
3414 are taken as a parameter to the next command.
3415 The commands that accept a parameter are
3440 Soft-key \- Your alias list is searched for an
3443 and if an alias of this name is defined, its
3444 value will be inserted on the input queue.
3447 must not be one of the above meta-functions.
3451 Soft-key \- Your alias list is searched for an
3454 and if an alias of this name is defined, its
3455 value will be inserted on the input queue.
3456 The can be used to program functions keys on many terminals.
3460 The last word of the previous command is inserted
3462 If preceded by a numeric parameter, the value
3463 of this parameter determines which word to insert rather than
3473 Attempt file name generation on the current word.
3474 An asterisk is appended if the word doesn't match any file
3475 or contain any special
3479 Command or file name completion as described above.
3483 Command or file name listing as described above.
3487 Multiply parameter of next command by 4.
3491 Escape next character.
3492 Editing characters, the user's erase, kill and
3497 in a command line or in a search string if preceded by a
3501 removes the next character's
3502 editing features (if any).
3506 Display version of the shell.
3510 If the line does not begin with a
3515 at the beginning of the line
3516 and after each new-line,
3517 and the line is entered.
3518 This causes a comment to be inserted in the history file.
3519 If the line begins with a
3525 after each new-line is also deleted.
3527 .SS Vi Editing Mode.
3528 There are two typing modes.
3529 Initially, when you enter a command you are in the
3532 To edit, the user enters
3536 and moves the cursor to the point needing correction and
3537 then inserts or deletes characters or words as needed.
3538 Most control commands accept an optional repeat
3540 prior to the command.
3544 mode on most systems,
3545 canonical processing is initially enabled and the
3546 command will be echoed again if the speed is 1200 baud or greater and it
3547 contains any control characters or less than one second has elapsed
3548 since the prompt was printed.
3549 The ESC character terminates canonical processing for the remainder of the command
3550 and the user can then modify the command line.
3551 This scheme has the advantages of canonical processing with the type-ahead
3552 echoing of raw mode.
3556 is also set, the terminal will always have canonical processing
3558 This mode is implicit for systems that do not support two
3559 alternate end of line delimiters,
3560 and may be helpful for certain terminals.
3561 .SS "\ \ \ \ \ Input Edit Commands"
3564 By default the editor is in input mode.
3568 (User defined erase character as defined
3569 by the stty command, usually
3573 Delete previous character.
3576 Delete the previous blank separated word.
3577 One some systems the \f3viraw\fP option
3578 may be required for this to work.
3581 As the first character of the line causes
3582 the shell to terminate unless the \f3ignoreeof\fP
3584 Otherwise this character is ignored.
3587 Escape next character.
3588 Editing characters and the user's erase or kill
3589 characters may be entered
3590 in a command line or in a search string if preceded by a
3594 removes the next character's
3595 editing features (if any).
3596 One some systems the \f3viraw\fP option
3597 may be required for this to work.
3607 .SS "\ \ \ \ \ Motion Edit Commands"
3609 These commands will move the cursor.
3611 [\f2count\fP]\f3l\fP
3612 Cursor forward (right) one character.
3614 [\f2count\fP]\f3w\fP
3615 Cursor forward one alpha-numeric word.
3617 [\f2count\fP]\f3W\fP
3618 Cursor to the beginning of the next word that follows a blank.
3620 [\f2count\fP]\f3e\fP
3621 Cursor to end of word.
3623 [\f2count\fP]\f3E\fP
3624 Cursor to end of the current blank delimited word.
3626 [\f2count\fP]\f3h\fP
3627 Cursor backward (left) one character.
3629 [\f2count\fP]\f3b\fP
3630 Cursor backward one word.
3632 [\f2count\fP]\f3B\fP
3633 Cursor to preceding blank separated word.
3635 [\f2count\fP]\f3\(bv\fP
3639 [\f2count\fP]\f3f\fP\f2c\fP
3640 Find the next character \fIc\fP in the current line.
3642 [\f2count\fP]\f3F\fP\f2c\fP
3643 Find the previous character \fIc\fP in the current line.
3645 [\f2count\fP]\f3t\fP\f2c\fP
3651 [\f2count\fP]\f3T\fP\f2c\fP
3657 [\f2count\fP]\f3;\fP
3661 the last single character find command,
3668 [\f2count\fP]\f3,\fP
3669 Reverses the last single character find command
3674 Cursor to start of line.
3677 Cursor to first non-blank character in line.
3680 Cursor to end of line.
3691 If cursor is not on one of the above characters,
3692 the remainder of the line is searched for the first
3693 occurrence of one of the above characters first.
3695 .SS "\ \ \ \ \ Search Edit Commands"
3697 These commands access your command history.
3699 [\f2count\fP]\f3k\fP
3700 Fetch previous command.
3704 the previous command back in time is accessed.
3706 [\f2count\fP]\f3\-\fP
3710 [\f2count\fP]\f3j\fP
3715 the next command forward in time is accessed.
3717 [\f2count\fP]\f3+\fP
3721 [\f2count\fP]\f3G\fP
3725 The default is the least recent history command.
3728 Search backward through history for a previous command containing
3731 is terminated by a "RETURN" or "NEW\ LINE".
3732 If string is preceded by a
3734 the matched line must begin with
3736 If \fIstring\fP is null the previous string will be used.
3741 except that search will be in the forward direction.
3744 Search for next match of the last pattern to
3751 Search for next match of the last pattern to
3755 but in reverse direction.
3757 .SS "\ \ \ \ \ Text Modification Edit Commands"
3759 These commands will modify the line.
3762 Enter input mode and enter text after the current character.
3765 Append text to the end of the line.
3769 [\f2count\fP]\f3c\fP\f2motion\fP
3771 \f3c\fP[\f2count\fP]\f2motion\fP
3772 Delete current character through the character that
3774 would move the cursor to and enter input mode.
3777 the entire line will be deleted and
3781 Delete the current character through the end of line and enter input mode.
3790 Delete the current character through the end of line.
3794 [\f2count\fP]\f3d\fP\f2motion\fP
3796 \f3d\fP[\f2count\fP]\f2motion\fP
3797 Delete current character through the character that
3802 the entire line will be deleted.
3805 Enter input mode and insert text before the current character.
3808 Insert text before the beginning of the line.
3812 [\f2count\fP]\f3P\fP
3813 Place the previous text modification before the cursor.
3815 [\f2count\fP]\f3p\fP
3816 Place the previous text modification after the cursor.
3819 Enter input mode and
3820 replace characters on the screen with characters you type overlay fashion.
3822 [\f2count\fP]\f3r\fP\f2c\fP
3825 character(s) starting at the current cursor position with
3827 and advance the cursor.
3829 [\f2count\fP]\f3x\fP
3830 Delete current character.
3832 [\f2count\fP]\f3X\fP
3833 Delete preceding character.
3835 [\f2count\fP]\f3.\fP
3836 Repeat the previous text modification command.
3838 [\f2count\fP]\f3\(ap\fP
3839 Invert the case of the
3841 character(s) starting at the current cursor position and advance the cursor.
3843 [\f2count\fP]\f3_\fP
3846 word of the previous command to be appended and
3848 The last word is used
3856 to be appended to the current word and file name generation attempted.
3857 If no match is found,
3859 Otherwise, the word is replaced
3860 by the matching pattern and input mode is entered.
3863 Command or file name completion as described above.
3865 .SS "\ \ \ \ \ Other Edit Commands"
3867 Miscellaneous commands.
3869 [\f2count\fP]\f3y\fP\f2motion\fP
3871 \f3y\fP[\f2count\fP]\f2motion\fP
3872 Yank current character through character that
3874 would move the cursor to and puts them into the delete buffer.
3875 The text and cursor are unchanged.
3878 Yanks from current position to end of line.
3883 Undo the last text modifying command.
3886 Undo all the text modifying commands performed on the line.
3888 [\f2count\fP]\f3v\fP
3890 .BI "hist \-e ${\s-1VISUAL\s+1:\-${\s-1EDITOR\s+1:\-vi}}" " count"
3891 in the input buffer.
3894 is omitted, then the current line is used.
3897 Line feed and print current line.
3898 Has effect only in control mode.
3901 (New\ line) Execute the current line, regardless of mode.
3904 (Return) Execute the current line, regardless of mode.
3907 If the first character of the command is a
3909 then this command deletes this
3913 that follows a newline.
3915 sends the line after
3918 in front of each line in the command.
3919 Useful for causing the current line to be
3920 inserted in the history as a comment and
3921 uncommenting previously commented commands
3922 in the history file.
3925 Command or file name listing as described above.
3928 Your alias list is searched for an
3931 and if an alias of this name is defined, its
3932 value will be inserted on the input queue for processing.
3935 .SS Built-in Commands.
3936 The following simple-commands are executed in the shell process.
3937 Input/Output redirection is permitted.
3938 Unless otherwise indicated, the output is written on file descriptor 1
3939 and the exit status, when there is no syntax error, is zero.
3949 all built-in commands accept
3951 to indicate end of options.
3952 They also interpret the option
3954 as a help request and print a
3958 Commands that are preceded by one or two \(dg
3959 are special built-in commands and
3960 are treated specially in the following ways:
3964 Variable assignment lists preceding the command
3965 remain in effect when the command completes.
3968 I/O redirections are processed after variable assignments.
3973 that contains them to abort.
3976 They are not valid function names.
3980 following a command preceded by \(dg\(dg
3981 that are in the format of a variable assignment,
3982 are expanded with the same rules as a variable assignment.
3984 tilde substitution is performed after the
3986 sign and field splitting and file name generation are not
3990 \(dg \f3:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
3991 The command only expands parameters.
3995 \(dg \f3\|. \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
3998 is a function defined with the
4001 reserved word syntax,
4002 the function is executed in the current environment
4003 ( as if it had been defined with the
4008 refers to a file, the
4009 file is read in its entirety and the commands are
4010 executed in the current shell environment.
4015 is used to find the directory containing file.
4019 they become the positional parameters while processing
4022 command and are restored upon completion.
4023 Otherwise the positional parameters are unchanged.
4024 The exit status is the exit status of the last command executed.
4026 \(dg\(dg \f3alias\fP \*(OK \f3\-ptx\fP \*(CK \*(OK \f2name\fP\*(OK \f3=\fP\f2value\^\fP \*(CK \*(CK .\|.\|.
4028 with no arguments prints the list of aliases
4037 to be inserted before each one.
4038 When one or more arguments are given
4049 causes the next word to be checked for
4053 option is used to set and list tracked aliases.
4054 The value of a tracked alias is the full pathname
4055 corresponding to the given
4057 The value becomes undefined when the value of
4060 is reset but the alias remains tracked.
4066 in the argument list
4070 and value of the alias is printed.
4073 option has no effect.
4074 The exit status is non-zero if a
4076 is given, but no value, and no alias has been defined for the
4079 \f3bg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
4080 This command is only on systems that support job control.
4083 into the background.
4084 The current job is put in the background
4090 for a description of the format of
4093 \(dg \f3break\fP \*(OK \f2n\^\fP \*(CK
4094 Exit from the enclosing
4103 is specified then break
4107 \f3builtin\fP \*(OK \f3\-ds\fP \*(CK \*(OK \f3\-f\fP \f2file\^\fP \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
4110 is not specified, the built-ins are printed on standard output.
4113 option prints only the special built-ins.
4116 represents the pathname whose basename is the name of the built-in.
4117 The entry point function name is determined by prepending
4119 to the built-in name.
4120 Special built-ins cannot be bound to a pathname or deleted.
4123 option deletes each of the given built-ins.
4124 On systems that support dynamic loading, the
4126 option names a shared library containing the code for built-ins.
4127 Once a library is loaded, its symbols become available
4128 for subsequent invocations of
4130 Multiple libraries can be specified with separate invocations
4134 Libraries are searched in the reverse order in which they are specified.
4137 \f3cd\fP \*(OK \f3\-LP\fP \*(CK \*(OK \f2arg\^\fP \*(CK
4139 \f3cd\fP \*(OK \f3\-LP\fP \*(CK \f2old\^\fP \f2new\^\fP
4141 This command can be in either of two forms.
4142 In the first form it
4143 changes the current directory to
4149 the directory is changed to the previous
4160 is set to the current directory.
4164 defines the search path for
4165 the directory containing
4167 Alternative directory names are separated by
4172 (specifying the current directory).
4173 Note that the current directory is specified by a null path name,
4174 which can appear immediately after the equal sign
4175 or between the colon delimiters anywhere else in the path list.
4178 begins with a \f3/\fP then the search path
4180 Otherwise, each directory in the path is
4184 The obsolete second form of
4186 substitutes the string
4190 in the current directory name,
4193 and tries to change to this new directory.
4195 By default, symbolic links are not followed when
4196 finding the directory name.
4197 This is equivalent to the
4203 symbolic links to be followed when determining the directory.
4204 The last instance of
4208 determines which method is used.
4212 command may not be executed by
4214 .if \nZ=1 .B rksh\^.
4216 \f3command\fP \*(OK \f3\-pvV\fP \*(CK \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4225 with the arguments given by
4230 a default path to be searched
4231 rather than the one defined by the value of
4234 Functions will not be searched for when finding
4238 refers to a special built-in,
4239 none of the special properties associated with the leading
4240 daggers will be honored.
4242 For example, the predefined alias
4243 .B "redirect=\(fmcommand exec\(fm"
4244 prevents a script from terminating when an invalid
4245 redirection is given.)
4250 is equivalent to the built-in
4252 command described below.
4260 \(dg \f3continue\fP \*(OK \f2n\^\fP \*(CK
4261 Resume the next iteration of the enclosing
4270 is specified then resume at the
4274 \f3disown\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
4275 Causes the shell not to send a HUP signal to
4278 or all active jobs if
4281 when a login shell terminates.
4283 \f3echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4286 does not begin with a \-, and
4287 none of the arguments contain a \e,
4290 prints each of its arguments separated by a space
4291 and terminated by a new-line.
4292 Otherwise, the behavior of
4299 described below should be used.
4302 for usage and description.
4304 \(dg \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4305 The arguments are read as input
4307 and the resulting command(s) executed.
4309 \(dg \f3exec\fP \*(OK \f3\-c\fP \*(CK \*(OK \f3\-a\fP \f2name\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
4313 the command specified by
4314 the arguments is executed in place of this shell
4315 without creating a new process.
4318 option causes the environment to be cleared before applying
4319 variable assignments associated with the
4327 rather than the first
4331 for the new process.
4332 Input/output arguments may appear and
4333 affect the current process.
4337 the effect of this command is to
4338 modify file descriptors
4339 as prescribed by the input/output redirection list.
4341 any file descriptor numbers greater than 2 that are
4342 opened with this mechanism are closed when invoking
4345 \(dg \f3exit\fP \*(OK \f2n\^\fP \*(CK
4346 Causes the shell to exit
4347 with the exit status specified by
4349 The value will be the least significant 8 bits of the specified status.
4352 is omitted then the exit status is that of the last command executed.
4353 An end-of-file will also cause the shell to exit
4361 \(dg\(dg \f3export\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2name\^\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
4365 the names and values of each variable with
4366 the export attribute are printed with the values
4367 quoted in a manner that allows them to be re-inputed.
4373 to be inserted before each one.
4374 Otherwise, the given
4376 are marked for automatic
4379 of subsequently-executed commands.
4381 \f3fg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
4382 This command is only on systems that support job control.
4385 specified is brought to the foreground and waited for in
4386 the specified order.
4387 Otherwise, the current job is
4388 brought into the foreground.
4391 for a description of the format of
4394 \f3getconf\fP \f2name\^\fP \*(OK \f2pathname\^\fP \*(CK
4395 Prints the current value of the configuration parameter given by
4398 \f3getopts\fP \f2optstring vname\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4405 the positional parameters are used.
4406 An option argument begins with a
4410 An option not beginning with
4418 contains the letters that
4421 If a letter is followed by a
4423 that option is expected to have an argument.
4424 The options can be separated from the argument by blanks.
4428 places the next option letter it finds inside variable
4430 each time it is invoked with a
4436 The index of the next
4441 The option argument,
4453 to store the letter of an invalid
4461 for an unknown option and to
4463 when a required option is missing.
4466 prints an error message.
4467 The exit status is non-zero when there are no more options.
4469 There is no way to specify any of the options
4479 can only be specified as the first option.
4482 \f3hist\fP \*(OK \f3\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f3\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
4484 \f3hist \-s \fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
4487 a range of commands from
4491 is selected from the last
4494 commands that were typed at the terminal.
4499 may be specified as a number or as a string.
4500 A string is used to locate the most recent command starting with
4502 A negative number is used as an offset to the current command number.
4507 the commands are listed on standard output.
4508 Otherwise, the editor program
4510 is invoked on a file containing these
4514 is not supplied, then the value of the variable
4526 is used as the editor.
4527 When editing is complete, the edited command(s)
4528 is executed if the changes have been saved.
4532 then it will be set to
4537 the default is the previous command
4538 for editing and \-16 for listing.
4541 reverses the order of the commands and
4544 suppresses command numbers when listing.
4545 In the second form the
4547 is re-executed after the substitution
4548 \f2old\^\fP\f3=\fP\f2new\^\fP
4551 \f3jobs\fP \*(OK \f3\-lnp\^\fP \*(CK \*(OK \f2job\^\fP \.\|.\|. \*(CK
4552 Lists information about each given job; or all active jobs if
4557 option lists process ids in addition to the normal information.
4560 option only displays jobs that have stopped or exited since last
4564 option causes only the process group to be listed.
4567 for a description of the format of
4571 \f3kill\fP \*(OK \f3\-s\fP \f2signame\^\fP \*(CK \f2job\^\fP .\|.\|.
4574 \f3kill\fP \*(OK \f3\-n\fP \f2signum\^\fP \*(CK \f2job\^\fP .\|.\|.
4576 \f3kill\fP \f3\-l\fP \*(OK \f2sig\^\fP .\|.\|. \*(CK
4578 Sends either the TERM (terminate) signal or the
4579 specified signal to the specified jobs or processes.
4580 Signals are either given by number with the
4582 option or by name with the
4587 stripped of the prefix ``SIG'' with
4588 the exception that SIGCLD is named CHLD).
4589 For backward compatibility, the
4593 can be omitted and the number or name placed immediately
4596 If the signal being sent is TERM (terminate) or HUP (hangup),
4597 then the job or process will be sent a CONT (continue) signal
4601 can be the process id of a process that is not a member of one of the
4605 for a description of the format of
4612 the signal names are listed.
4615 that is a name, the corresponding signal number is listed.
4618 that is a number, the signal name corresponding to the
4619 least significant 8 bits of
4623 \f3let\fP \f2arg\^\fP .\|.\|.
4627 .I "arithmetic expression"
4630 .I "Arithmetic Evaluation"
4631 above, for a description of arithmetic expression evaluation.
4634 0 if the value of the last expression
4635 is non-zero, and 1 otherwise.
4637 \(dg \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4639 .BI "exec /bin/newgrp" " arg\^"
4642 \f3print\fP \*(OK \f3\-Rnprs\^\fP \*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f3\-f\fP \f2format\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
4643 With no options or with option
4653 option causes the arguments to be printed as
4660 options are ignored.
4666 are specified, the following
4667 escape conventions will be applied:
4672 The alert character (ascii
4676 The backspace character (ascii
4682 to end without processing more arguments and
4683 not adding a new-line.
4686 The formfeed character (ascii
4690 The new-line character (ascii
4694 The carriage return character (ascii
4698 The tab character (ascii
4702 The vertical tab character (ascii
4706 The escape character (ascii
4710 The backslash character \e.
4715 option will print all subsequent arguments and options
4721 arguments to be written onto the pipe
4722 of the process spawned with
4724 instead of standard output.
4728 arguments to be written onto the history file
4729 instead of standard output.
4732 option can be used to specify a one digit
4733 file descriptor unit number
4736 output will be placed.
4742 is added to the output.
4745 \f3printf\fP \f2format\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
4748 are printed on standard output
4749 in accordance with the ANSI-C
4750 formatting rules associated with the format string
4752 The following extensions can also be used:
4757 format can be used instead of
4759 to cause escape sequences in the corresponding
4761 to be expanded as described in
4766 format can be used instead of
4770 to be interpreted as an extended regular
4771 expression and be printed as a shell pattern.
4775 format can be used instead of
4777 to cause the resulting string to be quoted in a manner than can
4778 be reinput to the shell.
4780 The precision field of the
4782 format can be followed by a
4784 and the output base.
4787 \f3pwd\fP \*(OK \f3\-LP\fP \*(CK
4788 Outputs the value of the current working
4793 all symbolic links are resolved from the name.
4795 \f3read\fP \*(OK \f3\-Aprs\^\fP \*(CK \*(OK \f3\-d\fP \f2delim\^\fP\*(CK \*(OK \f3\-t\fP \f2timeout\^\fP\*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
4796 The shell input mechanism.
4797 One line is read and
4798 is broken up into fields using the characters in
4802 The escape character,
4804 is used to remove any special meaning for the next
4805 character and for line continuation.
4809 causes the read to continue to the first character of
4811 rather than new-line.
4816 character is not treated specially.
4818 field is assigned to the first
4823 etc., with leftover fields assigned to the last
4827 option causes the variable
4829 to be unset and each field that is read to be stored in
4830 successive elements of the indexed array
4834 option causes the input line
4835 to be taken from the input pipe
4836 of a process spawned by the shell
4842 the input will be saved as a command in the history file.
4845 can be used to specify a one digit file
4849 The file descriptor can be opened with the
4851 special built-in command.
4852 The default value of unit
4857 is used to specify a timeout in decimal
4858 seconds when reading from a terminal or pipe.
4864 is used as the default
4866 An end-of-file with the
4868 option causes cleanup for this process
4869 so that another can be spawned.
4870 If the first argument contains a
4872 the remainder of this word is used as a
4875 when the shell is interactive.
4876 The exit status is 0 unless an end-of-file is encountered
4877 or read has timed out.
4879 \(dg\(dg \f3readonly\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
4883 the names and values of each variable with
4884 the readonly attribute is printed with the values
4885 quoted in a manner that allows them to be re-inputed.
4891 to be inserted before each one.
4892 Otherwise, the given
4896 names cannot be changed
4897 by subsequent assignment.
4899 \(dg \f3return\fP \*(OK \f2n\^\fP \*(CK
4905 to the invoking script
4906 with the return status specified by
4908 The value will be the least significant 8 bits of the specified status.
4911 is omitted then the return status is that of the last command executed.
4914 is invoked while not in a
4919 then it behaves the same as
4922 \(dg \f3set\fP \*(OK \f3\(+-CPabefhkmnopstuvx\fP \*(CK \*(OK \f3\(+-o\fP \f2option\^\fP \*(CK.\|.\|. \*(OK \f3\(+-A\fP \f2vname\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
4923 The options for this command have meaning as follows:
4931 and assign values sequentially from the
4936 is used, the variable
4941 Prevents redirection
4943 from truncating existing files.
4944 Files that are created are opened with the O_EXCL mode.
4947 to truncate a file when turned on.
4954 built-in commands to default to physical mode.
4957 All subsequent variables that are defined are automatically exported.
4960 Prints job completion messages as soon as a background job changes
4961 state rather than waiting for the next prompt.
4964 If a command has a non-zero exit status,
4970 This mode is disabled while reading profiles.
4973 Disables file name generation.
4977 becomes a tracked alias when first encountered.
4980 (Obsolete). All variable assignment arguments are placed in the environment for a command,
4981 not just those that precede the command name.
4984 Background jobs will run in a separate process group
4985 and a line will print upon completion.
4986 The exit status of background jobs is reported in a completion message.
4987 On systems with job control,
4988 this option is turned on automatically for
4992 Read commands and check them for syntax errors, but do not execute them.
4993 Ignored for interactive shells.
4996 The following argument can be one of the following option names:
5008 All background jobs are run at a lower priority.
5009 This is the default mode.
5014 style in-line editor for command entry.
5019 style in-line editor for command entry.
5022 The shell will not exit on end-of-file.
5032 All directory names resulting from file name generation have a trailing
5053 Do not save function definitions in history file.
5080 Puts you in insert mode of a
5082 style in-line editor
5083 until you hit escape character
5085 This puts you in control mode.
5086 A return sends the line.
5089 Each character is processed as it is typed
5098 If no option name is supplied then the current option settings are printed.
5102 Disables processing of the
5103 .B \s-1$HOME\s+1/.profile
5104 file and uses the file
5105 .B /etc/suid_profile
5110 This mode is on whenever the effective uid (gid)
5111 is not equal to the real uid (gid).
5112 Turning this off causes the effective uid and gid to be
5113 set to the real uid and gid.
5116 Sort the positional parameters lexicographically.
5119 (Obsolete). Exit after reading and executing one command.
5122 Treat unset parameters as an error when substituting.
5125 Print shell input lines as they are read.
5128 Print commands and their arguments as they are executed.
5131 Do not change any of the options; useful in setting
5133 to a value beginning with
5135 If no arguments follow this option then the positional parameters are unset.
5138 As an obsolete feature,
5147 options are turned off and the next
5149 is treated as the first argument.
5154 causes these options to be turned off.
5155 These options can also be used upon invocation of the shell.
5156 The current set of options may be found in
5161 the remaining arguments are positional
5162 parameters and are assigned, in order, to
5166 If no arguments are given then the names and values
5167 of all variables are printed on the standard output.
5170 \(dg \f3shift\fP \*(OK \f2n\^\fP \*(CK
5172 The positional parameters from
5173 \f3$\fP\f2n\fP\f3+1\fP
5183 can be any arithmetic expression that evaluates to a non-negative
5184 number less than or equal to
5187 \f3sleep\fP \f2seconds\^\fP
5188 Suspends execution for the number of decimal seconds or fractions of a
5192 \(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
5194 option causes the trap
5195 action associated with each trap as specified by the arguments
5196 to be printed with appropriate quoting.
5199 will be processed as if it were an argument to
5206 can be given as a number or as the name of the signal.
5207 Trap commands are executed in order of signal number.
5208 Any attempt to set a trap on a signal that
5209 was ignored on entry to the current shell
5213 is omitted and the first
5219 then the trap(s) for each
5222 to their original values.
5226 string then this signal is ignored by the shell and by the commands
5235 will be executed whenever a command has a non-zero exit status.
5243 will be executed before each command.
5253 statement is executed inside the body of a function,
5257 after the function completes.
5267 set outside any function
5271 on exit from the shell.
5279 will be executed whenever a key is read
5289 with no arguments prints a list
5290 of commands associated with each signal number.
5292 \(dg\(dg \f3typeset\fP \*(OK \f3\(+-AHflnprtux\^\fP \*(CK \*(OK \f3\(+-EFLRZi\*(OK\f2n\^\fP\*(CK \*(CK \*(OK \f2vname\^\fP\*(OK\f3=\fP\f2value\^\fP \*(CK \^ \*(CK .\|.\|.
5293 Sets attributes and values for shell variables and functions.
5294 When invoked inside a function,
5295 a new instance of the variables
5298 The variables' value and type are restored
5299 when the function completes.
5300 The following list of attributes may be specified:
5307 to be an associate array.
5308 Subscripts are strings rather than arithmetic
5314 to be a double precision floating point number.
5317 is non-zero it defines the number of significant figures
5318 that are used when expanding
5320 Otherwise ten significant figures will be used.
5325 to be a double precision floating point number.
5328 is non-zero it defines the number of places after the
5329 decimal point that are used when expanding
5331 Otherwise ten places after the decimal point will be used.
5334 This option provides UNIX to host-name file mapping on non-UNIX
5338 Left justify and remove leading blanks from
5342 is non-zero it defines the width
5344 otherwise it is determined by the width of the value of
5346 When the variable is assigned to, it is
5347 filled on the right with blanks or truncated, if necessary, to
5351 option is turned off.
5354 Right justify and fill with leading blanks.
5357 is non-zero it defines the width
5359 otherwise it is determined by the width of the value of
5361 The field is left filled with blanks or
5362 truncated from the end if the
5363 variable is reassigned.
5366 option is turned off.
5369 Right justify and fill with leading zeros if
5370 the first non-blank character is a digit and the
5372 option has not been set.
5373 Remove leading zeros if the
5378 is non-zero it defines the width
5380 otherwise it is determined by the width of the value of
5384 The names refer to function names rather than
5386 No assignments can be made and the only other
5394 turns on execution tracing for this function.
5397 causes this function to be marked undefined.
5401 variable will be searched to find the function definition
5402 when the function is referenced.
5407 to be represented internally as integer.
5408 The right hand side of an assignment is evaluated as an
5409 arithmetic expression when assigning to an integer.
5412 is non-zero it defines the output arithmetic base,
5413 otherwise the the output base will be ten.
5416 All upper-case characters are
5417 converted to lower-case.
5418 The upper-case option,
5425 to be a reference to the variable whose name is
5426 defined by the value of variable
5428 This is usually used to reference a variable inside
5429 a function whose name has been passed as an argument.
5436 names cannot be changed
5437 by subsequent assignment.
5441 Tags are user definable and have no special
5442 meaning to the shell.
5445 All lower-case characters are converted
5446 to upper-case characters.
5447 The lower-case option,
5454 are marked for automatic
5457 of subsequently-executed commands.
5458 Variables whose names contain a \fB\s+2.\s-2\fP
5459 can not be exported.
5464 attribute can not be specified along with
5475 causes these options to be turned off.
5491 values from being printed.)
5496 followed by the the option letters
5497 to be printed before each name
5498 rather than the names of the options.
5499 If any option other than
5502 only those variables
5503 which have all of the given
5504 options are printed.
5514 \f3ulimit\fP \*(OK \f3\-HSacdfmnpstv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
5515 Set or display a resource limit.
5516 The available resources limits are listed below.
5517 Many systems do not contain one or more of these limits.
5518 The limit for a specified resource is set when
5523 can be a number in the unit specified below with each resource,
5530 options specify whether the hard limit or the
5531 soft limit for the given resource is set.
5532 A hard limit cannot be increased once it is set. A soft
5533 limit can be increased up to the value of the hard limit.
5538 options is specified, the limit applies to both.
5539 The current resource limit is printed when
5542 In this case the soft limit is printed unless
5545 When more that one resource is specified, then the limit
5546 name and unit is printed before the value.
5551 Lists all of the current resource limits.
5554 The number of 512-byte blocks on the size of core dumps.
5557 The number of K-bytes on the size of the data area.
5560 The number of 512-byte blocks on files that can be written the
5561 current process or by child processes (files of any size may be read).
5564 The number of K-bytes on the size of physical memory.
5567 The number of file descriptors plus 1.
5570 The number of 512-byte blocks for pipe buffering.
5573 The number of K-bytes on the size of the stack area.
5576 The number of seconds to be used by each process.
5579 The number of K-bytes for virtual memory.
5582 If no option is given,
5587 \f3umask\fP \*(OK \f3\-S\fP \*(CK \*(OK \f2mask\^\fP \*(CK
5588 The user file-creation mask is set to
5593 can either be an octal number or
5594 a symbolic value as described in
5596 If a symbolic value is given,
5598 umask value is the complement of the result of
5601 to the complement of the previous umask value.
5604 is omitted, the current value of the mask is printed.
5607 option causes the mode to be printed as a symbolic
5608 value. Otherwise, the
5609 mask is printed in octal.
5611 \(dg \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|.
5614 given by the list of
5616 are removed from the
5621 option causes all the
5622 aliases to be unset.
5624 \(dg\f3unset\fP \*(OK \f3\-fv\fP \*(CK \f2vname\^\fP .\|.\|.
5625 The variables given by the list of
5629 their values and attributes are erased.
5630 Readonly variables cannot be unset.
5634 is set, then the names refer to
5639 option is set, then the names refer to
5642 The default is equivalent to
5664 removes their special meaning even if they are
5665 subsequently assigned to.
5667 \f3wait\fP \*(OK \f2job\^\fP .\|.\|. \*(CK
5668 Wait for the specified
5671 report its termination status.
5674 is not given then all currently active child processes are waited for.
5675 The exit status from this command is that of
5676 the last process waited for.
5679 for a description of the format of
5682 \f3whence\fP \*(OK \f3\-apv\fP \*(CK \f2name\^\fP .\|.\|.
5686 would be interpreted if used as a command name.
5691 produces a more verbose report.
5696 does a path search for
5698 even if name is an alias, a function, or a reserved word.
5704 all interpretations of the given name to be reported.
5706 If the shell is invoked by
5708 and the first character of argument zero
5712 then the shell is assumed to be a
5715 commands are read from
5717 and then from either
5719 in the current directory or
5720 .BR \s-1$HOME\s+1/.profile ,
5721 if either file exists.
5722 Next, commands are read from
5724 performing parameter expansion, command substitution,
5725 and arithmetic substitution on
5726 the value of the environment variable
5732 option is not present and
5734 is, then a path search is performed on the first
5736 to determine the name of the script to execute.
5739 must have read permission and any
5743 settings will be ignored.
5744 If the script is not found on the path,
5746 is processed as if it named a built-in command or function.
5747 Commands are then read as described below;
5748 the following option are interpreted by the shell
5756 option is present then
5757 commands are read from the first
5759 Any remaining arguments become
5760 position parameters starting at
5766 option is present or if no
5768 then commands are read from the standard input.
5770 except for the output of the
5771 .I Special Commands\^
5779 option is present or
5780 if the shell input and output are attached to a terminal (as told by
5784 In this case \s-1TERM\s+1 is ignored (so that \f3kill 0\fP
5785 does not kill an interactive shell) and \s-1INTR\s+1 is caught and ignored
5789 In all cases, \s-1QUIT\s+1 is ignored by the shell.
5794 option is present the shell is a restricted shell.
5801 to generate a cross reference database
5802 that can be used by a separate utility
5803 to find definitions and references for variables and commands.
5805 The remaining options and arguments are described under the
5810 as the first argument is ignored.
5811 .if \nZ=0 \{.SS Rsh Only.
5813 .if \nZ=1 \{.SS Rksh Only.
5815 is used to set up login names and execution environments whose
5816 capabilities are more controlled than those of the standard shell.
5820 are identical to those of
5821 .if \nZ=0 .BR sh\^ ,
5822 .if \nZ=1 .BR ksh\^ ,
5823 except that the following are disallowed:
5827 changing directory (see
5830 setting or unsetting the value or attributes of
5840 command names containing
5852 The restrictions above are enforced
5853 after \f3.profile\fP and the
5856 files are interpreted.
5858 When a command to be executed is found to be a shell procedure,
5859 .if \nZ=0 \{.B rsh\^
5862 .if \nZ=1 \{.B rksh\^
5866 Thus, it is possible to provide to the end-user shell procedures
5867 that have access to the full power of
5869 while imposing a limited menu of commands;
5870 this scheme assumes that the end-user does not have write and
5871 execute permissions in the same directory.
5873 The net effect of these rules is that the writer of the
5875 has complete control over user actions,
5876 by performing guaranteed setup actions
5877 and leaving the user in an appropriate directory
5880 the login directory).
5882 The system administrator often sets up a directory
5886 that can be safely invoked by
5888 .if \nZ=1 .BR rksh .
5890 Errors detected by the shell, such as syntax errors,
5892 to return a non-zero exit status.
5893 Otherwise, the shell returns the exit status of
5894 the last command executed (see also the
5897 If the shell is being used non-interactively
5898 then execution of the shell file is abandoned.
5899 Run time errors detected by the shell are reported by
5900 printing the command or function name and the error condition.
5901 If the line number that the error occurred on is greater than one,
5902 then the line number is also printed in square brackets
5904 after the command or function name.
5912 \s-1$HOME\s+1/\f3.\fPprofile
5946 Morris I. Bolsky and David G. Korn,
5947 .IR "The KornShell Command and Programming Language" ,
5948 Prentice Hall, 1989, ISBN 0-13-516972-0.
5952 is executed, and then a command with the same name is
5953 installed in a directory in the search path before the directory where the
5954 original command was found, the shell will continue to
5956 the original command.
5961 command to correct this situation.
5963 Some very old shell scripts contain a
5965 as a synonym for the pipe character
5970 built-in command within a compound command will cause the whole
5971 command to disappear from the history file.
5973 The built-in command \f3\|.\fP \f2file\^\fP
5974 reads the whole file before any commands are executed.
5979 commands in the file
5980 will not apply to any commands defined in the file.
5982 Traps are not processed while a job is waiting for a foreground process.
5985 won't be executed until the foreground job terminates.