2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
9 .\" Last Change: Wed Jan 20 16:47:14 EST 1999
11 .\" bash_builtins, strip all but Built-Ins section
13 .TH BASH 1 "1999 Jan 20" GNU
15 .\" There's some problem with having a `@'
16 .\" in a tagged paragraph with the BSD man macros.
17 .\" It has to do with `@' appearing in the }1 macro.
18 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
19 .\" appears to have fixed it.
20 .\" If you're seeing the characters
21 .\" `@u-3p' appearing before the lines reading
22 .\" `possible-hostname-completions
23 .\" and `complete-hostname' down in READLINE,
24 .\" then uncomment this redefinition.
29 .if !"\\$1"" .nr )I \\$1n
32 .in \\n()Ru+\\n(INu+\\n()Iu
34 .ie !\\n()Iu+\\n()Ru-\w
\a\\*(]X
\au-3p \{\\*(]X
36 .el \\*(]X\h
\a|\\n()Iu+\\n()Ru
\a\c
40 .\" File Name macro. This used to be `.PN', for Path Name,
41 .\" but Sun doesn't seem to like that very much.
47 bash \- GNU Bourne-Again SHell
53 .if n Bash is Copyright (C) 1989-1999 by the Free Software Foundation, Inc.
54 .if t Bash is Copyright \(co 1989-1999 by the Free Software Foundation, Inc.
57 is an \fBsh\fR-compatible command language interpreter that
58 executes commands read from the standard input or from a file.
60 also incorporates useful features from the \fIKorn\fP and \fIC\fP
61 shells (\fBksh\fP and \fBcsh\fP).
64 is intended to be a conformant implementation of the IEEE
65 POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
67 In addition to the single-character shell options documented in the
68 description of the \fBset\fR builtin command, \fBbash\fR
69 interprets the following options when it is invoked:
76 option is present, then commands are read from
78 If there are arguments after the
80 they are assigned to the positional parameters, starting with
86 option is present, the shell becomes
96 option is present, the shell is
102 option is present, or if no arguments remain after option
103 processing, then commands are read from the standard input.
104 This option allows the positional parameters to be set
105 when invoking an interactive shell.
108 A list of all double-quoted strings preceded by \fB$\fP
109 is printed on the standard ouput.
110 These are the strings that
111 are subject to language translation when the current locale
113 This implies the \fB\-n\fP option; no commands will be executed.
118 signals the end of options and disables further option processing.
119 Any arguments after the
121 are treated as filenames and arguments. An argument of
123 is equivalent to \fB\-\-\fP.
127 also interprets a number of multi-character options.
128 These options must appear on the command line before the
129 single-character options in order for them to be recognized.
133 .B \-\-dump\-po\-strings
134 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
135 \fBpo\fP (portable object) file format.
138 Equivalent to \fB\-D\fP.
141 Display a usage message on standard output and exit successfully.
146 act as if it had been invoked as a login shell (see
154 library to read command lines if interactive.
157 Do not read either the system-wide startup file
159 or any of the personal initialization files
160 .IR ~/.bash_profile ,
166 reads these files when it is invoked as a login shell (see
172 Do not read and execute the personal initialization file
174 if the shell is interactive.
175 This option is on by default if the shell is invoked as
179 Change the behavior of \fBbash\fP where the default operation differs
180 from the POSIX 1003.2 standard to match the standard.
182 \fB\-\-rcfile\fP \fIfile\fP
183 Execute commands from
185 instead of the standard personal initialization file
187 if the shell is interactive (see
193 The shell becomes restricted (see
195 .B "RESTRICTED SHELL"
199 Equivalent to \fB\-v\fP.
202 Show version information for this instance of
204 on the standard output and exit successfully.
207 If arguments remain after option processing, and neither the
211 option has been supplied, the first argument is assumed to
212 be the name of a file containing shell commands.
215 is invoked in this fashion,
217 is set to the name of the file, and the positional parameters
218 are set to the remaining arguments.
220 reads and executes commands from this file, then exits.
221 \fBBash\fP's exit status is the exit status of the last command
222 executed in the script.
223 If no commands are executed, the exit status is 0.
225 A \fIlogin shell\fP is one whose first character of argument zero is a
227 or one started with the
231 An \fIinteractive\fP shell is one whose standard input and output are
232 both connected to terminals (as determined by
234 or one started with the
246 allowing a shell script or a startup file to test this state.
248 The following paragraphs describe how
250 executes its startup files.
251 If any of the files exist but cannot be read,
254 Tildes are expanded in file names as described below under
263 is invoked as an interactive login shell, or as a non-interactive shell
264 with the \fB\-\-login\fP option, it first reads and
265 executes commands from the file \fI/etc/profile\fP, if that
267 After reading that file, it looks for \fI~/.bash_profile\fP,
268 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
269 and executes commands from the first one that exists and is readable.
272 option may be used when the shell is started to inhibit this behavior.
274 When a login shell exits,
276 reads and executes commands from the file \fI~/.bash_logout\fP, if it
279 When an interactive shell that is not a login shell is started,
281 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
282 This may be inhibited by using the
285 The \fB\-\-rcfile\fP \fIfile\fP option will force
287 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
291 is started non-interactively, to run a shell script, for example, it
292 looks for the variable
295 in the environment, expands its value if it appears there, and uses the
296 expanded value as the name of a file to read and execute.
298 behaves as if the following command were executed:
301 \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
307 variable is not used to search for the file name.
311 is invoked with the name
313 it tries to mimic the startup behavior of historical versions of
315 as closely as possible,
316 while conforming to the POSIX standard as well.
317 When invoked as an interactive login shell, or a non-interactive
318 shell with the \fB\-\-login\fP option, it first attempts to
319 read and execute commands from
326 option may be used to inhibit this behavior.
327 When invoked as an interactive shell with the name
330 looks for the variable
333 expands its value if it is defined, and uses the
334 expanded value as the name of a file to read and execute.
335 Since a shell invoked as
337 does not attempt to read and execute commands from any other startup
340 option has no effect.
341 A non-interactive shell invoked with the name
343 does not attempt to read any other startup files.
349 mode after the startup files are read.
357 command line option, it follows the POSIX standard for startup files.
358 In this mode, interactive shells expand the
361 variable and commands are read and executed from the file
362 whose name is the expanded value.
363 No other startup files are read.
366 attempts to determine when it is being run by the remote shell
367 daemon, usually \fIrshd\fP.
370 determines it is being run by \fIrshd\fP, it reads and executes
371 commands from \fI~/.bashrc\fP, if that file exists and is readable.
372 It will not do this if invoked as \fBsh\fP.
375 option may be used to inhibit this behavior, and the
377 option may be used to force another file to be read, but
378 \fIrshd\fP does not generally invoke the shell with those options
379 or allow them to be specified.
381 If the shell is started with the effective user (group) id not equal to the
382 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
383 files are read, shell functions are not inherited from the environment,
384 the \fBSHELLOPTS\fP variable, if it appears in the environment, is ignored,
385 and the effective user id is set to the real user id.
386 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
387 the same, but the effective user id is not reset.
390 The following definitions are used throughout the rest of this
398 A sequence of characters considered as a single unit by the shell.
405 consisting only of alphanumeric characters and underscores, and
406 beginning with an alphabetic character or an underscore. Also
411 A character that, when unquoted, separates words. One of the following:
415 .if t \fB| & ; ( ) < > space tab\fP
416 .if n \fB| & ; ( ) < > space tab\fP
421 A \fItoken\fP that performs a control function. It is one of the following
425 .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
426 .if n \fB|| & && ; ;; ( ) | <newline>\fP
430 \fIReserved words\fP are words that have a special meaning to the shell.
431 The following words are recognized as reserved when unquoted and either
432 the first word of a simple command (see
435 below) or the third word of a
443 .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
444 .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
450 A \fIsimple command\fP is a sequence of optional variable assignments
451 followed by \fBblank\fP-separated words and redirections, and
452 terminated by a \fIcontrol operator\fP. The first word
453 specifies the command to be executed. The remaining words are
454 passed as arguments to the invoked command.
456 The return value of a \fIsimple command\fP is its exit status, or
457 128+\fIn\^\fP if the command is terminated by signal
461 A \fIpipeline\fP is a sequence of one or more commands separated by
464 The format for a pipeline is:
467 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
470 The standard output of
472 is connected to the standard input of
474 This connection is performed before any redirections specified by the
482 precedes a pipeline, the exit status of that
483 pipeline is the logical NOT of the exit status of the last command.
484 Otherwise, the status of the pipeline is the exit status of the last
486 The shell waits for all commands in the pipeline to
487 terminate before returning a value.
491 reserved word precedes a pipeline, the elapsed as well as user and
492 system time consumed by its execution are reported when the pipeline
494 The \fB\-p\fP option changes the output format to that specified by POSIX.
498 variable may be set to a format string that specifies how the timing
499 information should be displayed; see the description of
506 Each command in a pipeline is executed as a separate process (i.e., in a
510 A \fIlist\fP is a sequence of one or more pipelines separated by one
517 and optionally terminated by one of
523 Of these list operators,
527 have equal precedence, followed by
531 which have equal precedence.
533 If a command is terminated by the control operator
535 the shell executes the command in the \fIbackground\fP
536 in a subshell. The shell does not wait for the command to
537 finish, and the return status is 0. Commands separated by a
539 are executed sequentially; the shell waits for each
540 command to terminate in turn. The return status is the
541 exit status of the last command executed.
543 The control operators
547 denote AND lists and OR lists, respectively.
548 An AND list has the form
551 \fIcommand\fP \fB&&\fP \fIcommand2\fP
555 is executed if, and only if,
557 returns an exit status of zero.
559 An OR list has the form
562 \fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP
567 is executed if and only if
569 returns a non-zero exit status. The return status of
570 AND and OR lists is the exit status of the last command
571 executed in the list.
572 .SS Compound Commands
574 A \fIcompound command\fP is one of the following:
577 \fIlist\fP is executed in a subshell. Variable assignments and builtin
578 commands that affect the shell's environment do not remain in effect
579 after the command completes. The return status is the exit status of
583 \fIlist\fP is simply executed in the current shell environment.
584 \fIlist\fP must be terminated with a newline or semicolon.
585 This is known as a \fIgroup command\fP.
586 The return status is the exit status of
590 The \fIexpression\fP is evaluated according to the rules described
593 .BR "ARITHMETIC EVALUATION" .
594 If the value of the expression is non-zero, the return status is 0;
595 otherwise the return status is 1. This is exactly equivalent to
596 \fBlet "\fIexpression\fP"\fR.
598 \fB[[\fP \fIexpression\fP \fB]]\fP
599 Return a status of 0 or 1 depending on the evaluation of
600 the conditional expression \fIexpression\fP.
601 Expressions are composed of the primaries described below under
603 .BR "CONDITIONAL EXPRESSIONS" .
604 Word splitting and pathname expansion are not performed on the words
605 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
606 variable expansion, arithmetic expansion, command substitution, process
607 substitution, and quote removal are performed.
610 When the \fB==\fP and \fB!=\fP operators are used, the string to the
611 right of the operator is considered a pattern and matched according
612 to the rules described below under \fBPattern Matching\fP.
613 The return value is 0 if the string matches or does not match
614 the pattern, respectively, and 1 otherwise.
615 Any part of the pattern may be quoted to force it to be matched as a
619 Expressions may be combined using the following operators, listed
620 in decreasing order of precedence:
626 .B ( \fIexpression\fP )
627 Returns the value of \fIexpression\fP.
628 This may be used to override the normal precedence of operators.
630 .B ! \fIexpression\fP
635 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
642 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
643 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
655 operators do not execute \fIexpression2\fP if the value of
656 \fIexpression1\fP is sufficient to determine the return value of
657 the entire conditional expression.
659 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
660 The list of words following \fBin\fP is expanded, generating a list
661 of items. The variable \fIname\fP is set to each element of this list
662 in turn, and \fIlist\fP is executed each time. If the \fBin\fP
663 \fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP
664 once for each positional parameter that is set (see
668 The return status is the exit status of the last command that executes.
669 If the expansion of the items following \fBin\fP results in an empty
670 list, no commands are executed, and the return status is 0.
672 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
673 The list of words following \fBin\fP is expanded, generating a list
674 of items. The set of expanded words is printed on the standard
675 error, each preceded by a number. If the \fBin\fP
676 \fIword\fP is omitted, the positional parameters are printed (see
681 prompt is then displayed and a line read from the standard input.
682 If the line consists of a number corresponding to one of
683 the displayed words, then the value of
685 is set to that word. If the line is empty, the words and prompt
686 are displayed again. If EOF is read, the command completes. Any
687 other value read causes
689 to be set to null. The line read is saved in the variable
693 is executed after each selection until a
700 is the exit status of the last command executed in
702 or zero if no commands were executed.
704 \fBcase\fP \fIword\fP \fBin\fP [ ( \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
705 ... ) \fIlist\fP ;; ] ... \fBesac\fP
706 A \fBcase\fP command first expands \fIword\fP, and tries to match
707 it against each \fIpattern\fP in turn, using the same matching rules
708 as for pathname expansion (see
709 .B Pathname Expansion
710 below). When a match is found, the
711 corresponding \fIlist\fP is executed. After the first match, no
712 subsequent matches are attempted. The exit status is zero if no
713 pattern matches. Otherwise, it is the exit status of the
714 last command executed in \fIlist\fP.
716 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
717 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
718 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
722 is executed. If its exit status is zero, the
723 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
724 \fIlist\fP is executed in turn, and if its exit status is zero,
725 the corresponding \fBthen\fP \fIlist\fP is executed and the
726 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
727 executed, if present. The exit status is the exit status of the
728 last command executed, or zero if no condition tested true.
731 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
733 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
735 The \fBwhile\fP command continuously executes the \fBdo\fP
736 \fIlist\fP as long as the last command in \fIlist\fP returns
737 an exit status of zero. The \fBuntil\fP command is identical
738 to the \fBwhile\fP command, except that the test is negated;
742 is executed as long as the last command in
744 returns a non-zero exit status.
745 The exit status of the \fBwhile\fP and \fBuntil\fP commands
747 of the last \fBdo\fP \fIlist\fP command executed, or zero if
750 [ \fBfunction\fP ] \fIname\fP () { \fIlist\fP; }
751 This defines a function named \fIname\fP. The \fIbody\fP of the
754 of commands between { and }. This list
755 is executed whenever \fIname\fP is specified as the
756 name of a simple command. The exit status of a function is
757 the exit status of the last command executed in the body. (See
762 In a non-interactive shell, or an interactive shell in which the
763 .B interactive_comments
766 builtin is enabled (see
768 .B "SHELL BUILTIN COMMANDS"
769 below), a word beginning with
771 causes that word and all remaining characters on that line to
772 be ignored. An interactive shell without the
773 .B interactive_comments
774 option enabled does not allow comments. The
775 .B interactive_comments
776 option is on by default in interactive shells.
778 \fIQuoting\fP is used to remove the special meaning of certain
779 characters or words to the shell. Quoting can be used to
780 disable special treatment for special characters, to prevent
781 reserved words from being recognized as such, and to prevent
784 Each of the \fImetacharacters\fP listed above under
787 has special meaning to the shell and must be quoted if they are to
788 represent themselves. There are three quoting mechanisms: the
789 .IR "escape character" ,
790 single quotes, and double quotes.
792 A non-quoted backslash (\fB\e\fP) is the
793 .IR "escape character" .
794 It preserves the literal value of the next character that follows,
795 with the exception of <newline>. If a \fB\e\fP<newline> pair
796 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
797 is treated as a line continuation (that is, it is removed from the
798 input stream and effectively ignored).
800 Enclosing characters in single quotes preserves the literal value
801 of each character within the quotes. A single quote may not occur
802 between single quotes, even when preceded by a backslash.
804 Enclosing characters in double quotes preserves the literal value
805 of all characters within the quotes, with the exception of
814 retain their special meaning within double quotes. The backslash
815 retains its special meaning only when followed by one of the following
823 A double quote may be quoted within double quotes by preceding it with
826 The special parameters
830 have special meaning when in double
836 Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
837 word expands to \fIstring\fP, with backslash-escaped characters replaced
838 as specifed by the ANSI C standard. Backslash escape sequences, if
839 present, are decoded as follows:
871 the character whose ASCII code is the octal value \fInnn\fP
872 (one to three digits)
875 the character whose ASCII code is the hexadecimal value \fInnn\fP
876 (one to three digits)
880 The translated result is single-quoted, as if the dollar sign had
883 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
884 the string to be translated according to the current locale.
885 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
887 If the string is translated and replaced, the replacement is
892 is an entity that stores values.
895 a number, or one of the special characters listed below under
896 .BR "Special Parameters" .
897 For the shell's purposes, a
899 is a parameter denoted by a
902 A parameter is set if it has been assigned a value. The null string is
903 a valid value. Once a variable is set, it may be unset only by using
908 .B SHELL BUILTIN COMMANDS
913 may be assigned to by a statement of the form
916 \fIname\fP=[\fIvalue\fP]
921 is not given, the variable is assigned the null string. All
923 undergo tilde expansion, parameter and variable expansion, string
924 expansion, command substitution, arithmetic expansion, and quote
928 below). If the variable has its
934 .BR "SHELL BUILTIN COMMANDS" )
937 is subject to arithmetic expansion even if the $((...)) expansion is
939 .B "Arithmetic Expansion"
941 Word splitting is not performed, with the exception
942 of \fB"$@"\fP as explained below under
943 .BR "Special Parameters" .
944 Pathname expansion is not performed.
945 .SS Positional Parameters
948 .I positional parameter
949 is a parameter denoted by one or more
950 digits, other than the single digit 0. Positional parameters are
951 assigned from the shell's arguments when it is invoked,
952 and may be reassigned using the
954 builtin command. Positional parameters may not be assigned to
955 with assignment statements. The positional parameters are
956 temporarily replaced when a shell function is executed (see
961 When a positional parameter consisting of more than a single
962 digit is expanded, it must be enclosed in braces (see
966 .SS Special Parameters
968 The shell treats several parameters specially. These parameters may
969 only be referenced; assignment to them is not allowed.
973 Expands to the positional parameters, starting from one. When the
974 expansion occurs within double quotes, it expands to a single word
975 with the value of each parameter separated by the first character
979 special variable. That is, "\fB$*\fP" is equivalent
980 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
982 is the first character of the value of the
988 is unset, the parameters are separated by spaces.
992 is null, the parameters are joined without intervening separators.
995 Expands to the positional parameters, starting from one. When the
996 expansion occurs within double quotes, each parameter expands to a
997 separate word. That is, "\fB$@\fP" is equivalent to
998 "\fB$1\fP" "\fB$2\fP" ...
999 When there are no positional parameters, "\fB$@\fP" and
1001 expand to nothing (i.e., they are removed).
1004 Expands to the number of positional parameters in decimal.
1007 Expands to the status of the most recently executed foreground
1011 Expands to the current option flags as specified upon invocation,
1014 builtin command, or those set by the shell itself
1020 Expands to the process ID of the shell. In a () subshell, it
1021 expands to the process ID of the current shell, not the
1025 Expands to the process ID of the most recently executed background
1026 (asynchronous) command.
1029 Expands to the name of the shell or shell script. This is set at
1030 shell initialization. If
1032 is invoked with a file of commands,
1034 is set to the name of that file. If
1040 is set to the first argument after the string to be
1041 executed, if one is present. Otherwise, it is set
1042 to the file name used to invoke
1044 as given by argument zero.
1047 At shell startup, set to the absolute file name of the shell or shell
1048 script being executed as passed in the argument list.
1049 Subsequently, expands to the last argument to the previous command,
1051 Also set to the full file name of each command executed and placed in
1052 the environment exported to that command.
1053 When checking mail, this parameter holds the name of the mail file
1054 currently being checked.
1058 The following variables are set by the shell:
1063 The process ID of the shell's parent. This variable is readonly.
1066 The current working directory as set by the
1071 The previous working directory as set by the
1076 Set to the line of input read by the
1078 builtin command when no arguments are supplied.
1081 Expands to the user ID of the current user, initialized at shell startup.
1082 This variable is readonly.
1085 Expands to the effective user ID of the current user, initialized at
1086 shell startup. This variable is readonly.
1089 An array variable containing the list of groups of which the current
1090 user is a member. This variable is readonly.
1093 Expands to the full file name used to invoke this instance of
1097 Expands to a string describing the version of this instance of
1101 A readonly array variable whose members hold version information for
1104 The values assigned to the array members are as follows:
1109 .B BASH_VERSINFO[\fR0\fP]
1110 The major version number (the \fIrelease\fP).
1112 .B BASH_VERSINFO[\fR1\fP]
1113 The minor version number (the \fIversion\fP).
1115 .B BASH_VERSINFO[\fR2\fP]
1118 .B BASH_VERSINFO[\fR3\fP]
1121 .B BASH_VERSINFO[\fR4\fP]
1122 The release status (e.g., \fIbeta1\fP).
1124 .B BASH_VERSINFO[\fR5\fP]
1125 The value of \fBMACHTYPE\fP.
1130 Incremented by one each time an instance of
1135 Each time this parameter is referenced, a random integer between
1137 generated. The sequence of random numbers may be initialized by assigning
1144 is unset, it loses its special properties, even if it is
1148 Each time this parameter is
1149 referenced, the number of seconds since shell invocation is returned. If a
1150 value is assigned to
1153 the value returned upon subsequent
1155 the number of seconds since the assignment plus the value assigned.
1159 is unset, it loses its special properties, even if it is
1163 Each time this parameter is referenced, the shell substitutes
1164 a decimal number representing the current sequential line number
1165 (starting with 1) within a script or function. When not in a
1166 script or function, the value substituted is not guaranteed to
1171 is unset, it loses its special properties, even if it is
1175 The history number, or index in the history list, of the current
1180 is unset, it loses its special properties, even if it is
1184 An array variable (see
1186 below) containing the current contents of the directory stack.
1187 Directories appear in the stack in the order they are displayed by the
1190 Assigning to members of this array variable may be used to modify
1191 directories already in the stack, but the
1195 builtins must be used to add and remove directories.
1196 Assignment to this variable will not change the current directory.
1200 is unset, it loses its special properties, even if it is
1204 An array variable (see
1206 below) containing a list of exit status values from the processes
1207 in the most-recently-executed foreground pipeline (which may
1208 contain only a single command).
1211 The value of the last option argument processed by the
1213 builtin command (see
1215 .B SHELL BUILTIN COMMANDS
1219 The index of the next argument to be processed by the
1221 builtin command (see
1223 .B SHELL BUILTIN COMMANDS
1227 Automatically set to the name of the current host.
1230 Automatically set to a string that uniquely
1231 describes the type of machine on which
1234 The default is system-dependent.
1237 Automatically set to a string that
1238 describes the operating system on which
1241 The default is system-dependent.
1244 Automatically set to a string that fully describes the system
1247 is executing, in the standard GNU \fIcpu-company-system\fP format.
1248 The default is system-dependent.
1251 A colon-separated list of enabled shell options. Each word in
1252 the list is a valid argument for the
1256 builtin command (see
1258 .B "SHELL BUILTIN COMMANDS"
1259 below). The options appearing in
1262 are those reported as
1265 If this variable is in the environment when
1267 starts up, each shell option in the list will be enabled before
1268 reading any startup files.
1269 This variable is read-only.
1272 The following variables are used by the shell. In some cases,
1274 assigns a default value to a variable; these cases are noted
1281 .I Internal Field Separator
1283 for word splitting after expansion and to
1284 split lines into words with the
1286 builtin command. The default value is
1287 ``<space><tab><newline>''.
1290 The search path for commands. It
1291 is a colon-separated list of directories in which
1292 the shell looks for commands (see
1294 .B COMMAND EXECUTION
1295 below). The default path is system-dependent,
1296 and is set by the administrator who installs
1298 A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
1301 The home directory of the current user; the default argument for the
1302 \fBcd\fP builtin command.
1303 The value of this variable is also used when performing tilde expansion.
1306 The search path for the
1309 This is a colon-separated list of directories in which the shell looks
1310 for destination directories specified by the
1313 A sample value is ``.:~:/usr''.
1316 If this parameter is set when \fBbash\fP is executing a shell script,
1317 its value is interpreted as a filename containing commands to
1318 initialize the shell, as in
1323 is subjected to parameter expansion, command substitution, and arithmetic
1324 expansion before being interpreted as a file name.
1327 is not used to search for the resultant file name.
1330 If this parameter is set to a file name and the
1333 variable is not set,
1335 informs the user of the arrival of mail in the specified file.
1341 checks for mail. The default is 60 seconds. When it is time to check
1342 for mail, the shell does so before displaying the primary prompt.
1343 If this variable is unset, the shell disables mail checking.
1346 A colon-separated list of file names to be checked for mail.
1347 The message to be printed when mail arrives in a particular file
1348 may be specified by separating the file name from the message with a `?'.
1349 When used in the text of the message, \fB$_\fP expands to the name of
1350 the current mailfile.
1354 \fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1357 supplies a default value for this variable, but the location of the user
1358 mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP).
1362 The value of this parameter is expanded (see
1365 below) and used as the primary prompt string. The default value is
1366 ``\fB\es\-\ev\e$ \fP''.
1369 The value of this parameter is expanded as with
1371 and used as the secondary prompt string. The default is
1375 The value of this parameter is used as the prompt for the
1383 The value of this parameter is expanded as with
1385 and the value is printed before each command
1387 displays during an execution trace. The first character of
1390 is replicated multiple times, as necessary, to indicate multiple
1391 levels of indirection. The default is ``\fB+ \fP''.
1394 The value of this parameter is used as a format string specifying
1395 how the timing information for pipelines prefixed with the
1397 reserved word should be displayed.
1398 The \fB%\fP character introduces an escape sequence that is
1399 expanded to a time value or other information.
1400 The escape sequences and their meanings are as follows; the
1401 braces denote optional portions.
1410 The elapsed time in seconds.
1413 The number of CPU seconds spent in user mode.
1416 The number of CPU seconds spent in system mode.
1419 The CPU percentage, computed as (%U + %S) / %R.
1423 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1424 the number of fractional digits after a decimal point.
1425 A value of 0 causes no decimal point or fraction to be output.
1426 At most three places after the decimal point may be specified;
1427 values of \fIp\fP greater than 3 are changed to 3.
1428 If \fIp\fP is not specified, the value 3 is used.
1430 The optional \fBl\fP specifies a longer format, including
1431 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1432 The value of \fIp\fP determines whether or not the fraction is
1435 If this variable is not set, \fBbash\fP acts as if it had the
1436 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1437 If the value is null, no timing information is displayed.
1438 A trailing newline is added when the format string is displayed.
1441 The number of commands to remember in the command history (see
1444 below). The default value is 500.
1447 The name of the file in which command history is saved (see
1450 below). The default value is \fI~/.bash_history\fP. If unset, the
1451 command history is not saved when an interactive shell exits.
1454 The maximum number of lines contained in the history file. When this
1455 variable is assigned a value, the history file is truncated, if
1456 necessary, to contain no more than that number of lines. The default
1457 value is 500. The history file is also truncated to this size after
1458 writing it when an interactive shell exits.
1461 If set to the value 1,
1463 displays error messages generated by the
1465 builtin command (see
1467 .B SHELL BUILTIN COMMANDS
1471 is initialized to 1 each time the shell is invoked or a shell
1475 Used to determine the locale category for any category not specifically
1476 selected with a variable starting with \fBLC_\fP.
1479 This variable overrides the value of \fBLANG\fP and any other
1480 \fBLC_\fP variable specifying a locale category.
1483 This variable determines the collation order used when sorting the
1484 results of pathname expansion, and determines the behavior of range
1485 expressions, equivalence classes, and collating sequences within
1486 pathname expansion and pattern matching.
1489 This variable determines the interpretation of characters and the
1490 behavior of character classes within pathname expansion and pattern
1494 This variable determines the locale used to translate double-quoted
1495 strings preceded by a \fB$\fP.
1498 If set, the value is executed as a command prior to issuing each primary
1503 action of an interactive shell on receipt of an
1506 character as the sole input. If set, the value is the number of
1510 characters which must be
1511 typed as the first characters on an input line before
1513 exits. If the variable exists but does not have a numeric value, or
1514 has no value, the default value is 10. If it does not exist,
1517 signifies the end of input to the shell.
1520 If set to a value greater than zero, the value is interpreted as the
1521 number of seconds to wait for input after issuing the primary prompt.
1523 terminates after waiting for that number of seconds if input does
1527 The default editor for the
1532 A colon-separated list of suffixes to ignore when performing
1533 filename completion (see
1537 A filename whose suffix matches one of the entries in
1540 is excluded from the list of matched filenames.
1541 A sample value is ``.o:~''.
1544 A colon-separated list of patterns defining the set of filenames to
1545 be ignored by pathname expansion.
1546 If a filename matched by a pathname expansion pattern also matches one
1550 it is removed from the list of matches.
1553 The filename for the
1555 startup file, overriding the default of
1563 If set to a value of
1565 lines which begin with a
1567 character are not entered on the history list. If set to
1570 lines matching the last history line are not entered.
1573 combines the two options.
1574 If unset, or if set to any other value than those above,
1576 by the parser are saved on the history list, subject to the value
1579 This variable's function is superseded by
1581 The second and subsequent lines of a multi-line compound command are
1582 not tested, and are added to the history regardless of the value of
1586 A colon-separated list of patterns used to decide which command lines
1587 should be saved on the history list. Each pattern is anchored at the
1588 beginning of the line and must fully specify the line (no implicit
1589 `\fB*\fP' is appended). Each pattern is tested against the line
1590 after the checks specified by
1593 In addition to the normal shell pattern matching characters, `\fB&\fP'
1594 matches the previous history line. `\fB&\fP' may be escaped using a
1595 backslash. The backslash is removed before attempting a match.
1596 The second and subsequent lines of a multi-line compound command are
1597 not tested, and are added to the history regardless of the value of
1601 The two or three characters which control history expansion
1602 and tokenization (see
1604 .B HISTORY EXPANSION
1605 below). The first character is the
1606 .IR "history expansion character" ,
1607 the character which signals the start of a history
1608 expansion, normally `\fB!\fP'.
1609 The second character is the
1610 .IR "quick substitution"
1611 character, which is used as shorthand for re-running the previous
1612 command entered, substituting one string for another in the command.
1613 The default is `\fB^\fP'.
1614 The optional third character is the character
1615 which indicates that the remainder of the line is a comment when found
1616 as the first character of a word, normally `\fB#\fP'. The history
1617 comment character causes history substitution to be skipped for the
1618 remaining words on the line. It does not necessarily cause the shell
1619 parser to treat the rest of the line as a comment.
1622 Contains the name of a file in the same format as
1624 that should be read when the shell needs to complete a
1625 hostname. The file may be changed interactively; the next
1626 time hostname completion is attempted
1628 adds the contents of the new file to the already existing database.
1631 This variable controls how the shell interacts with the user and
1632 job control. If this variable is set, single word simple
1633 commands without redirections are treated as candidates for resumption
1634 of an existing stopped job. There is no ambiguity allowed; if there is
1635 more than one job beginning with the string typed, the job most recently
1636 accessed is selected. The
1638 of a stopped job, in this context, is the command line used to
1642 the string supplied must match the name of a stopped job exactly;
1645 the string supplied needs to match a substring of the name of a
1648 value provides functionality analogous to the
1653 below). If set to any other value, the supplied string must
1654 be a prefix of a stopped job's name; this provides functionality
1661 provides one-dimensional array variables. Any variable may be used as
1664 builtin will explicitly declare an array. There is no maximum
1665 limit on the size of an array, nor any requirement that members
1666 be indexed or assigned contiguously. Arrays are indexed using
1667 integers and are zero-based.
1669 An array is created automatically if any variable is assigned to using
1670 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
1672 is treated as an arithmetic expression that must evaluate to a number
1673 greater than or equal to zero. To explicitly declare an array, use
1674 .B declare \-a \fIname\fP
1677 .B SHELL BUILTIN COMMANDS
1679 .B declare \-a \fIname\fP[\fIsubscript\fP]
1680 is also accepted; the \fIsubscript\fP is ignored. Attributes may be
1681 specified for an array variable using the
1685 builtins. Each attribute applies to all members of an array.
1687 Arrays are assigned to using compound assignments of the form
1688 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
1689 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
1690 \fIstring\fP is required. If
1691 the optional brackets and subscript are supplied, that index is assigned to;
1692 otherwise the index of the element assigned is the last index assigned
1693 to by the statement plus one. Indexing starts at zero.
1694 This syntax is also accepted by the
1696 builtin. Individual array elements may be assigned to using the
1697 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
1699 Any element of an array may be referenced using
1700 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
1701 conflicts with pathname expansion. If
1702 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
1703 all members of \fIname\fP. These subscripts differ only when the
1704 word appears within double quotes. If the word is double-quoted,
1705 ${\fIname\fP[*]} expands to a single
1706 word with the value of each array member separated by the first
1710 special variable, and ${\fIname\fP[@]} expands each element of
1711 \fIname\fP to a separate word. When there are no array members,
1712 ${\fIname\fP[@]} expands to nothing. This is analogous to the expansion
1713 of the special parameters \fB*\fP and \fB@\fP (see
1714 .B Special Parameters
1715 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
1716 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
1717 \fB@\fP, the expansion is the number of elements in the array.
1718 Referencing an array variable without a subscript is equivalent to
1719 referencing element zero.
1723 builtin is used to destroy arrays. \fBunset\fP \fBname\fP[\fIsubscript\fP]
1724 destroys the array element at index \fIsubscript\fP.
1725 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
1726 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
1727 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
1734 builtins each accept a
1736 option to specify an array. The
1740 option to assign a list of words read from the standard input
1745 builtins display array values in a way that allows them to be
1746 reused as assignments.
1748 Expansion is performed on the command line after it has been split into
1749 words. There are seven kinds of expansion performed:
1750 .IR "brace expansion" ,
1751 .IR "tilde expansion" ,
1752 .IR "parameter and variable expansion" ,
1753 .IR "command substitution" ,
1754 .IR "arithmetic expansion" ,
1755 .IR "word splitting" ,
1757 .IR "pathname expansion" .
1759 The order of expansions is: brace expansion, tilde expansion,
1760 parameter, variable and arithmetic expansion and
1761 command substitution
1762 (done in a left-to-right fashion), word splitting, and pathname
1765 On systems that can support it, there is an additional expansion
1766 available: \fIprocess substitution\fP.
1768 Only brace expansion, word splitting, and pathname expansion
1769 can change the number of words of the expansion; other expansions
1770 expand a single word to a single word.
1771 The only exceptions to this are the expansions of
1772 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
1773 as explained above (see
1778 .I "Brace expansion"
1779 is a mechanism by which arbitrary strings
1780 may be generated. This mechanism is similar to
1781 \fIpathname expansion\fP, but the filenames generated
1782 need not exist. Patterns to be brace expanded take
1783 the form of an optional
1785 followed by a series of comma-separated strings
1786 between a pair of braces, followed by an optional
1788 The preamble is prefixed to each string contained
1789 within the braces, and the postscript is then appended
1790 to each resulting string, expanding left to right.
1792 Brace expansions may be nested. The results of each expanded
1793 string are not sorted; left to right order is preserved.
1794 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
1796 Brace expansion is performed before any other expansions,
1797 and any characters special to other expansions are preserved
1798 in the result. It is strictly textual.
1800 does not apply any syntactic interpretation to the context of the
1801 expansion or the text between the braces.
1803 A correctly-formed brace expansion must contain unquoted opening
1804 and closing braces, and at least one unquoted comma.
1805 Any incorrectly formed brace expansion is left unchanged.
1806 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
1807 being considered part of a brace expression.
1809 This construct is typically used as shorthand when the common
1810 prefix of the strings to be generated is longer than in the
1814 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1818 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1821 Brace expansion introduces a slight incompatibility with
1822 historical versions of
1825 does not treat opening or closing braces specially when they
1826 appear as part of a word, and preserves them in the output.
1828 removes braces from words as a consequence of brace
1829 expansion. For example, a word entered to
1832 appears identically in the output. The same word is
1837 If strict compatibility with
1843 option or disable brace expansion with the
1849 .B SHELL BUILTIN COMMANDS
1853 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
1854 the characters preceding the first unquoted slash (or all characters,
1855 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
1856 If none of the characters in the tilde-prefix are quoted, the
1857 characters in the tilde-prefix following the tilde are treated as a
1858 possible \fIlogin name\fP.
1859 If this login name is the null string, the tilde is replaced with the
1860 value of the shell parameter
1866 is unset, the home directory of the user executing the shell is
1867 substituted instead.
1868 Otherwise, the tilde-prefix is replaced with the home directory
1869 associated with the specified login name.
1871 If the tilde-prefix is a `~+', the value of the shell variable
1874 replaces the tilde-prefix.
1875 If the tilde-prefix is a `~\-', the value of the shell variable
1878 if it is set, is substituted.
1879 If the characters following the tilde in the tilde-prefix consist
1880 of a number \fIN\fP, optionally prefixed
1881 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
1882 element from the directory stack, as it would be displayed by the
1884 builtin invoked with the tilde-prefix as an argument.
1885 If the characters following the tilde in the tilde-prefix consist of a
1886 number without a leading `+' or `\-', `+' is assumed.
1888 If the login name is invalid, or the tilde expansion fails, the word
1891 Each variable assignment is checked for unquoted tilde-prefixes immediately
1896 In these cases, tilde expansion is also performed.
1897 Consequently, one may use file names with tildes in assignments to
1905 and the shell assigns the expanded value.
1906 .SS Parameter Expansion
1908 The `\fB$\fP' character introduces parameter expansion,
1909 command substitution, or arithmetic expansion. The parameter name
1910 or symbol to be expanded may be enclosed in braces, which
1911 are optional but serve to protect the variable to be expanded from
1912 characters immediately following it which could be
1913 interpreted as part of the name.
1915 When braces are used, the matching ending brace is the first `\fB}\fP'
1916 not escaped by a backslash or within a quoted string, and not within an
1917 embedded arithmetic expansion, command substitution, or paramter
1923 The value of \fIparameter\fP is substituted. The braces are required
1926 is a positional parameter with more than one digit,
1929 is followed by a character which is not to be
1930 interpreted as part of its name.
1933 If the first character of \fIparameter\fP is an exclamation point,
1934 a level of variable indirection is introduced.
1935 \fBBash\fP uses the value of the variable formed from the rest of
1936 \fIparameter\fP as the name of the variable; this variable is then
1937 expanded and that value used in the rest of the substitution, rather
1938 than the value of \fIparameter\fP itself.
1939 This is known as \fIindirect expansion\fP.
1941 In each of the cases below, \fIword\fP is subject to tilde expansion,
1942 parameter expansion, command substitution, and arithmetic expansion.
1943 When not performing substring expansion, \fBbash\fP tests for a parameter
1944 that is unset or null; omitting the colon results in a test only for a
1945 parameter that is unset.
1949 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
1950 \fBUse Default Values\fP. If
1952 is unset or null, the expansion of
1954 is substituted. Otherwise, the value of
1958 ${\fIparameter\fP\fB:=\fP\fIword\fP}
1959 \fBAssign Default Values\fP.
1962 is unset or null, the expansion of
1968 is then substituted. Positional parameters and special parameters may
1969 not be assigned to in this way.
1971 ${\fIparameter\fP\fB:?\fP\fIword\fP}
1972 \fBDisplay Error if Null or Unset\fP.
1975 is null or unset, the expansion of \fIword\fP (or a message to that effect
1978 is not present) is written to the standard error and the shell, if it
1979 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
1982 ${\fIparameter\fP\fB:+\fP\fIword\fP}
1983 \fBUse Alternate Value\fP.
1986 is null or unset, nothing is substituted, otherwise the expansion of
1991 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
1993 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
1995 \fBSubstring Expansion.\fP
1996 Expands to up to \fIlength\fP characters of \fIparameter\fP,
1997 starting at the characters specified by \fIoffset\fP.
1998 If \fIlength\fP is omitted, expands to the substring of
1999 \fIparameter\fP, starting at the character specified by \fIoffset\fP.
2000 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2003 ARITHMETIC EVALUATION
2005 \fIlength\fP must evaluate to a number greater than or equal to zero.
2006 If \fIoffset\fP evaluates to a number less than zero, the value
2007 is used as an offset from the end of the value of \fIparameter\fP.
2008 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2009 parameters beginning at \fIoffset\fP.
2010 If \fIparameter\fP is an array name indexed by @ or *,
2011 the result is the \fIlength\fP
2012 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2013 Substring indexing is zero-based unless the positional parameters
2014 are used, in which case the indexing starts at 1.
2016 ${\fB#\fP\fIparameter\fP}
2017 The length in characters of the value of \fIparameter\fP is substituted.
2024 the value substituted is the number of positional parameters.
2027 is an array name subscripted by
2031 the value substituted is the number of elements in the array.
2034 ${\fIparameter\fP\fB#\fP\fIword\fP}
2036 ${\fIparameter\fP\fB##\fP\fIword\fP}
2040 is expanded to produce a pattern just as in pathname
2041 expansion. If the pattern matches the beginning of
2044 then the result of the expansion is the expanded value of
2046 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2047 longest matching pattern (the ``\fB##\fP'' case) deleted.
2054 the pattern removal operation is applied to each positional
2055 parameter in turn, and the expansion is the resultant list.
2058 is an array variable subscripted with
2062 the pattern removal operation is applied to each member of the
2063 array in turn, and the expansion is the resultant list.
2066 ${\fIparameter\fP\fB%\fP\fIword\fP}
2068 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2070 The \fIword\fP is expanded to produce a pattern just as in
2072 If the pattern matches a trailing portion of the expanded value of
2074 then the result of the expansion is the expanded value of
2076 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2077 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2084 the pattern removal operation is applied to each positional
2085 parameter in turn, and the expansion is the resultant list.
2088 is an array variable subscripted with
2092 the pattern removal operation is applied to each member of the
2093 array in turn, and the expansion is the resultant list.
2096 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2098 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2100 The \fIpattern\fP is expanded to produce a pattern just as in
2102 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2103 against its value is replaced with \fIstring\fP.
2104 In the first form, only the first match is replaced.
2105 The second form causes all matches of \fIpattern\fP to be
2106 replaced with \fIstring\fP.
2107 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2108 of the expanded value of \fIparameter\fP.
2109 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2110 of the expanded value of \fIparameter\fP.
2111 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2112 and the \fB/\fP following \fIpattern\fP may be omitted.
2119 the substitution operation is applied to each positional
2120 parameter in turn, and the expansion is the resultant list.
2123 is an array variable subscripted with
2127 the substitution operation is applied to each member of the
2128 array in turn, and the expansion is the resultant list.
2129 .SS Command Substitution
2131 \fICommand substitution\fP allows the output of a command to replace
2132 the command name. There are two forms:
2136 \fB$(\fP\fIcommand\fP\|\fB)\fP
2140 \fB`\fP\fIcommand\fP\fB`\fP
2144 performs the expansion by executing \fIcommand\fP and
2145 replacing the command substitution with the standard output of the
2146 command, with any trailing newlines deleted.
2147 Embedded newlines are not deleted, but they may be removed during
2149 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2150 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2152 When the old-style backquote form of substitution is used,
2153 backslash retains its literal meaning except when followed by
2158 The first backquote not preceded by a backslash terminates the
2159 command substitution.
2160 When using the $(\^\fIcommand\fP\|) form, all characters between the
2161 parentheses make up the command; none are treated specially.
2163 Command substitutions may be nested. To nest when using the backquoted form,
2164 escape the inner backquotes with backslashes.
2166 If the substitution appears within double quotes, word splitting and
2167 pathname expansion are not performed on the results.
2168 .SS Arithmetic Expansion
2170 Arithmetic expansion allows the evaluation of an arithmetic expression
2171 and the substitution of the result. The format for arithmetic expansion is:
2174 \fB$((\fP\fIexpression\fP\fB))\fP
2179 is treated as if it were within double quotes, but a double quote
2180 inside the parentheses is not treated specially.
2181 All tokens in the expression undergo parameter expansion, string
2182 expansion, command substitution, and quote removal.
2183 Arithmetic substitutions may be nested.
2185 The evaluation is performed according to the rules listed below under
2187 .BR "ARITHMETIC EVALUATION" .
2192 prints a message indicating failure and no substitution occurs.
2193 .SS Process Substitution
2195 \fIProcess substitution\fP is supported on systems that support named
2196 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2197 It takes the form of
2198 \fB<(\fP\fIlist\^\fP\fB)\fP
2200 \fB>(\fP\fIlist\^\fP\fB)\fP.
2201 The process \fIlist\fP is run with its input or output connected to a
2202 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2203 passed as an argument to the current command as the result of the
2204 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2205 the file will provide input for \fIlist\fP. If the
2206 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2207 argument should be read to obtain the output of \fIlist\fP.
2209 When available, \fIprocess substitution\fP is performed
2210 simultaneously with parameter and variable expansion,
2211 command substitution,
2212 and arithmetic expansion.
2215 The shell scans the results of
2216 parameter expansion,
2217 command substitution,
2219 arithmetic expansion
2220 that did not occur within double quotes for
2221 .IR "word splitting" .
2223 The shell treats each character of
2226 as a delimiter, and splits the results of the other
2227 expansions into words on these characters. If
2232 .BR <space><tab><newline> ,
2237 characters serves to delimit words. If
2240 has a value other than the default, then sequences of
2241 the whitespace characters
2245 are ignored at the beginning and end of the
2246 word, as long as the whitespace character is in the
2253 whitespace character).
2260 whitespace, along with any adjacent
2263 whitespace characters, delimits a field.
2267 whitespace characters is also treated as a delimiter.
2271 is null, no word splitting occurs.
2273 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2274 Unquoted implicit null arguments, resulting from the expansion of
2276 that have no values, are removed.
2277 If a parameter with no value is expanded within double quotes, a
2278 null argument results and is retained.
2280 Note that if no expansion occurs, no splitting
2282 .SS Pathname Expansion
2284 After word splitting,
2287 option has been set,
2289 scans each word for the characters
2295 If one of these characters appears, then the word is
2298 and replaced with an alphabetically sorted list of
2299 file names matching the pattern.
2300 If no matching file names are found,
2301 and the shell option
2303 is disabled, the word is left unchanged.
2306 option is set, and no matches are found,
2307 the word is removed.
2310 is enabled, the match is performed without regard to the case
2311 of alphabetic characters.
2312 When a pattern is used for pathname expansion,
2315 at the start of a name or immediately following a slash
2316 must be matched explicitly, unless the shell option
2319 When matching a pathname, the slash character must always be
2323 character is not treated specially.
2324 See the description of
2328 .B SHELL BUILTIN COMMANDS
2329 for a description of the
2339 shell variable may be used to restrict the set of file names matching a
2344 is set, each matching file name that also matches one of the patterns in
2347 is removed from the list of matches.
2352 are always ignored, even when
2355 is set. However, setting
2358 has the effect of enabling the
2360 shell option, so all other file names beginning with a
2363 To get the old behavior of ignoring file names beginning with a
2367 one of the patterns in
2372 option is disabled when
2377 \fBPattern Matching\fP
2379 Any character that appears in a pattern, other than the special pattern
2380 characters described below, matches itself. The NUL character may not
2381 occur in a pattern. The special pattern characters must be quoted if
2382 they are to be matched literally.
2384 The special pattern characters have the following meanings:
2389 Matches any string, including the null string.
2392 Matches any single character.
2395 Matches any one of the enclosed characters. A pair of characters
2396 separated by a minus sign denotes a
2398 any character lexically between those two characters, inclusive,
2399 is matched. If the first character following the
2405 then any character not enclosed is matched.
2408 may be matched by including it as the first or last character
2412 may be matched by including it as the first character
2421 \fIcharacter classes\fP can be specified using the syntax
2422 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
2423 following classes defined in the POSIX.2 standard:
2427 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
2428 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
2430 A character class matches any character belonging to that class.
2438 an \fIequivalence class\fP can be specified using the syntax
2439 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
2440 same collation weight (as defined by the current locale) as
2441 the character \fIc\fP.
2449 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
2454 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
2455 builtin, several extended pattern matching operators are recognized.
2456 In the following description, a \fIpattern\-list\fP is a list of one
2457 or more patterns separated by a \fB|\fP.
2458 Composite patterns may be formed using one or more of the following
2464 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
2465 Matches zero or one occurrence of the given patterns
2467 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
2468 Matches zero or more occurrences of the given patterns
2470 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
2471 Matches one or more occurrences of the given patterns
2473 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
2474 Matches exactly one of the given patterns
2476 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
2477 Matches anything except one of the given patterns
2482 After the preceding expansions, all unquoted occurrences of the
2486 and \^\f3"\fP\^ that did not result from one of the above
2487 expansions are removed.
2489 Before a command is executed, its input and output
2492 using a special notation interpreted by the shell.
2493 Redirection may also be used to open and close files for the
2494 current shell execution environment. The following redirection
2495 operators may precede or appear anywhere within a
2499 Redirections are processed in the order they appear, from
2502 In the following descriptions, if the file descriptor number is
2503 omitted, and the first character of the redirection operator is
2505 the redirection refers to the standard input (file descriptor
2506 0). If the first character of the redirection operator is
2508 the redirection refers to the standard output (file descriptor
2511 The word following the redirection operator in the following
2512 descriptions, unless otherwise noted, is subjected to brace expansion,
2513 tilde expansion, parameter expansion, command substitution, arithmetic
2514 expansion, quote removal, and pathname expansion.
2515 If it expands to more than one word,
2519 Note that the order of redirections is significant. For example,
2523 ls \fB>\fP dirlist 2\fB>&\fP1
2526 directs both standard output and standard error to the file
2531 ls 2\fB>&\fP1 \fB>\fP dirlist
2534 directs only the standard output to file
2536 because the standard error was duplicated as standard output
2537 before the standard output was redirected to
2540 A failure to open or create a file causes the redirection to fail.
2541 .SS Redirecting Input
2543 Redirection of input causes the file whose name results from
2546 to be opened for reading on file descriptor
2548 or the standard input (file descriptor 0) if
2552 The general format for redirecting input is:
2555 [\fIn\fP]\fB<\fP\fIword\fP
2557 .SS Redirecting Output
2559 Redirection of output causes the file whose name results from
2562 to be opened for writing on file descriptor
2564 or the standard output (file descriptor 1) if
2566 is not specified. If the file does not exist it is created;
2567 if it does exist it is truncated to zero size.
2569 The general format for redirecting output is:
2572 [\fIn\fP]\fB>\fP\fIword\fP
2575 If the redirection operator is
2581 builtin has been enabled, the redirection will fail if the filename
2582 whose name results from the expansion of \fIword\fP exists and is
2584 If the redirection operator is
2586 or the redirection operator is
2592 builtin command is not enabled, the redirection is attempted even
2593 if the file named by \fIword\fP exists.
2594 .SS Appending Redirected Output
2596 Redirection of output in this fashion
2597 causes the file whose name results from
2600 to be opened for appending on file descriptor
2602 or the standard output (file descriptor 1) if
2604 is not specified. If the file does not exist it is created.
2606 The general format for appending output is:
2609 [\fIn\fP]\fB>>\fP\fIword\fP
2612 .SS Redirecting Standard Output and Standard Error
2616 standard output (file descriptor 1) and
2617 the standard error output (file descriptor 2)
2618 to be redirected to the file whose name is the
2621 with this construct.
2623 There are two formats for redirecting standard output and
2634 Of the two forms, the first is preferred.
2635 This is semantically equivalent to
2638 \fB>\fP\fIword\fP 2\fB>&\fP1
2642 This type of redirection instructs the shell to read input from the
2643 current source until a line containing only
2645 (with no trailing blanks)
2647 the lines read up to that point are then used as the standard
2648 input for a command.
2650 The format of here-documents is as follows:
2654 \fB<<\fP[\fB\-\fP]\fIword\fP
2655 \fIhere\-document\fP
2660 No parameter expansion, command substitution, pathname
2661 expansion, or arithmetic expansion is performed on
2663 If any characters in
2667 is the result of quote removal on
2669 and the lines in the here-document are not expanded.
2670 If \fIword\fP is unquoted,
2671 all lines of the here-document are subjected to parameter expansion,
2672 command substitution, and arithmetic expansion. In the latter
2677 must be used to quote the characters
2683 If the redirection operator is
2685 then all leading tab characters are stripped from input lines and the
2689 here-documents within shell scripts to be indented in a
2691 .SS "Duplicating File Descriptors"
2693 The redirection operator
2696 [\fIn\fP]\fB<&\fP\fIword\fP
2699 is used to duplicate input file descriptors.
2702 expands to one or more digits, the file descriptor denoted by
2704 is made to be a copy of that file descriptor.
2707 do not specify a file descriptor open for input, a redirection error occurs.
2716 is not specified, the standard input (file descriptor 0) is used.
2721 [\fIn\fP]\fB>&\fP\fIword\fP
2724 is used similarly to duplicate output file descriptors. If
2726 is not specified, the standard output (file descriptor 1) is used.
2729 do not specify a file descriptor open for output, a redirection error occurs.
2730 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
2731 expand to one or more digits, the standard output and standard
2732 error are redirected as described previously.
2733 .SS "Opening File Descriptors for Reading and Writing"
2735 The redirection operator
2738 [\fIn\fP]\fB<>\fP\fIword\fP
2741 causes the file whose name is the expansion of
2743 to be opened for both reading and writing on file descriptor
2745 or on file descriptor 0 if
2747 is not specified. If the file does not exist, it is created.
2749 Aliases allow a string to be substituted for a word when it is used
2750 as the first word of a simple command.
2751 The shell maintains a list of
2753 that may be set and unset with the
2757 builtin commands (see
2759 .B SHELL BUILTIN COMMANDS
2761 The first word of each command, if unquoted,
2762 is checked to see if it has an
2763 alias. If so, that word is replaced by the text of the alias.
2764 The alias name and the replacement text may contain any valid
2765 shell input, including the
2767 listed above, with the exception that the alias name may not
2768 contain \fI=\fP. The first word of the replacement text is tested
2769 for aliases, but a word that is identical to an alias being expanded
2770 is not expanded a second time. This means that one may alias
2776 does not try to recursively expand the replacement text.
2777 If the last character of the alias value is a
2779 then the next command
2780 word following the alias is also checked for alias expansion.
2782 Aliases are created and listed with the
2784 command, and removed with the
2788 There is no mechanism for using arguments in the replacement text.
2789 If arguments are needed, a shell function should be used.
2791 Aliases are not expanded when the shell is not interactive, unless
2794 shell option is set using
2796 (see the description of
2800 \fBSHELL BUILTIN COMMANDS\fP
2803 The rules concerning the definition and use of aliases are
2806 always reads at least one complete line
2807 of input before executing any
2808 of the commands on that line. Aliases are expanded when a
2809 command is read, not when it is executed. Therefore, an
2810 alias definition appearing on the same line as another
2811 command does not take effect until the next line of input is read.
2812 The commands following the alias definition
2813 on that line are not affected by the new alias.
2814 This behavior is also an issue when functions are executed.
2815 Aliases are expanded when a function definition is read,
2816 not when the function is executed, because a function definition
2817 is itself a compound command. As a consequence, aliases
2818 defined in a function are not available until after that
2819 function is executed. To be safe, always put
2820 alias definitions on a separate line, and do not use
2822 in compound commands.
2824 For almost every purpose, aliases are superseded by
2827 A shell function, defined as described above under
2829 .BR "SHELL GRAMMAR" ,
2830 stores a series of commands for later execution.
2831 Functions are executed in the context of the
2832 current shell; no new process is created to interpret
2833 them (contrast this with the execution of a shell script).
2834 When a function is executed, the arguments to the
2835 function become the positional parameters
2836 during its execution. The special parameter
2838 is updated to reflect the change. Positional parameter 0
2839 is unchanged. All other aspects of the shell execution
2840 environment are identical between a function and its caller
2841 with the exception that the
2844 trap (see the description of the
2848 .B SHELL BUILTIN COMMANDS
2849 below) is not inherited.
2851 Variables local to the function may be declared with the
2853 builtin command. Ordinarily, variables and their values
2854 are shared between the function and its caller.
2856 If the builtin command
2858 is executed in a function, the function completes and
2859 execution resumes with the next command after the function
2860 call. When a function completes, the values of the
2861 positional parameters and the special parameter
2863 are restored to the values they had prior to the function's
2866 Function names and definitions may be listed with the
2872 builtin commands. The
2878 will list the function names only.
2879 Functions may be exported so that subshells
2880 automatically have them defined with the
2886 Functions may be recursive. No limit is imposed on the number
2888 .SH "ARITHMETIC EVALUATION"
2889 The shell allows arithmetic expressions to be evaluated, under
2890 certain circumstances (see the \fBlet\fP builtin command and
2891 \fBArithmetic Expansion\fP).
2892 Evaluation is done in long integers with no check for overflow,
2893 though division by 0 is trapped and flagged as an error.
2894 The following list of operators is grouped into levels of
2895 equal-precedence operators.
2896 The levels are listed in order of decreasing precedence.
2901 unary minus and plus
2904 logical and bitwise negation
2910 multiplication, division, remainder
2913 addition, subtraction
2916 left and right bitwise shifts
2922 equality and inequality
2928 bitwise exclusive OR
2939 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
2940 conditional evaluation
2942 .B = *= /= %= += \-= <<= >>= &= ^= |=
2946 Shell variables are allowed as operands; parameter expansion is
2947 performed before the expression is evaluated.
2948 The value of a parameter is coerced to a long integer within
2949 an expression. A shell variable need not have its integer attribute
2950 turned on to be used in an expression.
2952 Constants with a leading 0 are interpreted as octal numbers.
2953 A leading 0x or 0X denotes hexadecimal.
2954 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
2955 is a decimal number between 2 and 64 representing the arithmetic
2956 base, and \fIn\fP is a number in that base.
2957 If \fIbase\fP is omitted, then base 10 is used.
2958 The digits greater than 9 are represented by the lowercase letters,
2959 the uppercase letters, _, and @, in that order.
2960 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
2961 letters may be used interchangably to represent numbers between 10
2964 Operators are evaluated in order of precedence. Sub-expressions in
2965 parentheses are evaluated first and may override the precedence
2967 .SH "CONDITIONAL EXPRESSIONS"
2968 Conditional expressions are used by the \fB[[\fP compound command and
2969 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
2970 and perform string and arithmetic comparisons.
2971 Expressions are formed from the following unary or binary primaries.
2972 If any \fIfile\fP argument to one of the primaries is of the form
2973 /dev/fd/\fIn\fP, then file descriptor \fIn\fP is checked.
2978 True if \fIfile\fP exists.
2981 True if \fIfile\fP exists and is a block special file.
2984 True if \fIfile\fP exists and is a character special file.
2987 True if \fIfile\fP exists and is a directory.
2990 True if \fIfile\fP exists.
2993 True if \fIfile\fP exists and is a regular file.
2996 True if \fIfile\fP exists and is set-group-id.
2999 True if \fIfile\fP exists and is a symbolic link.
3002 True if \fIfile\fP exists and its ``sticky'' bit is set.
3005 True if \fIfile\fP exists and is a named pipe (FIFO).
3008 True if \fIfile\fP exists and is readable.
3011 True if \fIfile\fP exists and has a size greater than zero.
3014 True if file descriptor
3016 is open and refers to a terminal.
3019 True if \fIfile\fP exists and its set-user-id bit is set.
3022 True if \fIfile\fP exists and is writable.
3025 True if \fIfile\fP exists and is executable.
3028 True if \fIfile\fP exists and is owned by the effective user id.
3031 True if \fIfile\fP exists and is owned by the effective group id.
3034 True if \fIfile\fP exists and is a symbolic link.
3037 True if \fIfile\fP exists and is a socket.
3040 True if \fIfile\fP exists and has been modified since it was last read.
3042 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3043 True if \fIfile1\fP is newer (according to
3044 modification date) than \fIfile2\fP.
3046 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3047 True if \fIfile1\fP is older than \fIfile2\fP.
3049 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3050 True if \fIfile1\fP and \fIfile2\fP have the same device and
3053 .B \-o \fIoptname\fP
3054 True if shell option
3057 See the list of options under the description of the
3064 True if the length of \fIstring\fP is zero.
3069 True if the length of
3073 \fIstring1\fP \fB==\fP \fIstring2\fP
3074 True if the strings are equal. \fB=\fP may be used in place of
3077 \fIstring1\fP \fB!=\fP \fIstring2\fP
3078 True if the strings are not equal.
3080 \fIstring1\fP \fB<\fP \fIstring2\fP
3081 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
3082 in the current locale.
3084 \fIstring1\fP \fB>\fP \fIstring2\fP
3085 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
3086 in the current locale.
3088 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
3099 These arithmetic binary operators return true if \fIarg1\fP
3100 is equal to, not equal to, less than, less than or equal to,
3101 greater than, or greater than or equal to \fIarg2\fP, respectively.
3105 may be positive or negative integers.
3107 .SH "SIMPLE COMMAND EXPANSION"
3108 When a simple command is executed, the shell performs the following
3109 expansions, assignments, and redirections, from left to right.
3111 The words that the parser has marked as variable assignments (those
3112 preceding the command name) and redirections are saved for later
3115 The words that are not variable assignments or redirections are
3116 expanded. If any words remain after expansion, the first word
3117 is taken to be the name of the command and the remaining words are
3120 Redirections are performed as described above under
3124 The text after the \fB=\fP in each variable assignment undergoes tilde
3125 expansion, parameter expansion, command substitution, arithmetic expansion,
3126 and quote removal before being assigned to the variable.
3128 If no command name results, the variable assignments affect the current
3129 shell environment. Otherwise, the variables are added to the environment
3130 of the executed command and do not affect the current shell environment.
3131 If any of the assignments attempts to assign a value to a readonly variable,
3132 an error occurs, and the command exits with a non-zero status.
3134 If no command name results, redirections are performed, but do not
3135 affect the current shell environment. A redirection error causes the
3136 command to exit with a non-zero status.
3138 If there is a command name left after expansion, execution proceeds as
3139 described below. Otherwise, the command exits. If one of the expansions
3140 contained a command substitution, the exit status of the command is
3141 the exit status of the last command substitution performed. If there
3142 were no command substitutions, the command exits with a status of zero.
3143 .SH "COMMAND EXECUTION"
3144 After a command has been split into words, if it results in a
3145 simple command and an optional list of arguments, the following
3148 If the command name contains no slashes, the shell attempts to
3149 locate it. If there exists a shell function by that name, that
3150 function is invoked as described above in
3153 If the name does not match a function, the shell searches for
3154 it in the list of shell builtins. If a match is found, that
3157 If the name is neither a shell function nor a builtin,
3158 and contains no slashes,
3160 searches each element of the
3163 for a directory containing an executable file by that name.
3165 uses a hash table to remember the full file names of executable
3170 .B "SHELL BUILTIN COMMANDS"
3172 A full search of the directories in
3175 is performed only if the command is not found in the hash table.
3176 If the search is unsuccessful, the shell prints an error
3177 message and returns an exit status of 127.
3179 If the search is successful, or if the command name contains
3180 one or more slashes, the shell executes the named program in a
3181 separate execution environment.
3182 Argument 0 is set to the name given, and the remaining arguments
3183 to the command are set to the arguments given, if any.
3185 If this execution fails because the file is not in executable
3186 format, and the file is not a directory, it is assumed to be
3187 a \fIshell script\fP, a file
3188 containing shell commands. A subshell is spawned to execute
3189 it. This subshell reinitializes itself, so
3190 that the effect is as if a new shell had been invoked
3191 to handle the script, with the exception that the locations of
3192 commands remembered by the parent (see
3196 \fBSHELL BUILTIN COMMANDS\fP)
3197 are retained by the child.
3199 If the program is a file beginning with
3201 the remainder of the first line specifies an interpreter
3202 for the program. The shell executes the
3203 specified interpreter on operating systems that do not
3204 handle this executable format themselves. The arguments to the
3205 interpreter consist of a single optional argument following the
3206 interpreter name on the first line of the program, followed
3207 by the name of the program, followed by the command
3209 .SH COMMAND EXECUTION ENVIRONMENT
3210 The shell has an \fIexecution environment\fP, which consists of the
3214 open files inherited by the shell at invocation, as modified by
3215 redirections supplied to the \fBexec\fP builtin
3217 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
3218 \fBpopd\fP, or inherited by the shell at invocation
3220 the file creation mode mask as set by \fBumask\fP or inherited from
3223 current traps set by \fBtrap\fP
3225 shell parameters that are set by variable assignment or with \fBset\fP
3226 or inherited from the shell's parent in the environment
3228 shell functions defined during execution or inherited from the shell's
3229 parent in the environment
3231 options enabled at invocation (either by default or with command-line
3232 arguments) or by \fBset\fP
3234 options enabled by \fBshopt\fP
3236 shell aliases defined with \fBalias\fP
3238 various process IDs, including those of background jobs, the value
3239 of \fB$$\fP, and the value of \fB$PPID\fP
3241 When a simple command other than a builtin or shell function
3242 is to be executed, it
3243 is invoked in a separate execution environment that consists of
3244 the following. Unless otherwise noted, the values are inherited
3248 the shell's open files, plus any modifications and additions specified
3249 by redirections to the command
3251 the current working directory
3253 the file creation mode mask
3255 shell variables marked for export, along with variables exported for
3256 the command, passed in the environment
3258 traps caught by the shell are reset to the values the inherited
3259 from the shell's parent, and traps ignored by the shell are ignored
3261 A command invoked in this separate environment cannot affect the
3262 shell's execution environment.
3264 Command substitution and asynchronous commands are invoked in a
3265 subshell environment that is a duplicate of the shell environment,
3266 except that traps caught by the shell are reset to the values
3267 that the shell inherited from its parent at invocation. Builtin
3268 commands that are invoked as part of a pipeline are also executed in a
3269 subshell environment. Changes made to the subshell environment
3270 cannot affect the shell's execution environment.
3272 When a program is invoked it is given an array of strings
3276 \fIname\fP\-\fIvalue\fP pairs, of the form
3277 .IR "name\fR=\fPvalue" .
3279 The shell allows you to manipulate the environment in several
3280 ways. On invocation, the shell scans its own environment and
3281 creates a parameter for each name found, automatically marking
3284 to child processes. Executed commands inherit the environment.
3289 commands allow parameters and functions to be added to and
3290 deleted from the environment. If the value of a parameter
3291 in the environment is modified, the new value becomes part
3292 of the environment, replacing the old. The environment
3293 inherited by any executed command consists of the shell's
3294 initial environment, whose values may be modified in the shell,
3295 less any pairs removed by the
3297 command, plus any additions via the
3303 The environment for any
3305 or function may be augmented temporarily by prefixing it with
3306 parameter assignments, as described above in
3309 These assignment statements affect only the environment seen
3314 option is set (see the
3316 builtin command below), then
3318 parameter assignments are placed in the environment for a command,
3319 not just those that precede the command name.
3323 invokes an external command, the variable
3325 is set to the full file name of the command and passed to that
3326 command in its environment.
3328 For the shell's purposes, a command which exits with a
3329 zero exit status has succeeded. An exit status of zero
3330 indicates success. A non-zero exit status indicates failure.
3331 When a command terminates on a fatal signal, \fBbash\fP uses
3332 the value of 128+\fBsignal\fP as the exit status.
3334 If a command is not found, the child process created to
3335 execute it returns a status of 127. If a command is found
3336 but is not executable, the return status is 126.
3338 If a command fails because of an error during expansion or redirection,
3339 the exit status is greater than zero.
3341 Shell builtin commands return a status of 0 (\fItrue\fP) if
3342 successful, and non-zero (\fIfalse\fP) if an error occurs
3344 All builtins return an exit status of 2 to indicate incorrect usage.
3346 \fBBash\fP itself returns the exit status of the last command
3347 executed, unless a syntax error occurs, in which case it exits
3348 with a non-zero value. See also the \fBexit\fP builtin
3351 When \fBbash\fP is interactive, in the absence of any traps, it ignores
3354 (so that \fBkill 0\fP does not kill an interactive shell),
3358 is caught and handled (so that the \fBwait\fP builtin is interruptible).
3359 In all cases, \fBbash\fP ignores
3362 If job control is in effect,
3373 Synchronous jobs started by \fBbash\fP have signal handlers
3374 set to the values inherited by the shell from its parent.
3375 When job control is not in effect, asynchronous commands
3383 Commands run as a result of command substitution ignore the
3384 keyboard-generated job control signals
3393 The shell exits by default upon receipt of a
3396 Before exiting, it resends the
3399 to all jobs, running or stopped.
3400 Stopped jobs are sent
3403 to ensure that they receive the
3406 To prevent the shell from
3407 sending the signal to a particular job, it should be removed from the
3412 .B "SHELL BUILTIN COMMANDS"
3422 shell option has been set with
3428 to all jobs when an interactive login shell exits.
3430 When \fBbash\fP receives a signal for which a trap has been set while
3431 waiting for a command to complete, the trap will not be executed until
3432 the command completes.
3433 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
3434 builtin, the reception of a signal for which a trap has been set will
3435 cause the \fBwait\fP builtin to return immediately with an exit status
3436 greater than 128, immediately after which the trap is executed.
3439 refers to the ability to selectively stop (\fIsuspend\fP)
3440 the execution of processes and continue (\fIresume\fP)
3441 their execution at a later point. A user typically employs
3442 this facility via an interactive interface supplied jointly
3443 by the system's terminal driver and
3446 The shell associates a
3448 with each pipeline. It keeps a table of currently executing
3449 jobs, which may be listed with the
3453 starts a job asynchronously (in the
3455 it prints a line that looks like:
3461 indicating that this job is job number 1 and that the process ID
3462 of the last process in the pipeline associated with this job is 25647.
3463 All of the processes in a single pipeline are members of the same job.
3467 abstraction as the basis for job control.
3469 To facilitate the implementation of the user interface to job
3470 control, the system maintains the notion of a \fIcurrent terminal
3471 process group ID\fP. Members of this process group (processes whose
3472 process group ID is equal to the current terminal process group ID)
3473 receive keyboard-generated signals such as
3476 These processes are said to be in the
3479 processes are those whose process group ID differs from the terminal's;
3480 such processes are immune to keyboard-generated signals.
3481 Only foreground processes are allowed to read from or write to the
3482 terminal. Background processes which attempt to read from (write to) the
3485 .B SIGTTIN (SIGTTOU)
3486 signal by the terminal driver,
3487 which, unless caught, suspends the process.
3489 If the operating system on which
3494 allows you to use it.
3497 character (typically
3499 Control-Z) while a process is running
3500 causes that process to be stopped and returns you to
3503 .I "delayed suspend"
3504 character (typically
3506 Control-Y) causes the process to be stopped when it
3507 attempts to read input from the terminal, and control to
3510 The user may then manipulate the state of this job, using the
3512 command to continue it in the background, the
3514 command to continue it in the foreground, or
3517 command to kill it. A \fB^Z\fP takes effect immediately,
3518 and has the additional side effect of causing pending output
3519 and typeahead to be discarded.
3521 There are a number of ways to refer to a job in the shell.
3524 introduces a job name. Job number
3526 may be referred to as
3528 A job may also be referred to using a prefix of the name used to
3529 start it, or using a substring that appears in its command line.
3534 job. If a prefix matches more than one job,
3536 reports an error. Using
3538 on the other hand, refers to any job containing the string
3540 in its command line. If the substring matches more than one job,
3542 reports an error. The symbols
3546 refer to the shell's notion of the
3548 which is the last job stopped while it was in
3549 the foreground or started in the background.
3552 may be referenced using
3554 In output pertaining to jobs (e.g., the output of the
3556 command), the current job is always flagged with a
3558 and the previous job with a
3561 Simply naming a job can be used to bring it into the
3566 bringing job 1 from the background into the foreground.
3569 resumes job 1 in the background, equivalent to
3572 The shell learns immediately whenever a job changes state.
3575 waits until it is about to print a prompt before reporting
3576 changes in a job's status so as to not interrupt
3577 any other output. If the
3584 reports such changes immediately.
3586 If an attempt to exit
3588 is made while jobs are stopped, the shell prints a warning message. The
3590 command may then be used to inspect their status.
3591 If a second attempt to exit is made without an intervening command,
3592 the shell does not print another warning, and the stopped
3593 jobs are terminated.
3595 When executing interactively,
3597 displays the primary prompt
3600 when it is ready to read a command, and the secondary prompt
3603 when it needs more input to complete a command.
3605 allows these prompt strings to be customized by inserting a number of
3606 backslash-escaped special characters that are decoded as follows:
3611 an ASCII bell character (07)
3614 the date in "Weekday Month Date" format (e.g., "Tue May 26")
3617 an ASCII escape character (033)
3620 the hostname up to the first `.'
3632 the name of the shell, the basename of
3634 (the portion following the final slash)
3637 the current time in 24-hour HH:MM:SS format
3640 the current time in 12-hour HH:MM:SS format
3643 the current time in 12-hour am/pm format
3646 the username of the current user
3649 the version of \fBbash\fP (e.g., 2.00)
3652 the release of \fBbash\fP, version + patchlevel (e.g., 2.00.0)
3655 the current working directory
3658 the basename of the current working directory
3661 the history number of this command
3664 the command number of this command
3667 if the effective UID is 0, a
3673 the character corresponding to the octal number \fInnn\fP
3679 begin a sequence of non-printing characters, which could be used to
3680 embed a terminal control sequence into the prompt
3683 end a sequence of non-printing characters
3687 The command number and the history number are usually different:
3688 the history number of a command is its position in the history
3689 list, which may include commands restored from the history file
3693 below), while the command number is the position in the sequence
3694 of commands executed during the current shell session.
3695 After the string is decoded, it is expanded via
3696 parameter expansion, command substitution, arithmetic expansion,
3697 string expansion, and quote removal, subject to the value of the
3699 shell option (see the description of the
3703 .B "SHELL BUILTIN COMMANDS"
3706 This is the library that handles reading input when using an interactive
3709 option is given at shell invocation.
3710 By default, the line editing commands are similar to those of emacs.
3711 A vi-style line editing interface is also available.
3712 To turn off line editing after the shell is running, use the
3720 .B SHELL BUILTIN COMMANDS
3722 .SS "Readline Notation"
3724 In this section, the emacs-style notation is used to denote
3725 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
3726 means Control\-N. Similarly,
3728 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
3731 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
3734 key. This makes ESC the \fImeta prefix\fP.
3735 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
3736 or press the Escape key
3737 then hold the Control key while pressing the
3741 Readline commands may be given numeric
3743 which normally act as a repeat count.
3744 Sometimes, however, it is the sign of the argument that is significant.
3745 Passing a negative argument to a command that acts in the forward
3746 direction (e.g., \fBkill\-line\fP) causes that command to act in a
3748 Commands whose behavior with arguments deviates from this are noted
3751 When a command is described as \fIkilling\fP text, the text
3752 deleted is saved for possible future retrieval
3753 (\fIyanking\fP). The killed text is saved in a
3754 \fIkill ring\fP. Consecutive kills cause the text to be
3755 accumulated into one unit, which can be yanked all at once.
3756 Commands which do not kill text separate the chunks of text
3758 .SS "Readline Initialization"
3760 Readline is customized by putting commands in an initialization
3761 file (the \fIinputrc\fP file).
3762 The name of this file is taken from the value of the
3765 variable. If that variable is unset, the default is
3767 When a program which uses the readline library starts up, the
3768 initialization file is read, and the key bindings and variables
3770 There are only a few basic constructs allowed in the
3771 readline initialization file.
3772 Blank lines are ignored.
3773 Lines beginning with a \fB#\fP are comments.
3774 Lines beginning with a \fB$\fP indicate conditional constructs.
3775 Other lines denote key bindings and variable settings.
3777 The default key-bindings may be changed with an
3780 Other programs that use this library may add their own commands
3783 For example, placing
3786 M\-Control\-u: universal\-argument
3790 C\-Meta\-u: universal\-argument
3794 would make M\-C\-u execute the readline command
3795 .IR universal\-argument .
3797 The following symbolic character names are recognized:
3809 In addition to command names, readline allows keys to be bound
3810 to a string that is inserted when the key is pressed (a \fImacro\fP).
3811 .SS "Readline Key Bindings"
3813 The syntax for controlling key bindings in the
3815 file is simple. All that is required is the name of the
3816 command or the text of a macro and a key sequence to which
3817 it should be bound. The name may be specified in one of two ways:
3818 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
3819 prefixes, or as a key sequence.
3820 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
3822 is the name of a key spelled out in English. For example:
3825 Control-u: universal\-argument
3827 Meta-Rubout: backward-kill-word
3829 Control-o: "> output"
3832 In the above example,
3834 is bound to the function
3835 .BR universal\-argument ,
3837 is bound to the function
3838 .BR backward\-kill\-word ,
3841 is bound to run the macro
3842 expressed on the right hand side (that is, to insert the text
3846 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
3850 above in that strings denoting
3851 an entire key sequence may be specified by placing the sequence
3852 within double quotes. Some GNU Emacs style key escapes can be
3853 used, as in the following example.
3856 "\eC\-u": universal\-argument
3858 "\eC\-x\eC\-r": re\-read\-init\-file
3860 "\ee[11~": "Function Key 1"
3865 is again bound to the function
3866 .BR universal\-argument .
3868 is bound to the function
3869 .BR re\-read\-init\-file ,
3872 is bound to insert the text
3873 .BR "Function Key 1" .
3874 The full set of GNU Emacs style escape sequences is
3898 In addition to the GNU Emacs style escape sequences, a second
3899 set of backslash escapes is available:
3928 the character whose ASCII code is the octal value \fInnn\fP
3929 (one to three digits)
3932 the character whose ASCII code is the hexadecimal value \fInnn\fP
3933 (one to three digits)
3937 When entering the text of a macro, single or double quotes must
3938 be used to indicate a macro definition.
3939 Unquoted text is assumed to be a function name.
3940 In the macro body, the backslash escapes described above are expanded.
3941 Backslash will quote any other character in the macro text,
3945 allows the current readline key bindings to be displayed or modified
3948 builtin command. The editing mode may be switched during interactive
3953 builtin command (see
3955 .B SHELL BUILTIN COMMANDS
3957 .SS "Readline Variables"
3959 Readline has variables that can be used to further customize its
3960 behavior. A variable may be set in the
3962 file with a statement of the form
3965 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
3968 Except where noted, readline variables can take the values
3972 The variables and their default values are:
3976 .B bell\-style (audible)
3977 Controls what happens when readline wants to ring the terminal bell.
3978 If set to \fBnone\fP, readline never rings the bell. If set to
3979 \fBvisible\fP, readline uses a visible bell if one is available.
3980 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
3982 .B comment\-begin (``#'')
3983 The string that is inserted when the
3986 command is executed.
3987 This command is bound to
3989 in emacs mode and to
3993 .B completion\-ignore\-case (Off)
3994 If set to \fBOn\fP, readline performs filename matching and completion
3995 in a case\-insensitive fashion.
3997 .B completion\-query\-items (100)
3998 This determines when the user is queried about viewing
3999 the number of possible completions
4000 generated by the \fBpossible\-completions\fP command.
4001 It may be set to any integer value greater than or equal to
4002 zero. If the number of possible completions is greater than
4003 or equal to the value of this variable, the user is asked whether
4004 or not he wishes to view them; otherwise they are simply listed
4007 .B convert\-meta (On)
4008 If set to \fBOn\fP, readline will convert characters with the
4009 eighth bit set to an ASCII key sequence
4010 by stripping the eighth bit and prepending an
4011 escape character (in effect, using escape as the \fImeta prefix\fP).
4013 .B disable\-completion (Off)
4014 If set to \fBOn\fP, readline will inhibit word completion. Completion
4015 characters will be inserted into the line as if they had been
4016 mapped to \fBself-insert\fP.
4018 .B editing\-mode (emacs)
4019 Controls whether readline begins with a set of key bindings similar
4020 to \fIemacs\fP or \fIvi\fP.
4022 can be set to either
4027 .B enable\-keypad (Off)
4028 When set to \fBOn\fP, readline will try to enable the application
4029 keypad when it is called. Some systems need this to enable the
4032 .B expand\-tilde (Off)
4033 If set to \fBon\fP, tilde expansion is performed when readline
4034 attempts word completion.
4036 .B horizontal\-scroll\-mode (Off)
4037 When set to \fBOn\fP, makes readline use a single line for display,
4038 scrolling the input horizontally on a single screen line when it
4039 becomes longer than the screen width rather than wrapping to a new line.
4041 .B input\-meta (Off)
4042 If set to \fBOn\fP, readline will enable eight-bit input (that is,
4043 it will not strip the high bit from the characters it reads),
4044 regardless of what the terminal claims it can support. The name
4046 is a synonym for this variable.
4048 .B isearch\-terminators (``C\-[C\-J'')
4049 The string of characters that should terminate an incremental
4050 search without subsequently executing the character as a command.
4051 If this variable has not been given a value, the characters
4052 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
4055 Set the current readline keymap. The set of valid keymap names is
4056 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4059 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4060 equivalent to \fIemacs\-standard\fP. The default value is
4064 also affects the default keymap.
4066 .B mark\-directories (On)
4067 If set to \fBOn\fP, completed directory names have a slash
4070 .B mark\-modified\-lines (Off)
4071 If set to \fBOn\fP, history lines that have been modified are displayed
4072 with a preceding asterisk (\fB*\fP).
4074 .B output\-meta (Off)
4075 If set to \fBOn\fP, readline will display characters with the
4076 eighth bit set directly rather than as a meta-prefixed escape
4079 .B print\-completions\-horizontally (Off)
4080 If set to \fBOn\fP, readline will display completions with matches
4081 sorted horizontally in alphabetical order, rather than down the screen.
4083 .B show\-all\-if\-ambiguous (Off)
4084 This alters the default behavior of the completion functions. If
4087 words which have more than one possible completion cause the
4088 matches to be listed immediately instead of ringing the bell.
4090 .B visible\-stats (Off)
4091 If set to \fBOn\fP, a character denoting a file's type as reported
4092 by \fIstat\fP(2) is appended to the filename when listing possible
4095 .SS "Readline Conditional Constructs"
4097 Readline implements a facility similar in spirit to the conditional
4098 compilation features of the C preprocessor which allows key
4099 bindings and variable settings to be performed as the result
4100 of tests. There are four parser directives used.
4104 construct allows bindings to be made based on the
4105 editing mode, the terminal being used, or the application using
4106 readline. The text of the test extends to the end of the line;
4107 no characters are required to isolate it.
4110 The \fBmode=\fP form of the \fB$if\fP directive is used to test
4111 whether readline is in emacs or vi mode.
4112 This may be used in conjunction
4113 with the \fBset keymap\fP command, for instance, to set bindings in
4114 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
4115 readline is starting out in emacs mode.
4117 The \fBterm=\fP form may be used to include terminal-specific
4118 key bindings, perhaps to bind the key sequences output by the
4119 terminal's function keys. The word on the right side of the
4121 is tested against the both full name of the terminal and the portion
4122 of the terminal name before the first \fB\-\fP. This allows
4129 .IP \fBapplication\fP
4130 The \fBapplication\fP construct is used to include
4131 application-specific settings. Each program using the readline
4132 library sets the \fIapplication name\fP, and an initialization
4133 file can test for a particular value.
4134 This could be used to bind key sequences to functions useful for
4135 a specific program. For instance, the following command adds a
4136 key sequence that quotes the current or previous word in Bash:
4141 # Quote the current or previous word
4142 "\eC\-xq": "\eeb\e"\eef\e""
4148 This command, as seen in the previous example, terminates an
4151 Commands in this branch of the \fB$if\fP directive are executed if
4154 This directive takes a single filename as an argument and reads commands
4155 and bindings from that file. For example, the following directive
4156 would read \fI/etc/inputrc\fP:
4160 \fB$include\fP \^ \fI/etc/inputrc\fP
4165 Readline provides commands for searching through the command history
4169 below) for lines containing a specified string.
4170 There are two search modes:
4173 .IR non-incremental .
4175 Incremental searches begin before the user has finished typing the
4177 As each character of the search string is typed, readline displays
4178 the next entry from the history matching the string typed so far.
4179 An incremental search requires only as many characters as needed to
4180 find the desired history entry.
4181 The characters present in the value of the \fIisearch-terminators\fP
4182 variable are used to terminate an incremental search.
4183 If that variable has not been assigned a value the Escape and
4184 Control-J characters will terminate an incremental search.
4185 Control-G will abort an incremental search and restore the original
4187 When the search is terminated, the history entry containing the
4188 search string becomes the current line.
4189 To find other matching entries in the history list, type Control-S or
4190 Control-R as appropriate.
4191 This will search backward or forward in the history for the next
4192 entry matching the search string typed so far.
4193 Any other key sequence bound to a readline command will terminate
4194 the search and execute that command.
4195 For instance, a \fInewline\fP will terminate the search and accept
4196 the line, thereby executing the command from the history list.
4198 Non-incremental searches read the entire search string before starting
4199 to search for matching history lines. The search string may be
4200 typed by the user or be part of the contents of the current line.
4201 .SS "Readline Command Names"
4203 The following is a list of the names of the commands and the default
4204 key sequences to which they are bound.
4205 Command names without an accompanying key sequence are unbound by default.
4206 .SS Commands for Moving
4210 .B beginning\-of\-line (C\-a)
4211 Move to the start of the current line.
4213 .B end\-of\-line (C\-e)
4214 Move to the end of the line.
4216 .B forward\-char (C\-f)
4217 Move forward a character.
4219 .B backward\-char (C\-b)
4220 Move back a character.
4222 .B forward\-word (M\-f)
4223 Move forward to the end of the next word. Words are composed of
4224 alphanumeric characters (letters and digits).
4226 .B backward\-word (M\-b)
4227 Move back to the start of this, or the previous, word. Words are
4228 composed of alphanumeric characters (letters and digits).
4230 .B clear\-screen (C\-l)
4231 Clear the screen leaving the current line at the top of the screen.
4232 With an argument, refresh the current line without clearing the
4235 .B redraw\-current\-line
4236 Refresh the current line.
4238 .SS Commands for Manipulating the History
4242 .B accept\-line (Newline, Return)
4243 Accept the line regardless of where the cursor is. If this line is
4244 non-empty, add it to the history list according to the state of the
4247 variable. If the line is a modified history
4248 line, then restore the history line to its original state.
4250 .B previous\-history (C\-p)
4251 Fetch the previous command from the history list, moving back in
4254 .B next\-history (C\-n)
4255 Fetch the next command from the history list, moving forward in the
4258 .B beginning\-of\-history (M\-<)
4259 Move to the first line in the history.
4261 .B end\-of\-history (M\->)
4262 Move to the end of the input history, i.e., the line currently being
4265 .B reverse\-search\-history (C\-r)
4266 Search backward starting at the current line and moving `up' through
4267 the history as necessary. This is an incremental search.
4269 .B forward\-search\-history (C\-s)
4270 Search forward starting at the current line and moving `down' through
4271 the history as necessary. This is an incremental search.
4273 .B non\-incremental\-reverse\-search\-history (M\-p)
4274 Search backward through the history starting at the current line
4275 using a non-incremental search for a string supplied by the user.
4277 .B non\-incremental\-forward\-search\-history (M\-n)
4278 Search forward through the history using a non-incremental search for
4279 a string supplied by the user.
4281 .B history\-search\-forward
4282 Search forward through the history for the string of characters
4283 between the start of the current line and the current cursor
4284 position (the \fIpoint\fP).
4285 This is a non-incremental search.
4287 .B history\-search\-backward
4288 Search backward through the history for the string of characters
4289 between the start of the current line and the point.
4290 This is a non-incremental search.
4292 .B yank\-nth\-arg (M\-C\-y)
4293 Insert the first argument to the previous command (usually
4294 the second word on the previous line) at point (the current
4295 cursor position). With an argument
4297 insert the \fIn\fPth word from the previous command (the words
4298 in the previous command begin with word 0). A negative argument
4299 inserts the \fIn\fPth word from the end of the previous command.
4302 yank\-last\-arg (M\-.\^, M\-_\^)
4303 Insert the last argument to the previous command (the last word of
4304 the previous history entry). With an argument,
4305 behave exactly like \fByank\-nth\-arg\fP.
4306 Successive calls to \fByank\-last\-arg\fP move back through the history
4307 list, inserting the last argument of each line in turn.
4309 .B shell\-expand\-line (M\-C\-e)
4310 Expand the line as the shell does. This
4311 performs alias and history expansion as well as all of the shell
4312 word expansions. See
4314 .B HISTORY EXPANSION
4315 below for a description of history expansion.
4317 .B history\-expand\-line (M\-^)
4318 Perform history expansion on the current line.
4321 .B HISTORY EXPANSION
4322 below for a description of history expansion.
4325 Perform history expansion on the current line and insert a space.
4328 .B HISTORY EXPANSION
4329 below for a description of history expansion.
4331 .B alias\-expand\-line
4332 Perform alias expansion on the current line.
4336 above for a description of alias expansion.
4338 .B history\-and\-alias\-expand\-line
4339 Perform history and alias expansion on the current line.
4341 .B insert\-last\-argument (M\-.\^, M\-_\^)
4342 A synonym for \fByank\-last\-arg\fP.
4344 .B operate\-and\-get\-next (C\-o)
4345 Accept the current line for execution and fetch the next line
4346 relative to the current line from the history for editing. Any
4347 argument is ignored.
4349 .SS Commands for Changing Text
4353 .B delete\-char (C\-d)
4354 Delete the character under the cursor. If point is at the
4355 beginning of the line, there are no characters in the line, and
4356 the last character typed was not bound to \fBdelete\-char\fP,
4361 .B backward\-delete\-char (Rubout)
4362 Delete the character behind the cursor. When given a numeric argument,
4363 save the deleted text on the kill ring.
4365 .B forward\-backward\-delete\-char
4366 Delete the character under the cursor, unless the cursor is at the
4367 end of the line, in which case the character behind the cursor is
4368 deleted. By default, this is not bound to a key.
4370 .B quoted\-insert (C\-q, C\-v)
4371 Add the next character typed to the line verbatim. This is
4372 how to insert characters like \fBC\-q\fP, for example.
4374 .B tab\-insert (C\-v TAB)
4375 Insert a tab character.
4377 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
4378 Insert the character typed.
4380 .B transpose\-chars (C\-t)
4381 Drag the character before point forward over the character at point.
4382 Point moves forward as well. If point is at the end of the line, then
4383 transpose the two characters before point. Negative arguments don't work.
4385 .B transpose\-words (M\-t)
4386 Drag the word behind the cursor past the word in front of the cursor
4387 moving the cursor over that word as well.
4389 .B upcase\-word (M\-u)
4390 Uppercase the current (or following) word. With a negative argument,
4391 uppercase the previous word, but do not move point.
4393 .B downcase\-word (M\-l)
4394 Lowercase the current (or following) word. With a negative argument,
4395 lowercase the previous word, but do not move point.
4397 .B capitalize\-word (M\-c)
4398 Capitalize the current (or following) word. With a negative argument,
4399 capitalize the previous word, but do not move point.
4401 .SS Killing and Yanking
4405 .B kill\-line (C\-k)
4406 Kill the text from the current cursor position to the end of the line.
4408 .B backward\-kill\-line (C\-x Rubout)
4409 Kill backward to the beginning of the line.
4411 .B unix\-line\-discard (C\-u)
4412 Kill backward from point to the beginning of the line.
4413 The killed text is saved on the kill-ring.
4414 \" There is no real difference between this and backward-kill-line
4416 .B kill\-whole\-line
4417 Kill all characters on the current line, no matter where the
4420 .B kill\-word (M\-d)
4421 Kill from the cursor to the end of the current word, or if between
4422 words, to the end of the next word. Word boundaries are the same as
4423 those used by \fBforward\-word\fP.
4425 .B backward\-kill\-word (M\-Rubout)
4426 Kill the word behind the cursor. Word boundaries are the same as
4427 those used by \fBbackward\-word\fP.
4429 .B unix\-word\-rubout (C\-w)
4430 Kill the word behind the cursor, using white space as a word boundary.
4431 The word boundaries are different from \fBbackward\-kill\-word\fP.
4433 .B delete\-horizontal\-space (M\-\e)
4434 Delete all spaces and tabs around point.
4437 Kill the text between the point and \fImark\fP (saved cursor position).
4438 This text is referred to as the \fIregion\fP.
4440 .B copy\-region\-as\-kill
4441 Copy the text in the region to the kill buffer.
4443 .B copy\-backward\-word
4444 Copy the word before point to the kill buffer.
4445 The word boundaries are the same as \fBbackward\-word\fP.
4447 .B copy\-forward\-word
4448 Copy the word following point to the kill buffer.
4449 The word boundaries are the same as \fBforward\-word\fP.
4452 Yank the top of the kill ring into the buffer at the cursor.
4455 Rotate the kill ring, and yank the new top. Only works following
4460 .SS Numeric Arguments
4464 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
4465 Add this digit to the argument already accumulating, or start a new
4466 argument. M\-\- starts a negative argument.
4468 .B universal\-argument
4469 This is another way to specify an argument.
4470 If this command is followed by one or more digits, optionally with a
4471 leading minus sign, those digits define the argument.
4472 If the command is followed by digits, executing
4473 .B universal\-argument
4474 again ends the numeric argument, but is otherwise ignored.
4475 As a special case, if this command is immediately followed by a
4476 character that is neither a digit or minus sign, the argument count
4477 for the next command is multiplied by four.
4478 The argument count is initially one, so executing this function the
4479 first time makes the argument count four, a second time makes the
4480 argument count sixteen, and so on.
4487 Attempt to perform completion on the text before point.
4489 attempts completion treating the text as a variable (if the
4490 text begins with \fB$\fP), username (if the text begins with
4491 \fB~\fP), hostname (if the text begins with \fB@\fP), or
4492 command (including aliases and functions) in turn. If none
4493 of these produces a match, filename completion is attempted.
4495 .B possible\-completions (M\-?)
4496 List the possible completions of the text before point.
4498 .B insert\-completions (M\-*)
4499 Insert all completions of the text before point
4500 that would have been generated by
4501 \fBpossible\-completions\fP.
4504 Similar to \fBcomplete\fP, but replaces the word to be completed
4505 with a single match from the list of possible completions.
4506 Repeated execution of \fBmenu\-complete\fP steps through the list
4507 of possible completions, inserting each match in turn.
4508 At the end of the list of completions, the bell is rung and the
4509 original text is restored.
4510 An argument of \fIn\fP moves \fIn\fP positions forward in the list
4511 of matches; a negative argument may be used to move backward
4513 This command is intended to be bound to \fBTAB\fP, but is unbound
4516 .B delete\-char\-or\-list
4517 Deletes the character under the cursor if not at the beginning or
4518 end of the line (like \fBdelete-char\fP).
4519 If at the end of the line, behaves identically to
4520 \fBpossible-completions\fP.
4521 This command is unbound by default.
4523 .B complete\-filename (M\-/)
4524 Attempt filename completion on the text before point.
4526 .B possible\-filename\-completions (C\-x /)
4527 List the possible completions of the text before point,
4528 treating it as a filename.
4530 .B complete\-username (M\-~)
4531 Attempt completion on the text before point, treating
4534 .B possible\-username\-completions (C\-x ~)
4535 List the possible completions of the text before point,
4536 treating it as a username.
4538 .B complete\-variable (M\-$)
4539 Attempt completion on the text before point, treating
4540 it as a shell variable.
4542 .B possible\-variable\-completions (C\-x $)
4543 List the possible completions of the text before point,
4544 treating it as a shell variable.
4546 .B complete\-hostname (M\-@)
4547 Attempt completion on the text before point, treating
4550 .B possible\-hostname\-completions (C\-x @)
4551 List the possible completions of the text before point,
4552 treating it as a hostname.
4554 .B complete\-command (M\-!)
4555 Attempt completion on the text before point, treating
4556 it as a command name. Command completion attempts to
4557 match the text against aliases, reserved words, shell
4558 functions, shell builtins, and finally executable filenames,
4561 .B possible\-command\-completions (C\-x !)
4562 List the possible completions of the text before point,
4563 treating it as a command name.
4565 .B dynamic\-complete\-history (M\-TAB)
4566 Attempt completion on the text before point, comparing
4567 the text against lines from the history list for possible
4570 .B complete\-into\-braces (M\-{)
4571 Perform filename completion and return the list of possible completions
4572 enclosed within braces so the list is available to the shell (see
4580 .B start\-kbd\-macro (C\-x (\^)
4581 Begin saving the characters typed into the current keyboard macro.
4583 .B end\-kbd\-macro (C\-x )\^)
4584 Stop saving the characters typed into the current keyboard macro
4585 and store the definition.
4587 .B call\-last\-kbd\-macro (C\-x e)
4588 Re-execute the last keyboard macro defined, by making the characters
4589 in the macro appear as if typed at the keyboard.
4595 .B re\-read\-init\-file (C\-x C\-r)
4596 Read in the contents of the \fIinputrc\fP file, and incorporate
4597 any bindings or variable assignments found there.
4600 Abort the current editing command and
4601 ring the terminal's bell (subject to the setting of
4604 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
4605 If the metafied character \fIx\fP is lowercase, run the command
4606 that is bound to the corresponding uppercase character.
4608 .B prefix\-meta (ESC)
4609 Metafy the next character typed.
4616 .B undo (C\-_, C\-x C\-u)
4617 Incremental undo, separately remembered for each line.
4619 .B revert\-line (M\-r)
4620 Undo all changes made to this line. This is like executing the
4622 command enough times to return the line to its initial state.
4624 .B tilde\-expand (M\-&)
4625 Perform tilde expansion on the current word.
4627 .B set\-mark (C\-@, M\-<space>)
4628 Set the mark to the current point. If a
4629 numeric argument is supplied, the mark is set to that position.
4631 .B exchange\-point\-and\-mark (C\-x C\-x)
4632 Swap the point with the mark. The current cursor position is set to
4633 the saved position, and the old cursor position is saved as the mark.
4635 .B character\-search (C\-])
4636 A character is read and point is moved to the next occurrence of that
4637 character. A negative count searches for previous occurrences.
4639 .B character\-search\-backward (M\-C\-])
4640 A character is read and point is moved to the previous occurrence of that
4641 character. A negative count searches for subsequent occurrences.
4643 .B insert\-comment (M\-#)
4647 variable is inserted at the beginning of the current line, and the line
4648 is accepted as if a newline had been typed. This makes the current line
4651 .B glob\-expand\-word (C\-x *)
4652 The word before point is treated as a pattern for pathname expansion,
4653 and the list of matching file names is inserted, replacing the word.
4655 .B glob\-list\-expansions (C\-x g)
4656 The list of expansions that would have been generated by
4657 .B glob\-expand\-word
4658 is displayed, and the line is redrawn.
4661 Print all of the functions and their key bindings to the
4662 readline output stream. If a numeric argument is supplied,
4663 the output is formatted in such a way that it can be made part
4664 of an \fIinputrc\fP file.
4667 Print all of the settable readline variables and their values to the
4668 readline output stream. If a numeric argument is supplied,
4669 the output is formatted in such a way that it can be made part
4670 of an \fIinputrc\fP file.
4673 Print all of the readline key sequences bound to macros and the
4674 strings they ouput. If a numeric argument is supplied,
4675 the output is formatted in such a way that it can be made part
4676 of an \fIinputrc\fP file.
4678 .B display\-shell\-version (C\-x C\-v)
4679 Display version information about the current instance of
4687 builtin is enabled, the shell provides access to the
4688 \fIcommand history\fP,
4689 the list of commands previously typed. The text of the last
4692 commands (default 500) is saved in a history list. The shell
4693 stores each command in the history list prior to parameter and
4694 variable expansion (see
4697 above) but after history expansion is performed, subject to the
4698 values of the shell variables
4704 On startup, the history is initialized from the file named by
4708 (default \fI~/.bash_history\fP).
4711 is truncated, if necessary, to contain no more than
4715 When an interactive shell exits, the last
4718 lines are copied from the history list to
4723 shell option is enabled
4724 (see the description of
4728 .B "SHELL BUILTIN COMMANDS"
4729 below), the lines are appended to the history file,
4730 otherwise the history file is overwritten.
4734 is unset, or if the history file is unwritable, the history is
4735 not saved. After saving the history, the history file is truncated
4736 to contain no more than
4742 is not set, no truncation is performed.
4748 .B SHELL BUILTIN COMMANDS
4749 below) may be used to list or edit and re-execute a portion of
4753 builtin can be used to display or modify the history list and
4754 manipulate the history file.
4755 When using the command-line editing, search commands
4756 are available in each editing mode that provide access to the
4759 The shell allows control over which commands are saved on the history
4766 variables may be set to cause the shell to save only a subset of the
4770 shell option, if enabled, causes the shell to attempt to save each
4771 line of a multi-line command in the same history entry, adding
4772 semicolons where necessary to preserve syntactic correctness.
4775 shell option causes the shell to save the command with embedded newlines
4776 instead of semicolons. See the description of the
4780 .B "SHELL BUILTIN COMMANDS"
4781 for information on setting and unsetting shell options.
4782 .SH "HISTORY EXPANSION"
4784 The shell supports a history expansion feature that
4785 is similar to the history expansion in
4787 This section describes what syntax features are available. This
4788 feature is enabled by default for interactive shells, and can be
4793 builtin command (see
4795 .B SHELL BUILTIN COMMANDS
4796 below). Non-interactive shells do not perform history expansion
4799 History expansions introduce words from the history list into
4800 the input stream, making it easy to repeat commands, insert the
4801 arguments to a previous command into the current input line, or
4802 fix errors in previous commands quickly.
4804 History expansion is performed immediately after a complete line
4805 is read, before the shell breaks it into words.
4806 It takes place in two parts.
4807 The first is to determine which line from the history list
4808 to use during substitution.
4809 The second is to select portions of that line for inclusion into
4811 The line selected from the history is the \fIevent\fP,
4812 and the portions of that line that are acted upon are \fIwords\fP.
4813 Various \fImodifiers\fP are available to manipulate the selected words.
4814 The line is broken into words in the same fashion as when reading input,
4815 so that several \fImetacharacter\fP-separated words surrounded by
4816 quotes are considered one word.
4817 History expansions are introduced by the appearance of the
4818 history expansion character, which is \^\fB!\fP\^ by default.
4819 Only backslash (\^\fB\e\fP\^) and single quotes can quote
4820 the history expansion character.
4822 Several shell options settable with the
4824 builtin may be used to tailor the behavior of history expansion.
4827 shell option is enabled (see the description of the
4831 is being used, history substitutions are not immediately passed to
4833 Instead, the expanded line is reloaded into the
4835 editing buffer for further modification.
4838 is being used, and the
4840 shell option is enabled, a failed history substitution will be reloaded
4843 editing buffer for correction.
4848 builtin command may be used to see what a history expansion will
4854 builtin may be used to add commands to the end of the history list
4855 without actually executing them, so that they are available for
4858 The shell allows control of the various characters used by the
4859 history expansion mechanism (see the description of
4862 .BR "Shell Variables" ).
4863 .SS Event Designators
4865 An event designator is a reference to a command line entry in the
4871 Start a history substitution, except when followed by a
4876 Refer to command line
4880 Refer to the current command line minus
4884 Refer to the previous command. This is a synonym for `!\-1'.
4887 Refer to the most recent command starting with
4890 .B !?\fIstring\fR\fB[?]\fR
4891 Refer to the most recent command containing
4893 The trailing \fB?\fP may be omitted if
4895 is followed immediately by a newline.
4897 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
4898 Quick substitution. Repeat the last command, replacing
4903 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
4904 (see \fBModifiers\fP below).
4907 The entire command line typed so far.
4909 .SS Word Designators
4911 Word designators are used to select desired words from the event.
4914 separates the event specification from the word designator.
4915 It may be omitted if the word designator begins with a
4922 Words are numbered from the beginning of the line,
4923 with the first word being denoted by 0 (zero).
4924 Words are inserted into the current line separated by single spaces.
4929 The zeroth word. For the shell, this is the command
4936 The first argument. That is, word 1.
4942 The word matched by the most recent `?\fIstring\fR?' search.
4945 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
4948 All of the words but the zeroth. This is a synonym
4949 for `\fI1\-$\fP'. It is not an error to use
4951 if there is just one
4952 word in the event; the empty string is returned in that case.
4955 Abbreviates \fIx\-$\fP.
4958 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
4961 If a word designator is supplied without an event specification, the
4962 previous command is used as the event.
4965 After the optional word designator, there may appear a sequence of
4966 one or more of the following modifiers, each preceded by a `:'.
4972 Remove a trailing file name component, leaving only the head.
4975 Remove all leading file name components, leaving the tail.
4978 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
4982 Remove all but the trailing suffix.
4985 Print the new command but do not execute it.
4988 Quote the substituted words, escaping further substitutions.
4991 Quote the substituted words as with
4993 but break into words at
4997 .B s/\fIold\fP/\fInew\fP/
5000 for the first occurrence of
5002 in the event line. Any delimiter can be used in place of /. The
5003 final delimiter is optional if it is the last character of the
5004 event line. The delimiter may be quoted in
5008 with a single backslash. If & appears in
5012 A single backslash will quote the &. If
5014 is null, it is set to the last
5016 substituted, or, if no previous history substitutions took place,
5020 .B !?\fIstring\fR\fB[?]\fR
5024 Repeat the previous substitution.
5027 Cause changes to be applied over the entire event line. This is
5028 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
5029 or `\fB:&\fP'. If used with
5030 `\fB:s\fP', any delimiter can be used
5031 in place of /, and the final delimiter is optional
5032 if it is the last character of the event line.
5034 .SH "SHELL BUILTIN COMMANDS"
5035 .\" start of bash_builtins
5038 Unless otherwise noted, each builtin command documented in this
5039 section as accepting options preceded by
5043 to signify the end of the options.
5047 \fB:\fP [\fIarguments\fP]
5049 No effect; the command does nothing beyond expanding
5051 and performing any specified
5052 redirections. A zero exit code is returned.
5055 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
5057 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
5059 Read and execute commands from
5062 shell environment and return the exit status of the last command
5067 does not contain a slash, file names in
5070 are used to find the directory containing
5072 The file searched for in
5075 need not be executable. The current directory is
5076 searched if no file is found in
5083 builtin command is turned off, the
5087 If any \fIarguments\fP are supplied, they become the positional
5088 parameters when \fIfilename\fP is executed. Otherwise the positional
5089 parameters are unchanged.
5090 The return status is the status of the last command exited within
5091 the script (0 if no commands are executed), and false if
5093 is not found or cannot be read.
5095 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
5096 \fBAlias\fP with no arguments or with the
5098 option prints the list of aliases in the form
5099 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
5100 When arguments are supplied, an alias is defined for
5101 each \fIname\fP whose \fIvalue\fP is given.
5102 A trailing space in \fIvalue\fP causes the next word to be
5103 checked for alias substitution when the alias is expanded.
5104 For each \fIname\fP in the argument list for which no \fIvalue\fP
5105 is supplied, the name and value of the alias is printed.
5106 \fBAlias\fP returns true unless a \fIname\fP is given for which
5107 no alias has been defined.
5109 \fBbg\fP [\fIjobspec\fP]
5110 Resume the suspended job \fIjobspec\fP in the background, as if it
5111 had been started with
5113 If \fIjobspec\fP is not present, the shell's notion of the
5114 \fIcurrent job\fP is used.
5117 returns 0 unless run when job control is disabled or, when run with
5118 job control enabled, if \fIjobspec\fP was not found or started without
5122 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
5124 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
5126 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
5128 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
5132 key and function bindings, or bind a key sequence to a
5134 function or macro. The binding syntax accepted is identical to that of
5136 but each binding must be passed as a separate argument;
5137 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the
5145 as the keymap to be affected by the subsequent bindings.
5149 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
5152 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
5153 equivalent to \fIemacs\-standard\fP.
5156 List the names of all \fBreadline\fP functions.
5159 Display \fBreadline\fP function names and bindings in such a way
5160 that they can be re-read.
5163 List current \fBreadline\fP function names and bindings.
5166 Display \fBreadline\fP variable names and values in such a way that they
5170 List current \fBreadline\fP variable names and values.
5173 Display \fBreadline\fP key sequences bound to macros and the strings
5174 they output in such a way that they can be re-read.
5177 Display \fBreadline\fP key sequences bound to macros and the strings
5180 .B \-f \fIfilename\fP
5181 Read key bindings from \fIfilename\fP.
5183 .B \-q \fIfunction\fP
5184 Query about which keys invoke the named \fIfunction\fP.
5186 .B \-u \fIfunction\fP
5187 Unbind all keys bound to the named \fIfunction\fP.
5190 Remove any current binding for \fIkeyseq\fP.
5193 The return value is 0 unless an unrecognized option is given or an
5197 \fBbreak\fP [\fIn\fP]
5204 loop. If \fIn\fP is specified, break \fIn\fP levels.
5208 is greater than the number of enclosing loops, all enclosing loops
5209 are exited. The return value is 0 unless the shell is not executing
5214 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
5215 Execute the specified shell builtin, passing it
5217 and return its exit status.
5218 This is useful when defining a
5219 function whose name is the same as a shell builtin,
5220 retaining the functionality of the builtin within the function.
5221 The \fBcd\fP builtin is commonly redefined this way.
5222 The return status is false if
5224 is not a shell builtin command.
5226 \fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
5227 Change the current directory to \fIdir\fP. The variable
5236 defines the search path for the directory containing
5238 Alternative directory names in
5241 are separated by a colon (:). A null directory name in
5244 is the same as the current directory, i.e., ``\fB.\fP''. If
5246 begins with a slash (/),
5252 option says to use the physical directory structure instead of
5253 following symbolic links (see also the
5257 builtin command); the
5259 option forces symbolic links to be followed. An argument of
5264 The return value is true if the directory was successfully changed;
5267 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
5272 suppressing the normal shell function lookup. Only builtin
5273 commands or commands found in the
5276 are executed. If the
5278 option is given, the search for
5280 is performed using a default value for
5282 that is guaranteed to find all of the standard utilities.
5287 option is supplied, a description of
5291 option causes a single word indicating the command or file name
5294 to be displayed; the
5296 option produces a more verbose description.
5301 option is supplied, the exit status is 0 if
5303 was found, and 1 if not. If neither option is supplied and
5304 an error occurred or
5306 cannot be found, the exit status is 127. Otherwise, the exit status of the
5308 builtin is the exit status of
5311 \fBcontinue\fP [\fIn\fP]
5312 Resume the next iteration of the enclosing
5321 is specified, resume at the \fIn\fPth enclosing loop.
5325 is greater than the number of enclosing loops, the last enclosing loop
5326 (the ``top-level'' loop) is resumed. The return value is 0 unless the
5327 shell is not executing a loop when
5332 \fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
5334 \fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
5336 Declare variables and/or give them attributes.
5337 If no \fIname\fPs are given then display the values of variables.
5340 option will display the attributes and values of each
5344 is used, additional options are ignored.
5347 option inhibits the display of function definitions; only the
5348 function name and attributes are printed.
5353 The following options can
5354 be used to restrict output to variables with the specified attribute or
5355 to give variables attributes:
5360 Each \fIname\fP is an array variable (see
5365 Use function names only.
5368 The variable is treated as an integer; arithmetic evaluation (see
5370 .B "ARITHMETIC EVALUATION" ") "
5371 is performed when the variable is assigned a value.
5374 Make \fIname\fPs readonly. These names cannot then be assigned values
5375 by subsequent assignment statements or unset.
5378 Mark \fIname\fPs for export to subsequent commands via the environment.
5381 Using `+' instead of `\-'
5382 turns off the attribute instead, with the exception that \fB+a\fP
5383 may not be used to destroy an array variable. When used in a function,
5385 \fIname\fP local, as with the
5387 command. The return value is 0 unless an invalid option is encountered,
5388 an attempt is made to define a function using "\-f foo=bar",
5389 an attempt is made to assign a value to a readonly variable,
5390 an attempt is made to assign a value to an array variable without
5391 using the compound assignment syntax (see
5393 above), one of the \fInames\fP is not a valid shell variable name,
5394 an attempt is made to turn off readonly status for a readonly variable,
5395 an attempt is made to turn off array status for an array variable,
5396 or an attempt is made to display a non-existent function with \-f.
5399 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
5400 Without options, displays the list of currently remembered directories.
5401 The default display is on a single line with directory names separated
5403 Directories are added to the list with the
5407 command removes entries from the list.
5412 Displays the \fIn\fPth entry counting from the left of the list
5415 when invoked without options, starting with zero.
5418 Displays the \fIn\fPth entry counting from the right of the list
5421 when invoked without options, starting with zero.
5424 Clears the directory stack by deleting all of the entries.
5427 Produces a longer listing; the default listing format uses a
5428 tilde to denote the home directory.
5431 Print the directory stack with one entry per line.
5434 Print the directory stack with one entry per line,
5435 prefixing each entry with its index in the stack.
5438 The return value is 0 unless an
5439 invalid option is supplied or \fIn\fP indexes beyond the end
5440 of the directory stack.
5443 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
5444 Without options, each
5446 is removed from the table of active jobs.
5447 If the \fB\-h\fP option is given, each
5449 is not removed from the table, but is marked so that
5452 is not sent to the job if the shell receives a
5457 is present, and neither the
5461 option is supplied, the \fIcurrent job\fP is used.
5466 option means to remove or mark all jobs; the
5470 argument restricts operation to running jobs.
5471 The return value is 0 unless a
5473 does not specify a valid job.
5475 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
5476 Output the \fIarg\fPs, separated by spaces, followed by a newline.
5477 The return status is always 0.
5478 If \fB\-n\fP is specified, the trailing newline is
5479 suppressed. If the \fB\-e\fP option is given, interpretation of
5480 the following backslash-escaped characters is enabled. The
5482 option disables the interpretation of these escape characters,
5483 even on systems where they are interpreted by default.
5487 to mean the end of options.
5489 interprets the following escape sequences:
5500 suppress trailing newline
5524 the character whose ASCII code is the octal value \fInnn\fP
5525 (one to three digits)
5528 the character whose ASCII code is the hexadecimal value \fInnn\fP
5529 (one to three digits)
5533 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
5534 Enable and disable builtin shell commands.
5535 Disabling a builtin allows a disk command which has the same name
5536 as a shell builtin to be executed with specifying a full pathname,
5537 even though the shell normally searches for builtins before disk commands.
5538 If \fB\-n\fP is used, each \fIname\fP
5539 is disabled; otherwise,
5540 \fInames\fP are enabled. For example, to use the
5542 binary found via the
5545 instead of the shell builtin version, run
5546 \f(CWenable -n test\fP.
5549 option means to load the new builtin command
5553 on systems that support dynamic loading. The
5555 option will delete a builtin previously loaded with
5557 If no \fIname\fP arguments are given, or if the
5559 option is supplied, a list of shell builtins is printed.
5560 With no other option arguments, the list consists of all enabled
5562 If \fB\-n\fP is supplied, only disabled builtins are printed.
5563 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
5564 indication of whether or not each is enabled.
5565 If \fB\-s\fP is supplied, the output is restricted to the POSIX
5566 \fIspecial\fP builtins.
5567 The return value is 0 unless a
5569 is not a shell builtin or there is a problem loading a new builtin
5570 from a shared object.
5572 \fBeval\fP [\fIarg\fP ...]
5573 The \fIarg\fPs are read and concatenated together into a single
5574 command. This command is then read and executed by the shell, and
5575 its exit status is returned as the value of
5579 or only null arguments,
5583 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
5586 is specified, it replaces the shell.
5587 No new process is created. The
5589 become the arguments to \fIcommand\fP.
5593 the shell places a dash in the zeroth arg passed to
5601 to be executed with an empty environment. If
5603 is supplied, the shell passes
5605 as the zeroth argument to the executed command. If
5607 cannot be executed for some reason, a non-interactive shell exits,
5608 unless the shell option
5610 is enabled, in which case it returns failure.
5611 An interactive shell returns failure if the file cannot be executed.
5614 is not specified, any redirections take effect in the current shell,
5615 and the return status is 0. If there is a redirection error, the
5618 \fBexit\fP [\fIn\fP]
5619 Cause the shell to exit
5620 with a status of \fIn\fP. If
5622 is omitted, the exit status
5623 is that of the last command executed.
5627 is executed before the shell terminates.
5630 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
5636 are marked for automatic export to the environment of
5637 subsequently executed commands. If the
5645 are given, or if the
5647 option is supplied, a list
5648 of all names that are exported in this shell is printed.
5651 option causes the export property to be removed from the
5654 returns an exit status of 0 unless an invalid option is
5656 one of the \fInames\fP is not a valid shell variable name, or
5660 that is not a function.
5663 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
5665 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
5667 Fix Command. In the first form, a range of commands from
5671 is selected from the history list.
5675 may be specified as a string (to locate the last command beginning
5676 with that string) or as a number (an index into the history list,
5677 where a negative number is used as an offset from the current
5680 is not specified it is set to
5681 the current command for listing (so that
5683 prints the last 10 commands) and to
5688 is not specified it is set to the previous
5689 command for editing and \-16 for listing.
5694 the command numbers when listing. The
5696 option reverses the order of
5697 the commands. If the
5700 the commands are listed on
5701 standard output. Otherwise, the editor given by
5704 on a file containing those commands. If
5710 variable is used, and
5717 is not set. If neither variable is set,
5719 is used. When editing is complete, the edited commands are
5720 echoed and executed.
5722 In the second form, \fIcommand\fP is re-executed after each instance
5723 of \fIpat\fP is replaced by \fIrep\fP.
5724 A useful alias to use with this is
5726 .if t \f(CWr='fc \-s'\fP,
5730 runs the last command beginning with
5736 re-executes the last command.
5738 If the first form is used, the return value is 0 unless an invalid
5739 option is encountered or
5743 specify history lines out of range.
5746 option is supplied, the return value is the value of the last
5747 command executed or failure if an error occurs with the temporary
5748 file of commands. If the second form is used, the return status
5749 is that of the command re-executed, unless
5751 does not specify a valid history line, in which case
5755 \fBfg\fP [\fIjobspec\fP]
5758 in the foreground, and make it the current job.
5761 is not present, the shell's notion of the \fIcurrent job\fP is used.
5762 The return value is that of the command placed into the foreground,
5763 or failure if run when job control is disabled or, when run with
5764 job control enabled, if
5766 does not specify a valid job or
5768 specifies a job that was started without job control.
5770 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
5772 is used by shell procedures to parse positional parameters.
5774 contains the option letters to be recognized; if a letter
5775 is followed by a colon, the option is expected to have an
5776 argument, which should be separated from it by white space.
5777 Each time it is invoked,
5779 places the next option in the shell variable
5783 if it does not exist,
5784 and the index of the next argument to be processed into the
5790 is initialized to 1 each time the shell or a shell script
5791 is invoked. When an option requires an argument,
5793 places that argument into the variable
5796 The shell does not reset
5799 automatically; it must be manually reset between multiple
5802 within the same shell invocation if a new set of parameters
5805 When the end of options is encountered, \fBgetopts\fP exits with a
5806 return value greater than zero.
5807 \fBOPTIND\fP is set to the index of the first non-option argument,
5808 and \fBname\fP is set to ?.
5811 normally parses the positional parameters, but if more arguments are
5815 parses those instead.
5818 can report errors in two ways. If the first character of
5822 error reporting is used. In normal operation diagnostic messages
5823 are printed when invalid options or missing option arguments are
5828 is set to 0, no error messages will be displayed, even if the first
5833 If an invalid option is seen,
5838 prints an error message and unsets
5844 the option character found is placed in
5847 and no diagnostic message is printed.
5849 If a required argument is not found, and
5852 a question mark (\^\fB?\fP\^) is placed in
5855 is unset, and a diagnostic message is printed.
5858 is silent, then a colon (\^\fB:\fP\^) is placed in
5863 is set to the option character found.
5866 returns true if an option, specified or unspecified, is found.
5867 It returns false if the end of options is encountered or an
5870 \fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fIname\fP]
5873 the full file name of the command is determined by searching
5879 option is supplied, no path search is performed, and
5881 is used as the full file name of the command.
5884 option causes the shell to forget all
5885 remembered locations. If no arguments are given, information
5886 about remembered commands is printed.
5887 The return status is true unless a
5889 is not found or an invalid option is supplied.
5891 \fBhelp\fP [\fIpattern\fP]
5892 Display helpful information about builtin commands. If
5896 gives detailed help on all commands matching
5898 otherwise help for all the builtins and shell control structures
5899 is printed. The return status is 0 unless no command matches
5903 \fBhistory\fP [\fB\-c\fP] [\fIn\fP]
5905 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
5907 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
5909 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
5911 With no options, display the command
5912 history list with line numbers. Lines listed
5915 have been modified. An argument of
5919 lines. If \fIfilename\fP is supplied, it is used as the
5920 name of the history file; if not, the value of
5923 is used. Options, if supplied, have the following meanings:
5928 Append the ``new'' history lines (history lines entered since the
5929 beginning of the current \fBbash\fP session) to the history file.
5932 Read the history lines not already read from the history
5933 file into the current history list. These are lines
5934 appended to the history file since the beginning of the
5935 current \fBbash\fP session.
5938 Read the contents of the history file
5939 and use them as the current history.
5942 Write the current history to the history file, overwriting the
5943 history file's contents.
5946 Clear the history list by deleting all the entries.
5949 Perform history substitution on the following \fIargs\fP and display
5950 the result on the standard output.
5951 Does not store the results in the history list.
5952 Each \fIarg\fP must be quoted to disable normal history expansion.
5957 in the history list as a single entry. The last command in the
5958 history list is removed before the
5963 The return value is 0 unless an invalid option is encountered or an
5964 error occurs while reading or writing the history file.
5968 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
5970 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
5972 The first form lists the active jobs. The options have the following
5979 in addition to the normal information.
5982 List only the process ID of the job's process group
5986 Display information only about jobs that have changed status since
5987 the user was last notified of their status.
5990 Restrict output to running jobs.
5993 Restrict output to stopped jobs.
5998 is given, output is restricted to information about that job.
5999 The return status is 0 unless an invalid option is encountered
6014 with the corresponding process group ID, and executes
6018 returning its exit status.
6022 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
6024 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
6026 Send the signal named by
6030 to the processes named by
6035 is either a signal name such as
6040 is a signal number. If
6042 is a signal name, the name may be
6043 given with or without the
6049 is not present, then
6055 lists the signal names.
6056 If any arguments are supplied when
6058 is given, the names of the signals corresponding to the arguments are
6059 listed, and the return status is 0.
6060 The \fIexit_status\fP argument to
6062 is a number specifying either a signal number or the exit status of
6063 a process terminated by a signal.
6065 returns true if at least one signal was successfully sent, or false
6066 if an error occurs or an invalid option is encountered.
6068 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
6071 is an arithmetic expression to be evaluated (see
6073 .BR "ARITHMETIC EVALUATION" ).
6078 returns 1; 0 is returned otherwise.
6080 \fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...]
6081 For each argument, a local variable named
6083 is created, and assigned
6087 is used within a function, it causes the variable
6089 to have a visible scope restricted to that function and its children.
6092 writes a list of local variables to the standard output. It is
6095 when not within a function. The return status is 0 unless
6097 is used outside a function, or an invalid
6104 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
6105 Removes entries from the directory stack. With no arguments,
6106 removes the top directory from the stack, and performs a
6108 to the new top directory.
6109 Arguments, if supplied, have the following meanings:
6114 Removes the \fIn\fPth entry counting from the left of the list
6117 starting with zero. For example: ``popd +0''
6118 removes the first directory, ``popd +1'' the second.
6121 Removes the \fIn\fPth entry counting from the right of the list
6124 starting with zero. For example: ``popd -0''
6125 removes the last directory, ``popd -1'' the next to last.
6128 Suppresses the normal change of directory when removing directories
6129 from the stack, so that only the stack is manipulated.
6134 command is successful, a
6136 is performed as well, and the return status is 0.
6138 returns false if an invalid option is encountered, the directory stack
6139 is empty, a non-existent directory stack entry is specified, or the
6140 directory change fails.
6143 \fBprintf\fP \fIformat\fP [\fIarguments\fP]
6144 Write the formatted \fIarguments\fP to the standard output under the
6145 control of the \fIformat\fP.
6146 The \fIformat\fP is a character string which contains three types of objects:
6147 plain characters, which are simply copied to standard output, character
6148 escape sequences, which are converted and copied to the standard output, and
6149 format specifications, each of which causes printing of the next successive
6151 In addition to the standard \fIprintf\fP(1) formats, %b causes
6152 \fBprintf\fP to expand backslash escape sequences in the corresponding
6153 \fIargument\fP, and %q causes \fBprintf\fP to output the corresponding
6154 \fIargument\fP in a format that can be reused as shell input.
6156 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
6157 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
6158 extra format specifications behave as if a zero value or null string, as
6159 appropriate, had been supplied.
6162 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
6164 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
6166 Adds a directory to the top of the directory stack, or rotates
6167 the stack, making the new top of the stack the current working
6168 directory. With no arguments, exchanges the top two directories
6169 and returns 0, unless the directory stack is empty.
6170 Arguments, if supplied, have the following meanings:
6175 Rotates the stack so that the \fIn\fPth directory
6176 (counting from the left of the list shown by
6182 Rotates the stack so that the \fIn\fPth directory
6183 (counting from the right of the list shown by
6185 starting with zero) is at the top.
6188 Suppresses the normal change of directory when adding directories
6189 to the stack, so that only the stack is manipulated.
6194 to the directory stack at the top, making it the
6195 new current working directory.
6200 command is successful, a
6202 is performed as well.
6203 If the first form is used,
6205 returns 0 unless the cd to
6207 fails. With the second form,
6209 returns 0 unless the directory stack is empty,
6210 a non-existent directory stack element is specified,
6211 or the directory change to the specified new current directory
6215 \fBpwd\fP [\fB\-LP\fP]
6216 Print the absolute file name of the current working directory.
6217 The file name printed contains no symbolic links if the
6219 option is supplied or the
6223 builtin command is enabled.
6226 option is used, symbolic links are followed.
6227 The return status is 0 unless an error occurs while
6228 reading the name of the current directory or an
6229 invalid option is supplied.
6231 \fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...]
6232 One line is read from the standard input, and the first word
6233 is assigned to the first
6235 the second word to the second
6237 and so on, with leftover words and their intervening separators assigned
6240 If there are fewer words read from the standard input than names,
6241 the remaining names are assigned empty values.
6245 are used to split the line into words.
6246 The backslash character (\fB\e\fP) may be used to remove any special
6247 meaning for the next character read and for line continuation.
6248 Options, if supplied, have the following meanings:
6253 Backslash does not act as an escape character.
6254 The backslash is considered to be part of the line.
6255 In particular, a backslash-newline pair may not be used as a line
6259 Display \fIprompt\fP, without a
6260 trailing newline, before attempting to read any input. The prompt
6261 is displayed only if input is coming from a terminal.
6264 The words are assigned to sequential indices
6265 of the array variable
6269 is unset before any new values are assigned.
6270 Other \fIname\fP arguments are ignored.
6273 If the standard input
6274 is coming from a terminal,
6279 above) is used to obtain the line.
6284 are supplied, the line read is assigned to the variable
6287 The return code is zero, unless end-of-file is encountered.
6290 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
6293 \fInames\fP are marked readonly; the values of these
6295 may not be changed by subsequent assignment.
6298 option is supplied, the functions corresponding to the
6303 option restricts the variables to arrays.
6306 arguments are given, or if the
6308 option is supplied, a list of all readonly names is printed.
6311 option causes output to be displayed in a format thatmay be reused as input.
6312 The return status is 0 unless an invalid option is encountered,
6315 is not a valid shell variable name, or
6319 that is not a function.
6321 \fBreturn\fP [\fIn\fP]
6322 Causes a function to exit with the return value specified by
6326 is omitted, the return status is that of the last command
6327 executed in the function body. If used outside a function,
6328 but during execution of a script by the
6330 (\fBsource\fP) command, it causes the shell to stop executing
6331 that script and return either
6333 or the exit status of the last command executed within the
6334 script as the exit status of the script. If used outside a
6335 function and not during execution of a script by \fB.\fP\^,
6336 the return status is false.
6338 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
6339 Without options, the name and value of each shell variable are displayed
6340 in a format that can be reused as input.
6341 The output is sorted according to the current locale.
6342 When options are specified, they set or unset shell attributes.
6343 Any arguments remaining after the options are processed are treated
6344 as values for the positional parameters and are assigned, in order, to
6349 Options, if specified, have the following meanings:
6354 Automatically mark variables which are modified or created for export
6355 to the environment of subsequent commands.
6358 Report the status of terminated background jobs
6359 immediately, rather than before the next primary prompt. This is
6360 effective only when job control is enabled.
6363 Exit immediately if a \fIsimple command\fP (see
6366 above) exits with a non-zero status. The shell does not exit if the
6367 command that fails is part of an
6374 statement, part of a
6378 list, or if the command's return value is
6383 Disable pathname expansion.
6386 Remember the location of commands as they are looked up for execution.
6387 This is enabled by default.
6390 All arguments in the form of assignment statements
6391 are placed in the environment for a command, not just
6392 those that precede the command name.
6395 Monitor mode. Job control is enabled. This option is on
6396 by default for interactive shells on systems that support
6400 above). Background processes run in a separate process
6401 group and a line containing their exit status is printed
6402 upon their completion.
6405 Read commands but do not execute them. This may be used to
6406 check a shell script for syntax errors. This is ignored by
6409 .B \-o \fIoption\-name\fP
6410 The \fIoption\-name\fP can be one of the following:
6422 Use an emacs-style command line editing interface. This is enabled
6423 by default when the shell is interactive, unless the shell is started
6441 Enable command history, as described above under
6444 This option is on by default in interactive shells.
6447 The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed
6489 Change the behavior of
6491 where the default operation differs
6492 from the POSIX 1003.2 standard to match the standard.
6503 Use a vi-style command line editing interface.
6512 is supplied with no \fIoption\-name\fP, the values of the current options are
6516 is supplied with no \fIoption\-name\fP, a series of
6518 commands to recreate the current option settings is displayed on
6519 the standard output.
6525 mode. In this mode, the
6529 files are not processed, shell functions are not inherited from the
6530 environment, and the \fBSHELLOPTS\fP variable, if it appears in the
6531 environment, is ignored.
6532 If the shell is started with the effective user (group) id not equal to the
6533 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
6534 are taken and the effective user id is set to the real user id.
6535 If the \fB\-p\fP option is supplied at startup, the effective user id is
6537 Turning this option off causes the effective user
6538 and group ids to be set to the real user and group ids.
6541 Exit after reading and executing one command.
6544 Treat unset variables as an error when performing
6545 parameter expansion. If expansion is attempted on an
6546 unset variable, the shell prints an error message, and,
6547 if not interactive, exits with a non-zero status.
6550 Print shell input lines as they are read.
6553 After expanding each \fIsimple command\fP,
6554 display the expanded value of
6557 followed by the command and its expanded arguments.
6560 The shell performs brace expansion (see
6562 above). This is on by default.
6567 does not overwrite an existing file with the
6572 redirection operators. This may be overridden when
6573 creating output files by using the redirection operator
6581 style history substitution. This option is on by
6582 default when the shell is interactive.
6585 If set, the shell does not follow symbolic links when executing
6588 that change the current working directory. It uses the
6589 physical directory structure instead. By default,
6591 follows the logical chain of directories when performing commands
6592 which change the current directory.
6595 If no arguments follow this option, then the positional parameters are
6596 unset. Otherwise, the positional parameters are set to the
6597 \fIarg\fPs, even if some of them begin with a
6601 Signal the end of options, cause all remaining \fIarg\fPs to be
6602 assigned to the positional parameters. The
6606 options are turned off.
6607 If there are no \fIarg\fPs,
6608 the positional parameters remain unchanged.
6611 The options are off by default unless otherwise noted.
6612 Using + rather than \- causes these options to be turned off.
6613 The options can also be specified as arguments to an invocation of
6615 The current set of options may be found in
6617 The return status is always true unless an invalid option is encountered.
6620 \fBshift\fP [\fIn\fP]
6621 The positional parameters from \fIn\fP+1 ... are renamed to
6624 Parameters represented by the numbers \fB$#\fP
6625 down to \fB$#\fP\-\fIn\fP+1 are unset.
6627 must be a non-negative number less than or equal to \fB$#\fP.
6630 is 0, no parameters are changed.
6633 is not given, it is assumed to be 1.
6636 is greater than \fB$#\fP, the positional parameters are not changed.
6637 The return status is greater than zero if
6641 or less than zero; otherwise 0.
6643 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
6644 Toggle the values of variables controlling optional shell behavior.
6645 With no options, or with the
6647 option, a list of all settable options is displayed, with
6648 an indication of whether or not each is set.
6649 The \fB\-p\fP option causes output to be displayed in a form that
6650 may be reused as input.
6651 Other options have the following meanings:
6656 Enable (set) each \fIoptname\fP.
6659 Disable (unset) each \fIoptname\fP.
6662 Suppresses normal output (quiet mode); the return status indicates
6663 whether the \fIoptname\fP is set or unset.
6664 If multiple \fIoptname\fP arguments are given with
6666 the return status is zero if all \fIoptnames\fP are enabled; non-zero
6670 Restricts the values of \fIoptname\fP to be those defined for the
6681 is used with no \fIoptname\fP arguments, the display is limited to
6682 those options which are set or unset, respectively.
6683 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
6686 The return status when listing options is zero if all \fIoptnames\fP
6687 are enabled, non-zero otherwise. When setting or unsetting options,
6688 the return status is zero unless an \fIoptname\fP is not a valid shell
6691 The list of \fBshopt\fP options is:
6697 If set, an argument to the
6699 builtin command that
6700 is not a directory is assumed to be the name of a variable whose
6701 value is the directory to change to.
6704 If set, minor errors in the spelling of a directory component in a
6706 command will be corrected.
6707 The errors checked for are transposed characters,
6708 a missing character, and one character too many.
6709 If a correction is found, the corrected file name is printed,
6710 and the command proceeds.
6711 This option is only used by interactive shells.
6714 If set, \fBbash\fP checks that a command found in the hash
6715 table exists before trying to execute it. If a hashed command no
6716 longer exists, a normal path search is performed.
6719 If set, \fBbash\fP checks the window size after each command
6720 and, if necessary, updates the values of
6730 attempts to save all lines of a multiple-line
6731 command in the same history entry. This allows
6732 easy re-editing of multi-line commands.
6737 includes filenames beginning with a `.' in the results of pathname
6741 If set, a non-interactive shell will not exit if
6742 it cannot execute the file specified as an argument to the
6744 builtin command. An interactive shell does not exit if
6749 If set, aliases are expanded as described above under
6752 This option is enabled by default for interactive shells.
6755 If set, the extended pattern matching features described above under
6756 \fBPathname Expansion\fP are enabled.
6759 If set, the history list is appended to the file named by the value
6762 variable when the shell exits, rather than overwriting the file.
6767 is being used, a user is given the opportunity to re-edit a
6768 failed history substitution.
6773 is being used, the results of history substitution are not immediately
6774 passed to the shell parser. Instead, the resulting line is loaded into
6775 the \fBreadline\fP editing buffer, allowing further modification.
6780 is being used, \fBbash\fP will attempt to perform hostname completion when a
6781 word containing a \fB@\fP is being completed (see
6787 This is enabled by default.
6790 If set, \fBbash\fP will send
6793 to all jobs when an interactive login shell exits.
6795 .B interactive_comments
6796 If set, allow a word beginning with
6798 to cause that word and all remaining characters on that
6799 line to be ignored in an interactive shell (see
6802 above). This option is enabled by default.
6807 option is enabled, multi-line commands are saved to the history with
6808 embedded newlines rather than using semicolon separators where possible.
6811 If set, and a file that \fBbash\fP is checking for mail has been
6812 accessed since the last time it was checked, the message ``The mail in
6813 \fImailfile\fP has been read'' is displayed.
6818 matches filenames in a case\-insensitive fashion when performing pathname
6820 .B Pathname Expansion
6826 allows patterns which match no
6828 .B Pathname Expansion
6830 to expand to a null string, rather than themselves.
6833 If set, prompt strings undergo variable and parameter expansion after
6834 being expanded as described in
6837 above. This option is enabled by default.
6840 The shell sets this option if it is started in restricted mode (see
6842 .B "RESTRICTED SHELL"
6844 The value may not be changed.
6845 This is not reset when the startup files are executed, allowing
6846 the startup files to discover whether or not a shell is restricted.
6851 builtin prints an error message when the shift count exceeds the
6852 number of positional parameters.
6856 \fBsource\fP (\fB.\fP) builtin uses the value of
6859 to find the directory containing the file supplied as an argument.
6860 This option is enabled by default.
6863 \fBsuspend\fP [\fB\-f\fP]
6864 Suspend the execution of this shell until it receives a
6869 option says not to complain if this is
6870 a login shell; just suspend anyway. The return status is 0 unless
6871 the shell is a login shell and
6873 is not supplied, or if job control is not enabled.
6876 \fBtest\fP \fIexpr\fP
6878 \fB[\fP \fIexpr\fP \fB]\fP
6879 Return a status of 0 or 1 depending on
6880 the evaluation of the conditional expression
6882 Each operator and operand must be a separate argument.
6883 Expressions are composed of the primaries described above under
6885 .BR "CONDITIONAL EXPRESSIONS" .
6888 Expressions may be combined using the following operators, listed
6889 in decreasing order of precedence.
6899 Returns the value of \fIexpr\fP.
6900 This may be used to override the normal precedence of operators.
6902 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
6909 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
6917 \fBtest\fP and \fB[\fP evaluate conditional
6918 expressions using a set of rules based on the number of arguments.
6924 The expression is false.
6927 The expression is true if and only if the argument is not null.
6930 If the first argument is \fB!\fP, the expression is true if and
6931 only if the second argument is null.
6932 If the first argument is one of the unary conditional operators listed above
6935 .BR "CONDITIONAL EXPRESSIONS" ,
6936 the expression is true if the unary test is true.
6937 If the first argument is not a valid unary conditional operator, the expression
6941 If the second argument is one of the binary conditional operators listed above
6944 .BR "CONDITIONAL EXPRESSIONS" ,
6945 the result of the expression is the result of the binary test using
6946 the first and third arguments as operands.
6947 If the first argument is \fB!\fP, the value is the negation of
6948 the two-argument test using the second and third arguments.
6949 If the first argument is exactly \fB(\fP and the third argument is
6950 exactly \fB)\fP, the result is the one-argument test of the second
6952 Otherwise, the expression is false.
6953 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
6957 If the first argument is \fB!\fP, the result is the negation of
6958 the three-argument expression composed of the remaining arguments.
6959 Otherwise, the expression is parsed and evaluated according to
6960 precedence using the rules listed above.
6963 The expression is parsed and evaluated according to precedence
6964 using the rules listed above.
6969 Print the accumulated user and system times for the shell and
6970 for processes run from the shell. The return status is 0.
6972 \fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP ...]
6975 is to be read and executed when the shell receives
6982 all specified signals are
6983 reset to their original values (the values they had
6984 upon entrance to the shell).
6987 is the null string the signal specified by each
6989 is ignored by the shell and by the commands it invokes.
6994 then the trap commands associated with
6997 are displayed. If no arguments are supplied or if
7002 prints the list of commands associated with each signal number.
7006 a signal name defined in <\fIsignal.h\fP>, or a signal number.
7014 is executed on exit from the shell. If a
7021 is executed after every \fIsimple command\fP (see
7027 option causes the shell to print a list of signal names and
7028 their corresponding numbers.
7029 Signals ignored upon entry to the shell cannot be trapped or reset.
7030 Trapped signals are reset to their original values in a child
7031 process when it is created.
7032 The return status is false if any
7034 is invalid; otherwise
7038 \fBtype\fP [\fB\-atp\fP] \fIname\fP [\fIname\fP ...]
7042 would be interpreted if used as a command name.
7047 prints a string which is one of
7056 is an alias, shell reserved word, function, builtin, or disk file,
7060 is not found, then nothing is printed, and an exit status of false
7066 either returns the name of the disk file
7067 that would be executed if
7069 were specified as a command name,
7070 or nothing if \f(CWtype -t name\fP
7073 If a command is hashed,
7075 prints the hashed value, not necessarily the file that appears
7083 prints all of the places that contain
7086 This includes aliases and functions,
7089 option is not also used.
7090 The table of hashed commands is not consulted
7094 returns true if any of the arguments are found, false if
7097 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
7098 Provides control over the resources available to the shell and to
7099 processes started by it, on systems that allow such control. The
7102 can be a number in the unit specified for the resource, or the
7105 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
7106 set for the given resource. A hard limit cannot be increased once it
7107 is set; a soft limit may be increased up to the value of the hard limit.
7108 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
7112 is omitted, the current value of the soft limit of the resource is
7113 printed, unless the \fB\-H\fP option is given. When more than one
7114 resource is specified, the limit name and unit are printed before the value.
7115 Other options are interpreted as follows:
7120 All current limits are reported
7123 The maximum size of core files created
7126 The maximum size of a process's data segment
7129 The maximum size of files created by the shell
7132 The maximum size that may be locked into memory
7135 The maximum resident set size
7138 The maximum number of open file descriptors (most systems do not
7139 allow this value to be set)
7142 The pipe size in 512-byte blocks (this may not be set)
7145 The maximum stack size
7148 The maximum amount of cpu time in seconds
7151 The maximum number of processes available to a single user
7154 The maximum amount of virtual memory available to the shell
7159 is given, it is the new value of the specified resource (the
7161 option is display only).
7162 If no option is given, then
7164 is assumed. Values are in 1024-byte increments, except for
7166 which is in seconds,
7168 which is in units of 512-byte blocks,
7173 which are unscaled values. The return status is 0
7174 unless an invalid option is encountered, a non-numeric argument
7175 other than \fBunlimited\fP is supplied as \fIlimit\fP, or an
7176 error occurs while setting a new limit.
7179 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
7180 The user file-creation mask is set to
7184 begins with a digit, it
7185 is interpreted as an octal number; otherwise
7186 it is interpreted as a symbolic mode mask similar
7191 is omitted, or if the
7193 option is supplied, the
7194 current value of the mask is printed.
7197 option causes the mask to be printed in symbolic form; the
7198 default output is an octal number.
7201 option is supplied, and
7203 is omitted, the output is in a form that may be reused as input.
7204 The return status is 0 if the mode was successfully changed or if
7205 no \fImode\fP argument was supplied, and false otherwise.
7207 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
7208 Remove \fIname\fPs from the list of defined aliases. If
7210 is supplied, all alias definitions are removed. The return
7211 value is true unless a supplied
7213 is not a defined alias.
7215 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
7218 remove the corresponding variable or function.
7219 If no options are supplied, or the
7221 option is given, each
7223 refers to a shell variable.
7224 Read-only variables may not be unset.
7230 refers to a shell function, and the function definition
7232 Each unset variable or function is removed from the environment
7233 passed to subsequent commands.
7246 are unset, they lose their special properties, even if they are
7247 subsequently reset. The exit status is true unless a
7249 does not exist or is readonly.
7251 \fBwait\fP [\fIn\fP]
7252 Wait for the specified process and return its termination
7256 ID or a job specification; if a job spec is given, all processes
7257 in that job's pipeline are waited for. If
7259 is not given, all currently active child processes
7260 are waited for, and the return status is zero. If
7262 specifies a non-existent process or job, the return status is
7263 127. Otherwise, the return status is the exit status of the last
7264 process or job waited for.
7267 .SH "RESTRICTED SHELL"
7271 is started with the name
7275 option is supplied at invocation,
7276 the shell becomes restricted.
7277 A restricted shell is used to
7278 set up an environment more controlled than the standard shell.
7279 It behaves identically to
7281 with the exception that the following are disallowed or not performed:
7283 changing directories with \fBcd\fP
7285 setting or unsetting the values of
7292 specifying command names containing
7295 specifying a file name containing a
7297 as an argument to the
7301 importing function definitions from the shell environment at startup
7303 parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
7305 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
7309 builtin command to replace the shell with another command
7311 adding or deleting builtin commands with the
7325 turning off restricted mode with
7326 \fBset +r\fP or \fBset +o restricted\fP.
7328 These restrictions are enforced after any startup files are read.
7330 When a command that is found to be a shell script is executed (see
7332 .B "COMMAND EXECUTION"
7335 turns off any restrictions in the shell spawned to execute the
7340 \fIBash Features\fP, Brian Fox and Chet Ramey
7342 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
7344 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
7346 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
7348 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
7350 \fIemacs\fP(1), \fIvi\fP(1)
7358 The \fBbash\fP executable
7361 The systemwide initialization file, executed for login shells
7364 The personal initialization file, executed for login shells
7367 The individual per-interactive-shell startup file
7370 The individual login shell cleanup file, executed when a login shell exits
7373 Individual \fIreadline\fP initialization file
7376 Brian Fox, Free Software Foundation
7380 Chet Ramey, Case Western Reserve University
7384 If you find a bug in
7386 you should report it. But first, you should
7387 make sure that it really is a bug, and that it appears in the latest
7392 Once you have determined that a bug actually exists, use the
7394 command to submit a bug report.
7395 If you have a fix, you are encouraged to mail that as well!
7396 Suggestions and `philosophical' bug reports may be mailed
7397 to \fIbug-bash@gnu.org\fP or posted to the Usenet
7401 ALL bug reports should include:
7405 The version number of \fBbash\fR
7407 The hardware and operating system
7409 The compiler used to compile
7411 A description of the bug behaviour
7413 A short script or `recipe' which exercises the bug
7417 inserts the first three items automatically into the template
7418 it provides for filing a bug report.
7420 Comments and bug reports concerning
7421 this manual page should be directed to
7422 .IR chet@ins.CWRU.Edu .
7425 It's too big and too slow.
7427 There are some subtle differences between
7429 and traditional versions of
7431 mostly because of the
7436 Aliases are confusing in some uses.
7438 Shell builtin commands and functions are not stoppable/restartable.
7440 Compound commands and command sequences of the form `a ; b ; c'
7441 are not handled gracefully when process suspension is attempted.
7442 When a process is stopped, the shell immediately executes the next
7443 command in the sequence.
7444 It suffices to place the sequence of commands between
7445 parentheses to force it into a subshell, which may be stopped as
7448 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
7449 parsed until substitution is attempted. This will delay error
7450 reporting until some time after the command is entered.
7452 Array variables may not (yet) be exported.