2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
9 .\" Last Change: Sat Aug 27 13:28:44 EDT 2005
11 .\" bash_builtins, strip all but Built-Ins section
14 .TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1"
16 .\" There's some problem with having a `@'
17 .\" in a tagged paragraph with the BSD man macros.
18 .\" It has to do with `@' appearing in the }1 macro.
19 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
20 .\" appears to have fixed it.
21 .\" If you're seeing the characters
22 .\" `@u-3p' appearing before the lines reading
23 .\" `possible-hostname-completions
24 .\" and `complete-hostname' down in READLINE,
25 .\" then uncomment this redefinition.
30 .if !"\\$1"" .nr )I \\$1n
33 .in \\n()Ru+\\n(INu+\\n()Iu
35 .ie !\\n()Iu+\\n()Ru-\w
\a\\*(]X
\au-3p \{\\*(]X
37 .el \\*(]X\h
\a|\\n()Iu+\\n()Ru
\a\c
41 .\" File Name macro. This used to be `.PN', for Path Name,
42 .\" but Sun doesn't seem to like that very much.
48 bash \- GNU Bourne-Again SHell
54 .if n Bash is Copyright (C) 1989-2005 by the Free Software Foundation, Inc.
55 .if t Bash is Copyright \(co 1989-2005 by the Free Software Foundation, Inc.
58 is an \fBsh\fR-compatible command language interpreter that
59 executes commands read from the standard input or from a file.
61 also incorporates useful features from the \fIKorn\fP and \fIC\fP
62 shells (\fBksh\fP and \fBcsh\fP).
65 is intended to be a conformant implementation of the IEEE
66 POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
68 can be configured to be POSIX-conformant by default.
70 In addition to the single-character shell options documented in the
71 description of the \fBset\fR builtin command, \fBbash\fR
72 interprets the following options when it is invoked:
79 option is present, then commands are read from
81 If there are arguments after the
83 they are assigned to the positional parameters, starting with
89 option is present, the shell is
95 act as if it had been invoked as a login shell (see
103 option is present, the shell becomes
107 .B "RESTRICTED SHELL"
113 option is present, or if no arguments remain after option
114 processing, then commands are read from the standard input.
115 This option allows the positional parameters to be set
116 when invoking an interactive shell.
119 A list of all double-quoted strings preceded by \fB$\fP
120 is printed on the standard output.
121 These are the strings that
122 are subject to language translation when the current locale
123 is not \fBC\fP or \fBPOSIX\fP.
124 This implies the \fB\-n\fP option; no commands will be executed.
126 .B [\-+]O [\fIshopt_option\fP]
127 \fIshopt_option\fP is one of the shell options accepted by the
128 \fBshopt\fP builtin (see
130 .B SHELL BUILTIN COMMANDS
132 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
134 If \fIshopt_option\fP is not supplied, the names and values of the shell
135 options accepted by \fBshopt\fP are printed on the standard output.
136 If the invocation option is \fB+O\fP, the output is displayed in a format
137 that may be reused as input.
142 signals the end of options and disables further option processing.
143 Any arguments after the
145 are treated as filenames and arguments. An argument of
147 is equivalent to \fB\-\-\fP.
151 also interprets a number of multi-character options.
152 These options must appear on the command line before the
153 single-character options to be recognized.
158 Arrange for the debugger profile to be executed before the shell
160 Turns on extended debugging mode (see the description of the
165 and shell function tracing (see the description of the
166 \fB\-o functrace\fP option to the
170 .B \-\-dump\-po\-strings
171 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
172 \fBpo\fP (portable object) file format.
175 Equivalent to \fB\-D\fP.
178 Display a usage message on standard output and exit successfully.
180 \fB\-\-init\-file\fP \fIfile\fP
183 \fB\-\-rcfile\fP \fIfile\fP
185 Execute commands from
187 instead of the standard personal initialization file
189 if the shell is interactive (see
195 Equivalent to \fB\-l\fP.
200 library to read command lines when the shell is interactive.
203 Do not read either the system-wide startup file
205 or any of the personal initialization files
206 .IR ~/.bash_profile ,
212 reads these files when it is invoked as a login shell (see
218 Do not read and execute the personal initialization file
220 if the shell is interactive.
221 This option is on by default if the shell is invoked as
225 Change the behavior of \fBbash\fP where the default operation differs
226 from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
229 The shell becomes restricted (see
231 .B "RESTRICTED SHELL"
235 Equivalent to \fB\-v\fP.
238 Show version information for this instance of
240 on the standard output and exit successfully.
243 If arguments remain after option processing, and neither the
247 option has been supplied, the first argument is assumed to
248 be the name of a file containing shell commands.
251 is invoked in this fashion,
253 is set to the name of the file, and the positional parameters
254 are set to the remaining arguments.
256 reads and executes commands from this file, then exits.
257 \fBBash\fP's exit status is the exit status of the last command
258 executed in the script.
259 If no commands are executed, the exit status is 0.
260 An attempt is first made to open the file in the current directory, and,
261 if no file is found, then the shell searches the directories in
266 A \fIlogin shell\fP is one whose first character of argument zero is a
268 or one started with the
272 An \fIinteractive\fP shell is one started without non-option arguments
276 whose standard input and error are
277 both connected to terminals (as determined by
279 or one started with the
291 allowing a shell script or a startup file to test this state.
293 The following paragraphs describe how
295 executes its startup files.
296 If any of the files exist but cannot be read,
299 Tildes are expanded in file names as described below under
308 is invoked as an interactive login shell, or as a non-interactive shell
309 with the \fB\-\-login\fP option, it first reads and
310 executes commands from the file \fI/etc/profile\fP, if that
312 After reading that file, it looks for \fI~/.bash_profile\fP,
313 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
314 and executes commands from the first one that exists and is readable.
317 option may be used when the shell is started to inhibit this behavior.
319 When a login shell exits,
321 reads and executes commands from the file \fI~/.bash_logout\fP, if it
324 When an interactive shell that is not a login shell is started,
326 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
327 This may be inhibited by using the
330 The \fB\-\-rcfile\fP \fIfile\fP option will force
332 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
336 is started non-interactively, to run a shell script, for example, it
337 looks for the variable
340 in the environment, expands its value if it appears there, and uses the
341 expanded value as the name of a file to read and execute.
343 behaves as if the following command were executed:
346 .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
347 .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
353 variable is not used to search for the file name.
357 is invoked with the name
359 it tries to mimic the startup behavior of historical versions of
361 as closely as possible,
362 while conforming to the POSIX standard as well.
363 When invoked as an interactive login shell, or a non-interactive
364 shell with the \fB\-\-login\fP option, it first attempts to
365 read and execute commands from
372 option may be used to inhibit this behavior.
373 When invoked as an interactive shell with the name
376 looks for the variable
379 expands its value if it is defined, and uses the
380 expanded value as the name of a file to read and execute.
381 Since a shell invoked as
383 does not attempt to read and execute commands from any other startup
386 option has no effect.
387 A non-interactive shell invoked with the name
389 does not attempt to read any other startup files.
395 mode after the startup files are read.
403 command line option, it follows the POSIX standard for startup files.
404 In this mode, interactive shells expand the
407 variable and commands are read and executed from the file
408 whose name is the expanded value.
409 No other startup files are read.
412 attempts to determine when it is being run by the remote shell
413 daemon, usually \fIrshd\fP.
416 determines it is being run by \fIrshd\fP, it reads and executes
417 commands from \fI~/.bashrc\fP, if that file exists and is readable.
418 It will not do this if invoked as \fBsh\fP.
421 option may be used to inhibit this behavior, and the
423 option may be used to force another file to be read, but
424 \fIrshd\fP does not generally invoke the shell with those options
425 or allow them to be specified.
427 If the shell is started with the effective user (group) id not equal to the
428 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
429 files are read, shell functions are not inherited from the environment, the
432 variable, if it appears in the environment, is ignored,
433 and the effective user id is set to the real user id.
434 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
435 the same, but the effective user id is not reset.
438 The following definitions are used throughout the rest of this
446 A sequence of characters considered as a single unit by the shell.
453 consisting only of alphanumeric characters and underscores, and
454 beginning with an alphabetic character or an underscore. Also
459 A character that, when unquoted, separates words. One of the following:
463 .if t \fB| & ; ( ) < > space tab\fP
464 .if n \fB| & ; ( ) < > space tab\fP
469 A \fItoken\fP that performs a control function. It is one of the following
473 .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
474 .if n \fB|| & && ; ;; ( ) | <newline>\fP
478 \fIReserved words\fP are words that have a special meaning to the shell.
479 The following words are recognized as reserved when unquoted and either
480 the first word of a simple command (see
483 below) or the third word of a
491 .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
492 .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
497 A \fIsimple command\fP is a sequence of optional variable assignments
498 followed by \fBblank\fP-separated words and redirections, and
499 terminated by a \fIcontrol operator\fP. The first word
500 specifies the command to be executed, and is passed as argument zero.
501 The remaining words are passed as arguments to the invoked command.
503 The return value of a \fIsimple command\fP is its exit status, or
504 128+\fIn\^\fP if the command is terminated by signal
508 A \fIpipeline\fP is a sequence of one or more commands separated by
511 The format for a pipeline is:
514 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
517 The standard output of
519 is connected via a pipe to the standard input of
521 This connection is performed before any redirections specified by the
527 The return status of a pipeline is the exit status of the last
528 command, unless the \fBpipefail\fP option is enabled.
529 If \fBpipefail\fP is enabled, the pipeline's return status is the
530 value of the last (rightmost) command to exit with a non-zero status,
531 or zero if all commands exit successfully.
534 precedes a pipeline, the exit status of that pipeline is the logical
535 negation of the exit status as described above.
536 The shell waits for all commands in the pipeline to
537 terminate before returning a value.
541 reserved word precedes a pipeline, the elapsed as well as user and
542 system time consumed by its execution are reported when the pipeline
544 The \fB\-p\fP option changes the output format to that specified by POSIX.
548 variable may be set to a format string that specifies how the timing
549 information should be displayed; see the description of
556 Each command in a pipeline is executed as a separate process (i.e., in a
560 A \fIlist\fP is a sequence of one or more pipelines separated by one
567 and optionally terminated by one of
573 Of these list operators,
577 have equal precedence, followed by
581 which have equal precedence.
583 A sequence of one or more newlines may appear in a \fIlist\fP instead
584 of a semicolon to delimit commands.
586 If a command is terminated by the control operator
588 the shell executes the command in the \fIbackground\fP
589 in a subshell. The shell does not wait for the command to
590 finish, and the return status is 0. Commands separated by a
592 are executed sequentially; the shell waits for each
593 command to terminate in turn. The return status is the
594 exit status of the last command executed.
596 The control operators
600 denote AND lists and OR lists, respectively.
601 An AND list has the form
604 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
608 is executed if, and only if,
610 returns an exit status of zero.
612 An OR list has the form
615 \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
620 is executed if and only if
622 returns a non-zero exit status. The return status of
623 AND and OR lists is the exit status of the last command
624 executed in the list.
625 .SS Compound Commands
627 A \fIcompound command\fP is one of the following:
630 \fIlist\fP is executed in a subshell environment (see
632 \fBCOMMAND EXECUTION ENVIRONMENT\fP
634 Variable assignments and builtin
635 commands that affect the shell's environment do not remain in effect
636 after the command completes. The return status is the exit status of
640 \fIlist\fP is simply executed in the current shell environment.
641 \fIlist\fP must be terminated with a newline or semicolon.
642 This is known as a \fIgroup command\fP.
643 The return status is the exit status of
645 Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
646 \fB}\fP are \fIreserved words\fP and must occur where a reserved
647 word is permitted to be recognized. Since they do not cause a word
648 break, they must be separated from \fIlist\fP by whitespace.
651 The \fIexpression\fP is evaluated according to the rules described
654 .BR "ARITHMETIC EVALUATION" .
655 If the value of the expression is non-zero, the return status is 0;
656 otherwise the return status is 1. This is exactly equivalent to
657 \fBlet "\fIexpression\fP"\fR.
659 \fB[[\fP \fIexpression\fP \fB]]\fP
660 Return a status of 0 or 1 depending on the evaluation of
661 the conditional expression \fIexpression\fP.
662 Expressions are composed of the primaries described below under
664 .BR "CONDITIONAL EXPRESSIONS" .
665 Word splitting and pathname expansion are not performed on the words
666 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
667 variable expansion, arithmetic expansion, command substitution, process
668 substitution, and quote removal are performed.
669 Conditional operators such as \fB\-f\fP must be unquoted to be recognized
673 When the \fB==\fP and \fB!=\fP operators are used, the string to the
674 right of the operator is considered a pattern and matched according
675 to the rules described below under \fBPattern Matching\fP.
678 is enabled, the match is performed without regard to the case
679 of alphabetic characters.
680 The return value is 0 if the string matches or does not match
681 the pattern, respectively, and 1 otherwise.
682 Any part of the pattern may be quoted to force it to be matched as a
686 An additional binary operator, \fB=~\fP, is available, with the same
687 precedence as \fB==\fP and \fB!=\fP.
688 When it is used, the string to the right of the operator is considered
689 an extended regular expression and matched accordingly (as in \fIregex\fP(3)).
690 The return value is 0 if the string matches
691 the pattern, and 1 otherwise.
692 If the regular expression is syntactically incorrect, the conditional
693 expression's return value is 2.
696 is enabled, the match is performed without regard to the case
697 of alphabetic characters.
698 Substrings matched by parenthesized subexpressions within the regular
699 expression are saved in the array variable \fBBASH_REMATCH\fP.
700 The element of \fBBASH_REMATCH\fP with index 0 is the portion of the string
701 matching the entire regular expression.
702 The element of \fBBASH_REMATCH\fP with index \fIn\fP is the portion of the
703 string matching the \fIn\fPth parenthesized subexpression.
706 Expressions may be combined using the following operators, listed
707 in decreasing order of precedence:
713 .B ( \fIexpression\fP )
714 Returns the value of \fIexpression\fP.
715 This may be used to override the normal precedence of operators.
717 .B ! \fIexpression\fP
722 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
729 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
730 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
741 operators do not evaluate \fIexpression2\fP if the value of
742 \fIexpression1\fP is sufficient to determine the return value of
743 the entire conditional expression.
746 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
747 The list of words following \fBin\fP is expanded, generating a list
749 The variable \fIname\fP is set to each element of this list
750 in turn, and \fIlist\fP is executed each time.
751 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
752 \fIlist\fP once for each positional parameter that is set (see
756 The return status is the exit status of the last command that executes.
757 If the expansion of the items following \fBin\fP results in an empty
758 list, no commands are executed, and the return status is 0.
760 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
761 First, the arithmetic expression \fIexpr1\fP is evaluated according
762 to the rules described below under
764 .BR "ARITHMETIC EVALUATION" .
765 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
766 until it evaluates to zero.
767 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
768 executed and the arithmetic expression \fIexpr3\fP is evaluated.
769 If any expression is omitted, it behaves as if it evaluates to 1.
770 The return value is the exit status of the last command in \fIlist\fP
771 that is executed, or false if any of the expressions is invalid.
773 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
774 The list of words following \fBin\fP is expanded, generating a list
775 of items. The set of expanded words is printed on the standard
776 error, each preceded by a number. If the \fBin\fP
777 \fIword\fP is omitted, the positional parameters are printed (see
782 prompt is then displayed and a line read from the standard input.
783 If the line consists of a number corresponding to one of
784 the displayed words, then the value of
786 is set to that word. If the line is empty, the words and prompt
787 are displayed again. If EOF is read, the command completes. Any
788 other value read causes
790 to be set to null. The line read is saved in the variable
794 is executed after each selection until a
799 is the exit status of the last command executed in
801 or zero if no commands were executed.
803 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
804 ... ) \fIlist\fP ;; ] ... \fBesac\fP
805 A \fBcase\fP command first expands \fIword\fP, and tries to match
806 it against each \fIpattern\fP in turn, using the same matching rules
807 as for pathname expansion (see
808 .B Pathname Expansion
812 is enabled, the match is performed without regard to the case
813 of alphabetic characters.
814 When a match is found, the
815 corresponding \fIlist\fP is executed. After the first match, no
816 subsequent matches are attempted. The exit status is zero if no
817 pattern matches. Otherwise, it is the exit status of the
818 last command executed in \fIlist\fP.
820 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
821 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
822 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
826 is executed. If its exit status is zero, the
827 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
828 \fIlist\fP is executed in turn, and if its exit status is zero,
829 the corresponding \fBthen\fP \fIlist\fP is executed and the
830 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
831 executed, if present. The exit status is the exit status of the
832 last command executed, or zero if no condition tested true.
834 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
837 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
839 The \fBwhile\fP command continuously executes the \fBdo\fP
840 \fIlist\fP as long as the last command in \fIlist\fP returns
841 an exit status of zero. The \fBuntil\fP command is identical
842 to the \fBwhile\fP command, except that the test is negated;
846 is executed as long as the last command in
848 returns a non-zero exit status.
849 The exit status of the \fBwhile\fP and \fBuntil\fP commands
851 of the last \fBdo\fP \fIlist\fP command executed, or zero if
853 .SS Shell Function Definitions
855 A shell function is an object that is called like a simple command and
856 executes a compound command with a new set of positional parameters.
857 Shell functions are declared as follows:
859 [ \fBfunction\fP ] \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP]
860 This defines a function named \fIname\fP.
861 The reserved word \fBfunction\fP is optional.
862 If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
863 The \fIbody\fP of the function is the compound command
865 (see \fBCompound Commands\fP above).
866 That command is usually a \fIlist\fP of commands between { and }, but
867 may be any command listed under \fBCompound Commands\fP above.
868 \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the
869 name of a simple command.
870 Any redirections (see
873 below) specified when a function is defined are performed
874 when the function is executed.
875 The exit status of a function definition is zero unless a syntax error
876 occurs or a readonly function with the same name already exists.
877 When executed, the exit status of a function is the exit status of the
878 last command executed in the body. (See
883 In a non-interactive shell, or an interactive shell in which the
884 .B interactive_comments
887 builtin is enabled (see
889 .B "SHELL BUILTIN COMMANDS"
890 below), a word beginning with
892 causes that word and all remaining characters on that line to
893 be ignored. An interactive shell without the
894 .B interactive_comments
895 option enabled does not allow comments. The
896 .B interactive_comments
897 option is on by default in interactive shells.
899 \fIQuoting\fP is used to remove the special meaning of certain
900 characters or words to the shell. Quoting can be used to
901 disable special treatment for special characters, to prevent
902 reserved words from being recognized as such, and to prevent
905 Each of the \fImetacharacters\fP listed above under
908 has special meaning to the shell and must be quoted if it is to
911 When the command history expansion facilities are being used
916 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
917 to prevent history expansion.
919 There are three quoting mechanisms: the
920 .IR "escape character" ,
921 single quotes, and double quotes.
923 A non-quoted backslash (\fB\e\fP) is the
924 .IR "escape character" .
925 It preserves the literal value of the next character that follows,
926 with the exception of <newline>. If a \fB\e\fP<newline> pair
927 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
928 is treated as a line continuation (that is, it is removed from the
929 input stream and effectively ignored).
931 Enclosing characters in single quotes preserves the literal value
932 of each character within the quotes. A single quote may not occur
933 between single quotes, even when preceded by a backslash.
935 Enclosing characters in double quotes preserves the literal value
936 of all characters within the quotes, with the exception of
940 and, when history expansion is enabled,
946 retain their special meaning within double quotes. The backslash
947 retains its special meaning only when followed by one of the following
955 A double quote may be quoted within double quotes by preceding it with
957 If enabled, history expansion will be performed unless an
959 appearing in double quotes is escaped using a backslash.
960 The backslash preceding the
964 The special parameters
968 have special meaning when in double
974 Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
975 word expands to \fIstring\fP, with backslash-escaped characters replaced
976 as specified by the ANSI C standard. Backslash escape sequences, if
977 present, are decoded as follows:
1012 the eight-bit character whose value is the octal value \fInnn\fP
1013 (one to three digits)
1016 the eight-bit character whose value is the hexadecimal value \fIHH\fP
1017 (one or two hex digits)
1020 a control-\fIx\fP character
1024 The expanded result is single-quoted, as if the dollar sign had
1027 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
1028 the string to be translated according to the current locale.
1029 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
1031 If the string is translated and replaced, the replacement is
1036 is an entity that stores values.
1039 a number, or one of the special characters listed below under
1040 .BR "Special Parameters" .
1043 is a parameter denoted by a
1045 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
1046 Attributes are assigned using the
1048 builtin command (see
1052 .BR "SHELL BUILTIN COMMANDS" ).
1054 A parameter is set if it has been assigned a value. The null string is
1055 a valid value. Once a variable is set, it may be unset only by using
1058 builtin command (see
1060 .B SHELL BUILTIN COMMANDS
1065 may be assigned to by a statement of the form
1068 \fIname\fP=[\fIvalue\fP]
1073 is not given, the variable is assigned the null string. All
1075 undergo tilde expansion, parameter and variable expansion,
1076 command substitution, arithmetic expansion, and quote
1080 below). If the variable has its
1084 is evaluated as an arithmetic expression even if the $((...)) expansion is
1086 .B "Arithmetic Expansion"
1088 Word splitting is not performed, with the exception
1089 of \fB"$@"\fP as explained below under
1090 .BR "Special Parameters" .
1091 Pathname expansion is not performed.
1092 Assignment statements may also appear as arguments to the
1102 In the context where an assignment statement is assigning a value
1103 to a shell variable or array index, the += operator can be used to
1104 append to or add to the variable's previous value.
1105 When += is applied to a variable for which the integer attribute has been
1106 set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
1107 variable's current value, which is also evaluated.
1108 When += is applied to an array variable using compound assignment (see
1111 variable's value is not unset (as it is when using =), and new values are
1112 appended to the array beginning at one greater than the array's maximum index.
1113 When applied to a string-valued variable, \fIvalue\fP is expanded and
1114 appended to the variable's value.
1115 .SS Positional Parameters
1118 .I positional parameter
1119 is a parameter denoted by one or more
1120 digits, other than the single digit 0. Positional parameters are
1121 assigned from the shell's arguments when it is invoked,
1122 and may be reassigned using the
1124 builtin command. Positional parameters may not be assigned to
1125 with assignment statements. The positional parameters are
1126 temporarily replaced when a shell function is executed (see
1131 When a positional parameter consisting of more than a single
1132 digit is expanded, it must be enclosed in braces (see
1136 .SS Special Parameters
1138 The shell treats several parameters specially. These parameters may
1139 only be referenced; assignment to them is not allowed.
1143 Expands to the positional parameters, starting from one. When the
1144 expansion occurs within double quotes, it expands to a single word
1145 with the value of each parameter separated by the first character
1149 special variable. That is, "\fB$*\fP" is equivalent
1150 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1152 is the first character of the value of the
1158 is unset, the parameters are separated by spaces.
1162 is null, the parameters are joined without intervening separators.
1165 Expands to the positional parameters, starting from one. When the
1166 expansion occurs within double quotes, each parameter expands to a
1167 separate word. That is, "\fB$@\fP" is equivalent to
1168 "\fB$1\fP" "\fB$2\fP" ...
1169 If the double-quoted expansion occurs within a word, the expansion of
1170 the first parameter is joined with the beginning part of the original
1171 word, and the expansion of the last parameter is joined with the last
1172 part of the original word.
1173 When there are no positional parameters, "\fB$@\fP" and
1175 expand to nothing (i.e., they are removed).
1178 Expands to the number of positional parameters in decimal.
1181 Expands to the status of the most recently executed foreground
1185 Expands to the current option flags as specified upon invocation,
1188 builtin command, or those set by the shell itself
1194 Expands to the process ID of the shell. In a () subshell, it
1195 expands to the process ID of the current shell, not the
1199 Expands to the process ID of the most recently executed background
1200 (asynchronous) command.
1203 Expands to the name of the shell or shell script. This is set at
1204 shell initialization. If
1206 is invoked with a file of commands,
1208 is set to the name of that file. If
1214 is set to the first argument after the string to be
1215 executed, if one is present. Otherwise, it is set
1216 to the file name used to invoke
1218 as given by argument zero.
1221 At shell startup, set to the absolute pathname used to invoke the
1222 shell or shell script being executed as passed in the environment
1224 Subsequently, expands to the last argument to the previous command,
1226 Also set to the full pathname used to invoke each command executed
1227 and placed in the environment exported to that command.
1228 When checking mail, this parameter holds the name of the mail file
1229 currently being checked.
1233 The following variables are set by the shell:
1238 Expands to the full file name used to invoke this instance of
1242 An array variable whose values are the number of parameters in each
1243 frame of the current bash execution call stack.
1245 parameters to the current subroutine (shell function or script executed
1246 with \fB.\fP or \fBsource\fP) is at the top of the stack.
1247 When a subroutine is executed, the number of parameters passed is pushed onto
1249 The shell sets \fBBASH_ARGC\fP only when in extended debugging mode
1250 (see the description of the
1257 An array variable containing all of the parameters in the current bash
1258 execution call stack. The final parameter of the last subroutine call
1259 is at the top of the stack; the first parameter of the initial call is
1260 at the bottom. When a subroutine is executed, the parameters supplied
1261 are pushed onto \fBBASH_ARGV\fP.
1262 The shell sets \fBBASH_ARGV\fP only when in extended debugging mode
1263 (see the description of the
1270 The command currently being executed or about to be executed, unless the
1271 shell is executing a command as the result of a trap,
1272 in which case it is the command executing at the time of the trap.
1274 .B BASH_EXECUTION_STRING
1275 The command argument to the \fB\-c\fP invocation option.
1278 An array variable whose members are the line numbers in source files
1279 corresponding to each member of \fBFUNCNAME\fP.
1280 \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
1281 file where \fB${FUNCNAME[\fP\fI$ifP\fB]}\fP was called.
1282 The corresponding source file name is \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fB.
1283 Use \fBLINENO\fP to obtain the current line number.
1286 An array variable whose members are assigned by the \fB=~\fP binary
1287 operator to the \fB[[\fP conditional command.
1288 The element with index 0 is the portion of the string
1289 matching the entire regular expression.
1290 The element with index \fIn\fP is the portion of the
1291 string matching the \fIn\fPth parenthesized subexpression.
1292 This variable is read-only.
1295 An array variable whose members are the source filenames corresponding
1296 to the elements in the \fBFUNCNAME\fP array variable.
1299 Incremented by one each time a subshell or subshell environment is spawned.
1300 The initial value is 0.
1303 A readonly array variable whose members hold version information for
1306 The values assigned to the array members are as follows:
1311 .B BASH_VERSINFO[\fR0\fP]
1312 The major version number (the \fIrelease\fP).
1314 .B BASH_VERSINFO[\fR1\fP]
1315 The minor version number (the \fIversion\fP).
1317 .B BASH_VERSINFO[\fR2\fP]
1320 .B BASH_VERSINFO[\fR3\fP]
1323 .B BASH_VERSINFO[\fR4\fP]
1324 The release status (e.g., \fIbeta1\fP).
1326 .B BASH_VERSINFO[\fR5\fP]
1327 The value of \fBMACHTYPE\fP.
1332 Expands to a string describing the version of this instance of
1336 An index into \fB${COMP_WORDS}\fP of the word containing the current
1338 This variable is available only in shell functions invoked by the
1339 programmable completion facilities (see \fBProgrammable Completion\fP
1343 The current command line.
1344 This variable is available only in shell functions and external
1345 commands invoked by the
1346 programmable completion facilities (see \fBProgrammable Completion\fP
1350 The index of the current cursor position relative to the beginning of
1351 the current command.
1352 If the current cursor position is at the end of the current command,
1353 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1354 This variable is available only in shell functions and external
1355 commands invoked by the
1356 programmable completion facilities (see \fBProgrammable Completion\fP
1360 The set of characters that the Readline library treats as word
1361 separators when performing word completion.
1365 is unset, it loses its special properties, even if it is
1369 An array variable (see \fBArrays\fP below) consisting of the individual
1370 words in the current command line.
1371 This variable is available only in shell functions invoked by the
1372 programmable completion facilities (see \fBProgrammable Completion\fP
1376 An array variable (see
1378 below) containing the current contents of the directory stack.
1379 Directories appear in the stack in the order they are displayed by the
1382 Assigning to members of this array variable may be used to modify
1383 directories already in the stack, but the
1387 builtins must be used to add and remove directories.
1388 Assignment to this variable will not change the current directory.
1392 is unset, it loses its special properties, even if it is
1396 Expands to the effective user ID of the current user, initialized at
1397 shell startup. This variable is readonly.
1400 An array variable containing the names of all shell functions
1401 currently in the execution call stack.
1402 The element with index 0 is the name of any currently-executing
1404 The bottom-most element is "main".
1405 This variable exists only when a shell function is executing.
1409 have no effect and return an error status.
1413 is unset, it loses its special properties, even if it is
1417 An array variable containing the list of groups of which the current
1422 have no effect and return an error status.
1426 is unset, it loses its special properties, even if it is
1430 The history number, or index in the history list, of the current
1435 is unset, it loses its special properties, even if it is
1439 Automatically set to the name of the current host.
1442 Automatically set to a string that uniquely
1443 describes the type of machine on which
1446 The default is system-dependent.
1449 Each time this parameter is referenced, the shell substitutes
1450 a decimal number representing the current sequential line number
1451 (starting with 1) within a script or function. When not in a
1452 script or function, the value substituted is not guaranteed to
1457 is unset, it loses its special properties, even if it is
1461 Automatically set to a string that fully describes the system
1464 is executing, in the standard GNU \fIcpu-company-system\fP format.
1465 The default is system-dependent.
1468 The previous working directory as set by the
1473 The value of the last option argument processed by the
1475 builtin command (see
1477 .B SHELL BUILTIN COMMANDS
1481 The index of the next argument to be processed by the
1483 builtin command (see
1485 .B SHELL BUILTIN COMMANDS
1489 Automatically set to a string that
1490 describes the operating system on which
1493 The default is system-dependent.
1496 An array variable (see
1498 below) containing a list of exit status values from the processes
1499 in the most-recently-executed foreground pipeline (which may
1500 contain only a single command).
1503 The process ID of the shell's parent. This variable is readonly.
1506 The current working directory as set by the
1511 Each time this parameter is referenced, a random integer between
1513 generated. The sequence of random numbers may be initialized by assigning
1520 is unset, it loses its special properties, even if it is
1524 Set to the line of input read by the
1526 builtin command when no arguments are supplied.
1529 Each time this parameter is
1530 referenced, the number of seconds since shell invocation is returned. If a
1531 value is assigned to
1534 the value returned upon subsequent
1536 the number of seconds since the assignment plus the value assigned.
1540 is unset, it loses its special properties, even if it is
1544 A colon-separated list of enabled shell options. Each word in
1545 the list is a valid argument for the
1549 builtin command (see
1551 .B "SHELL BUILTIN COMMANDS"
1552 below). The options appearing in
1555 are those reported as
1558 If this variable is in the environment when
1560 starts up, each shell option in the list will be enabled before
1561 reading any startup files.
1562 This variable is read-only.
1565 Incremented by one each time an instance of
1570 Expands to the user ID of the current user, initialized at shell startup.
1571 This variable is readonly.
1574 The following variables are used by the shell. In some cases,
1576 assigns a default value to a variable; these cases are noted
1582 If this parameter is set when \fBbash\fP is executing a shell script,
1583 its value is interpreted as a filename containing commands to
1584 initialize the shell, as in
1589 is subjected to parameter expansion, command substitution, and arithmetic
1590 expansion before being interpreted as a file name.
1593 is not used to search for the resultant file name.
1596 The search path for the
1599 This is a colon-separated list of directories in which the shell looks
1600 for destination directories specified by the
1604 .if t \f(CW".:~:/usr"\fP.
1608 Used by the \fBselect\fP builtin command to determine the terminal width
1609 when printing selection lists. Automatically set upon receipt of a SIGWINCH.
1612 An array variable from which \fBbash\fP reads the possible completions
1613 generated by a shell function invoked by the programmable completion
1614 facility (see \fBProgrammable Completion\fP below).
1617 If \fBbash\fP finds this variable in the environment when the shell starts
1621 it assumes that the shell is running in an emacs shell buffer and disables
1625 The default editor for the
1630 A colon-separated list of suffixes to ignore when performing
1631 filename completion (see
1635 A filename whose suffix matches one of the entries in
1638 is excluded from the list of matched filenames.
1640 .if t \f(CW".o:~"\fP.
1644 A colon-separated list of patterns defining the set of filenames to
1645 be ignored by pathname expansion.
1646 If a filename matched by a pathname expansion pattern also matches one
1650 it is removed from the list of matches.
1653 A colon-separated list of values controlling how commands are saved on
1655 If the list of values includes
1657 lines which begin with a
1659 character are not saved in the history list.
1662 causes lines matching the previous history entry to not be saved.
1665 is shorthand for \fIignorespace\fP and \fIignoredups\fP.
1668 causes all previous lines matching the current line to be removed from
1669 the history list before that line is saved.
1670 Any value not in the above list is ignored.
1671 If \fBHISTCONTROL\fP is unset, or does not include a valid value,
1672 all lines read by the shell parser are saved on the history list,
1673 subject to the value of
1675 The second and subsequent lines of a multi-line compound command are
1676 not tested, and are added to the history regardless of the value of
1680 The name of the file in which command history is saved (see
1683 below). The default value is \fI~/.bash_history\fP. If unset, the
1684 command history is not saved when an interactive shell exits.
1687 The maximum number of lines contained in the history file. When this
1688 variable is assigned a value, the history file is truncated, if
1689 necessary, to contain no more than that number of lines. The default
1690 value is 500. The history file is also truncated to this size after
1691 writing it when an interactive shell exits.
1694 A colon-separated list of patterns used to decide which command lines
1695 should be saved on the history list. Each pattern is anchored at the
1696 beginning of the line and must match the complete line (no implicit
1697 `\fB*\fP' is appended). Each pattern is tested against the line
1698 after the checks specified by
1701 In addition to the normal shell pattern matching characters, `\fB&\fP'
1702 matches the previous history line. `\fB&\fP' may be escaped using a
1703 backslash; the backslash is removed before attempting a match.
1704 The second and subsequent lines of a multi-line compound command are
1705 not tested, and are added to the history regardless of the value of
1709 The number of commands to remember in the command history (see
1712 below). The default value is 500.
1715 If this variable is set and not null, its value is used as a format string
1716 for \fIstrftime\fP(3) to print the time stamp associated with each history
1717 entry displayed by the \fBhistory\fP builtin.
1718 If this variable is set, time stamps are written to the history file so
1719 they may be preserved across shell sessions.
1722 The home directory of the current user; the default argument for the
1723 \fBcd\fP builtin command.
1724 The value of this variable is also used when performing tilde expansion.
1727 Contains the name of a file in the same format as
1729 that should be read when the shell needs to complete a
1731 The list of possible hostname completions may be changed while the
1733 the next time hostname completion is attempted after the
1736 adds the contents of the new file to the existing list.
1740 is set, but has no value, \fBbash\fP attempts to read
1742 to obtain the list of possible hostname completions.
1746 is unset, the hostname list is cleared.
1750 .I Internal Field Separator
1752 for word splitting after expansion and to
1753 split lines into words with the
1755 builtin command. The default value is
1756 ``<space><tab><newline>''.
1760 action of an interactive shell on receipt of an
1763 character as the sole input. If set, the value is the number of
1767 characters which must be
1768 typed as the first characters on an input line before
1770 exits. If the variable exists but does not have a numeric value, or
1771 has no value, the default value is 10. If it does not exist,
1774 signifies the end of input to the shell.
1777 The filename for the
1779 startup file, overriding the default of
1787 Used to determine the locale category for any category not specifically
1788 selected with a variable starting with \fBLC_\fP.
1791 This variable overrides the value of \fBLANG\fP and any other
1792 \fBLC_\fP variable specifying a locale category.
1795 This variable determines the collation order used when sorting the
1796 results of pathname expansion, and determines the behavior of range
1797 expressions, equivalence classes, and collating sequences within
1798 pathname expansion and pattern matching.
1801 This variable determines the interpretation of characters and the
1802 behavior of character classes within pathname expansion and pattern
1806 This variable determines the locale used to translate double-quoted
1807 strings preceded by a \fB$\fP.
1810 This variable determines the locale category used for number formatting.
1813 Used by the \fBselect\fP builtin command to determine the column length
1814 for printing selection lists. Automatically set upon receipt of a SIGWINCH.
1817 If this parameter is set to a file name and the
1820 variable is not set,
1822 informs the user of the arrival of mail in the specified file.
1828 checks for mail. The default is 60 seconds. When it is time to check
1829 for mail, the shell does so before displaying the primary prompt.
1830 If this variable is unset, or set to a value that is not a number
1831 greater than or equal to zero, the shell disables mail checking.
1834 A colon-separated list of file names to be checked for mail.
1835 The message to be printed when mail arrives in a particular file
1836 may be specified by separating the file name from the message with a `?'.
1837 When used in the text of the message, \fB$_\fP expands to the name of
1838 the current mailfile.
1842 \fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1845 supplies a default value for this variable, but the location of the user
1846 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
1850 If set to the value 1,
1852 displays error messages generated by the
1854 builtin command (see
1856 .B SHELL BUILTIN COMMANDS
1860 is initialized to 1 each time the shell is invoked or a shell
1864 The search path for commands. It
1865 is a colon-separated list of directories in which
1866 the shell looks for commands (see
1868 .B COMMAND EXECUTION
1870 A zero-length (null) directory name in the value of \fBPATH\fP indicates the
1872 A null directory name may appear as two adjacent colons, or as an initial
1874 The default path is system-dependent,
1875 and is set by the administrator who installs
1878 .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin\fP.
1879 .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
1882 If this variable is in the environment when \fBbash\fP starts, the shell
1883 enters \fIposix mode\fP before reading the startup files, as if the
1885 invocation option had been supplied. If it is set while the shell is
1886 running, \fBbash\fP enables \fIposix mode\fP, as if the command
1887 .if t \f(CWset -o posix\fP
1888 .if n \fIset -o posix\fP
1892 If set, the value is executed as a command prior to issuing each primary
1896 The value of this parameter is expanded (see
1899 below) and used as the primary prompt string. The default value is
1900 ``\fB\es\-\ev\e$ \fP''.
1903 The value of this parameter is expanded as with
1905 and used as the secondary prompt string. The default is
1909 The value of this parameter is used as the prompt for the
1917 The value of this parameter is expanded as with
1919 and the value is printed before each command
1921 displays during an execution trace. The first character of
1924 is replicated multiple times, as necessary, to indicate multiple
1925 levels of indirection. The default is ``\fB+ \fP''.
1928 The full pathname to the shell is kept in this environment variable.
1929 If it is not set when the shell starts,
1931 assigns to it the full pathname of the current user's login shell.
1934 The value of this parameter is used as a format string specifying
1935 how the timing information for pipelines prefixed with the
1937 reserved word should be displayed.
1938 The \fB%\fP character introduces an escape sequence that is
1939 expanded to a time value or other information.
1940 The escape sequences and their meanings are as follows; the
1941 braces denote optional portions.
1950 The elapsed time in seconds.
1953 The number of CPU seconds spent in user mode.
1956 The number of CPU seconds spent in system mode.
1959 The CPU percentage, computed as (%U + %S) / %R.
1963 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1964 the number of fractional digits after a decimal point.
1965 A value of 0 causes no decimal point or fraction to be output.
1966 At most three places after the decimal point may be specified;
1967 values of \fIp\fP greater than 3 are changed to 3.
1968 If \fIp\fP is not specified, the value 3 is used.
1970 The optional \fBl\fP specifies a longer format, including
1971 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1972 The value of \fIp\fP determines whether or not the fraction is
1975 If this variable is not set, \fBbash\fP acts as if it had the
1976 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1977 If the value is null, no timing information is displayed.
1978 A trailing newline is added when the format string is displayed.
1981 If set to a value greater than zero, \fBTMOUT\fP is treated as the
1982 default timeout for the \fBread\fP builtin.
1983 The \fBselect\fP command terminates if input does not arrive
1984 after \fBTMOUT\fP seconds when input is coming from a terminal.
1985 In an interactive shell, the value is interpreted as the
1986 number of seconds to wait for input after issuing the primary prompt.
1988 terminates after waiting for that number of seconds if input does
1992 If set, \fBBash\fP uses its value as the name of a directory in which
1993 \fBBash\fP creates temporary files for the shell's use.
1996 This variable controls how the shell interacts with the user and
1997 job control. If this variable is set, single word simple
1998 commands without redirections are treated as candidates for resumption
1999 of an existing stopped job. There is no ambiguity allowed; if there is
2000 more than one job beginning with the string typed, the job most recently
2001 accessed is selected. The
2003 of a stopped job, in this context, is the command line used to
2007 the string supplied must match the name of a stopped job exactly;
2010 the string supplied needs to match a substring of the name of a
2013 value provides functionality analogous to the
2018 below). If set to any other value, the supplied string must
2019 be a prefix of a stopped job's name; this provides functionality
2020 analogous to the \fB%\fP\fIstring\fP job identifier.
2023 The two or three characters which control history expansion
2024 and tokenization (see
2026 .B HISTORY EXPANSION
2027 below). The first character is the \fIhistory expansion\fP character,
2028 the character which signals the start of a history
2029 expansion, normally `\fB!\fP'.
2030 The second character is the \fIquick substitution\fP
2031 character, which is used as shorthand for re-running the previous
2032 command entered, substituting one string for another in the command.
2033 The default is `\fB^\fP'.
2034 The optional third character is the character
2035 which indicates that the remainder of the line is a comment when found
2036 as the first character of a word, normally `\fB#\fP'. The history
2037 comment character causes history substitution to be skipped for the
2038 remaining words on the line. It does not necessarily cause the shell
2039 parser to treat the rest of the line as a comment.
2043 provides one-dimensional array variables. Any variable may be used as
2046 builtin will explicitly declare an array. There is no maximum
2047 limit on the size of an array, nor any requirement that members
2048 be indexed or assigned contiguously. Arrays are indexed using
2049 integers and are zero-based.
2051 An array is created automatically if any variable is assigned to using
2052 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
2054 is treated as an arithmetic expression that must evaluate to a number
2055 greater than or equal to zero. To explicitly declare an array, use
2056 .B declare \-a \fIname\fP
2059 .B SHELL BUILTIN COMMANDS
2061 .B declare \-a \fIname\fP[\fIsubscript\fP]
2062 is also accepted; the \fIsubscript\fP is ignored. Attributes may be
2063 specified for an array variable using the
2067 builtins. Each attribute applies to all members of an array.
2069 Arrays are assigned to using compound assignments of the form
2070 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
2071 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
2072 \fIstring\fP is required. If
2073 the optional brackets and subscript are supplied, that index is assigned to;
2074 otherwise the index of the element assigned is the last index assigned
2075 to by the statement plus one. Indexing starts at zero.
2076 This syntax is also accepted by the
2078 builtin. Individual array elements may be assigned to using the
2079 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
2081 Any element of an array may be referenced using
2082 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
2083 conflicts with pathname expansion. If
2084 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
2085 all members of \fIname\fP. These subscripts differ only when the
2086 word appears within double quotes. If the word is double-quoted,
2087 ${\fIname\fP[*]} expands to a single
2088 word with the value of each array member separated by the first
2092 special variable, and ${\fIname\fP[@]} expands each element of
2093 \fIname\fP to a separate word. When there are no array members,
2094 ${\fIname\fP[@]} expands to nothing.
2095 If the double-quoted expansion occurs within a word, the expansion of
2096 the first parameter is joined with the beginning part of the original
2097 word, and the expansion of the last parameter is joined with the last
2098 part of the original word.
2099 This is analogous to the expansion
2100 of the special parameters \fB*\fP and \fB@\fP (see
2101 .B Special Parameters
2102 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
2103 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
2104 \fB@\fP, the expansion is the number of elements in the array.
2105 Referencing an array variable without a subscript is equivalent to
2106 referencing element zero.
2110 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
2111 destroys the array element at index \fIsubscript\fP.
2112 Care must be taken to avoid unwanted side effects caused by filename
2114 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
2115 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
2116 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
2123 builtins each accept a
2125 option to specify an array. The
2129 option to assign a list of words read from the standard input
2134 builtins display array values in a way that allows them to be
2135 reused as assignments.
2137 Expansion is performed on the command line after it has been split into
2138 words. There are seven kinds of expansion performed:
2139 .IR "brace expansion" ,
2140 .IR "tilde expansion" ,
2141 .IR "parameter and variable expansion" ,
2142 .IR "command substitution" ,
2143 .IR "arithmetic expansion" ,
2144 .IR "word splitting" ,
2146 .IR "pathname expansion" .
2148 The order of expansions is: brace expansion, tilde expansion,
2149 parameter, variable and arithmetic expansion and
2150 command substitution
2151 (done in a left-to-right fashion), word splitting, and pathname
2154 On systems that can support it, there is an additional expansion
2155 available: \fIprocess substitution\fP.
2157 Only brace expansion, word splitting, and pathname expansion
2158 can change the number of words of the expansion; other expansions
2159 expand a single word to a single word.
2160 The only exceptions to this are the expansions of
2161 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
2162 as explained above (see
2167 .I "Brace expansion"
2168 is a mechanism by which arbitrary strings
2169 may be generated. This mechanism is similar to
2170 \fIpathname expansion\fP, but the filenames generated
2171 need not exist. Patterns to be brace expanded take
2172 the form of an optional
2174 followed by either a series of comma-separated strings or
2175 a sequence expression between a pair of braces, followed by
2178 The preamble is prefixed to each string contained
2179 within the braces, and the postscript is then appended
2180 to each resulting string, expanding left to right.
2182 Brace expansions may be nested. The results of each expanded
2183 string are not sorted; left to right order is preserved.
2184 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
2186 A sequence expression takes the form \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB}\fP,
2187 where \fIx\fP and \fIy\fP are either integers or single characters.
2188 When integers are supplied, the expression expands to each number between
2189 \fIx\fP and \fIy\fP, inclusive.
2190 When characters are supplied, the expression expands to each character
2191 lexicographically between \fIx\fP and \fIy\fP, inclusive. Note that
2192 both \fIx\fP and \fIy\fP must be of the same type.
2194 Brace expansion is performed before any other expansions,
2195 and any characters special to other expansions are preserved
2196 in the result. It is strictly textual.
2198 does not apply any syntactic interpretation to the context of the
2199 expansion or the text between the braces.
2201 A correctly-formed brace expansion must contain unquoted opening
2202 and closing braces, and at least one unquoted comma or a valid
2203 sequence expression.
2204 Any incorrectly formed brace expansion is left unchanged.
2205 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
2206 being considered part of a brace expression.
2207 To avoid conflicts with parameter expansion, the string \fB${\fP
2208 is not considered eligible for brace expansion.
2210 This construct is typically used as shorthand when the common
2211 prefix of the strings to be generated is longer than in the
2215 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2219 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2222 Brace expansion introduces a slight incompatibility with
2223 historical versions of
2226 does not treat opening or closing braces specially when they
2227 appear as part of a word, and preserves them in the output.
2229 removes braces from words as a consequence of brace
2230 expansion. For example, a word entered to
2233 appears identically in the output. The same word is
2238 If strict compatibility with
2244 option or disable brace expansion with the
2250 .B SHELL BUILTIN COMMANDS
2254 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2255 the characters preceding the first unquoted slash (or all characters,
2256 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2257 If none of the characters in the tilde-prefix are quoted, the
2258 characters in the tilde-prefix following the tilde are treated as a
2259 possible \fIlogin name\fP.
2260 If this login name is the null string, the tilde is replaced with the
2261 value of the shell parameter
2267 is unset, the home directory of the user executing the shell is
2268 substituted instead.
2269 Otherwise, the tilde-prefix is replaced with the home directory
2270 associated with the specified login name.
2272 If the tilde-prefix is a `~+', the value of the shell variable
2275 replaces the tilde-prefix.
2276 If the tilde-prefix is a `~\-', the value of the shell variable
2279 if it is set, is substituted.
2280 If the characters following the tilde in the tilde-prefix consist
2281 of a number \fIN\fP, optionally prefixed
2282 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2283 element from the directory stack, as it would be displayed by the
2285 builtin invoked with the tilde-prefix as an argument.
2286 If the characters following the tilde in the tilde-prefix consist of a
2287 number without a leading `+' or `\-', `+' is assumed.
2289 If the login name is invalid, or the tilde expansion fails, the word
2292 Each variable assignment is checked for unquoted tilde-prefixes immediately
2297 In these cases, tilde expansion is also performed.
2298 Consequently, one may use file names with tildes in assignments to
2306 and the shell assigns the expanded value.
2307 .SS Parameter Expansion
2309 The `\fB$\fP' character introduces parameter expansion,
2310 command substitution, or arithmetic expansion. The parameter name
2311 or symbol to be expanded may be enclosed in braces, which
2312 are optional but serve to protect the variable to be expanded from
2313 characters immediately following it which could be
2314 interpreted as part of the name.
2316 When braces are used, the matching ending brace is the first `\fB}\fP'
2317 not escaped by a backslash or within a quoted string, and not within an
2318 embedded arithmetic expansion, command substitution, or parameter
2324 The value of \fIparameter\fP is substituted. The braces are required
2327 is a positional parameter with more than one digit,
2330 is followed by a character which is not to be
2331 interpreted as part of its name.
2334 If the first character of \fIparameter\fP is an exclamation point,
2335 a level of variable indirection is introduced.
2336 \fBBash\fP uses the value of the variable formed from the rest of
2337 \fIparameter\fP as the name of the variable; this variable is then
2338 expanded and that value is used in the rest of the substitution, rather
2339 than the value of \fIparameter\fP itself.
2340 This is known as \fIindirect expansion\fP.
2341 The exceptions to this are the expansions of ${!\fIprefix\fP*} and
2342 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
2343 The exclamation point must immediately follow the left brace in order to
2344 introduce indirection.
2346 In each of the cases below, \fIword\fP is subject to tilde expansion,
2347 parameter expansion, command substitution, and arithmetic expansion.
2348 When not performing substring expansion, \fBbash\fP tests for a parameter
2349 that is unset or null; omitting the colon results in a test only for a
2350 parameter that is unset.
2354 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
2355 \fBUse Default Values\fP. If
2357 is unset or null, the expansion of
2359 is substituted. Otherwise, the value of
2363 ${\fIparameter\fP\fB:=\fP\fIword\fP}
2364 \fBAssign Default Values\fP.
2367 is unset or null, the expansion of
2373 is then substituted. Positional parameters and special parameters may
2374 not be assigned to in this way.
2376 ${\fIparameter\fP\fB:?\fP\fIword\fP}
2377 \fBDisplay Error if Null or Unset\fP.
2380 is null or unset, the expansion of \fIword\fP (or a message to that effect
2383 is not present) is written to the standard error and the shell, if it
2384 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
2387 ${\fIparameter\fP\fB:+\fP\fIword\fP}
2388 \fBUse Alternate Value\fP.
2391 is null or unset, nothing is substituted, otherwise the expansion of
2395 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
2398 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
2400 \fBSubstring Expansion.\fP
2401 Expands to up to \fIlength\fP characters of \fIparameter\fP
2402 starting at the character specified by \fIoffset\fP.
2403 If \fIlength\fP is omitted, expands to the substring of
2404 \fIparameter\fP starting at the character specified by \fIoffset\fP.
2405 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2408 ARITHMETIC EVALUATION
2410 \fIlength\fP must evaluate to a number greater than or equal to zero.
2411 If \fIoffset\fP evaluates to a number less than zero, the value
2412 is used as an offset from the end of the value of \fIparameter\fP.
2413 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2414 parameters beginning at \fIoffset\fP.
2415 If \fIparameter\fP is an array name indexed by @ or *,
2416 the result is the \fIlength\fP
2417 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2418 A negative \fIoffset\fP is taken relative to one greater than the maximum
2419 index of the specified array.
2420 Note that a negative offset must be separated from the colon by at least
2421 one space to avoid being confused with the :- expansion.
2422 Substring indexing is zero-based unless the positional parameters
2423 are used, in which case the indexing starts at 1.
2425 ${\fB!\fP\fIprefix\fP\fB*\fP}
2428 ${\fB!\fP\fIprefix\fP\fB@\fP}
2430 Expands to the names of variables whose names begin with \fIprefix\fP,
2431 separated by the first character of the
2436 ${\fB!\fP\fIname\fP[\fI@\fP]}
2439 ${\fB!\fP\fIname\fP[\fI*\fP]}
2441 If \fIname\fP is an array variable, expands to the list of array indices
2442 (keys) assigned in \fIname\fP.
2443 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
2445 When \fI@\fP is used and the expansion appears within double quotes, each
2446 key expands to a separate word.
2448 ${\fB#\fP\fIparameter\fP}
2449 The length in characters of the value of \fIparameter\fP is substituted.
2456 the value substituted is the number of positional parameters.
2459 is an array name subscripted by
2463 the value substituted is the number of elements in the array.
2465 ${\fIparameter\fP\fB#\fP\fIword\fP}
2468 ${\fIparameter\fP\fB##\fP\fIword\fP}
2472 is expanded to produce a pattern just as in pathname
2473 expansion. If the pattern matches the beginning of
2476 then the result of the expansion is the expanded value of
2478 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2479 longest matching pattern (the ``\fB##\fP'' case) deleted.
2486 the pattern removal operation is applied to each positional
2487 parameter in turn, and the expansion is the resultant list.
2490 is an array variable subscripted with
2494 the pattern removal operation is applied to each member of the
2495 array in turn, and the expansion is the resultant list.
2497 ${\fIparameter\fP\fB%\fP\fIword\fP}
2500 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2502 The \fIword\fP is expanded to produce a pattern just as in
2504 If the pattern matches a trailing portion of the expanded value of
2506 then the result of the expansion is the expanded value of
2508 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2509 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2516 the pattern removal operation is applied to each positional
2517 parameter in turn, and the expansion is the resultant list.
2520 is an array variable subscripted with
2524 the pattern removal operation is applied to each member of the
2525 array in turn, and the expansion is the resultant list.
2527 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2530 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2532 The \fIpattern\fP is expanded to produce a pattern just as in
2534 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2535 against its value is replaced with \fIstring\fP.
2536 In the first form, only the first match is replaced.
2537 The second form causes all matches of \fIpattern\fP to be
2538 replaced with \fIstring\fP.
2539 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2540 of the expanded value of \fIparameter\fP.
2541 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2542 of the expanded value of \fIparameter\fP.
2543 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2544 and the \fB/\fP following \fIpattern\fP may be omitted.
2551 the substitution operation is applied to each positional
2552 parameter in turn, and the expansion is the resultant list.
2555 is an array variable subscripted with
2559 the substitution operation is applied to each member of the
2560 array in turn, and the expansion is the resultant list.
2561 .SS Command Substitution
2563 \fICommand substitution\fP allows the output of a command to replace
2564 the command name. There are two forms:
2568 \fB$(\fP\fIcommand\fP\|\fB)\fP
2572 \fB`\fP\fIcommand\fP\fB`\fP
2576 performs the expansion by executing \fIcommand\fP and
2577 replacing the command substitution with the standard output of the
2578 command, with any trailing newlines deleted.
2579 Embedded newlines are not deleted, but they may be removed during
2581 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2582 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2584 When the old-style backquote form of substitution is used,
2585 backslash retains its literal meaning except when followed by
2590 The first backquote not preceded by a backslash terminates the
2591 command substitution.
2592 When using the $(\^\fIcommand\fP\|) form, all characters between the
2593 parentheses make up the command; none are treated specially.
2595 Command substitutions may be nested. To nest when using the backquoted form,
2596 escape the inner backquotes with backslashes.
2598 If the substitution appears within double quotes, word splitting and
2599 pathname expansion are not performed on the results.
2600 .SS Arithmetic Expansion
2602 Arithmetic expansion allows the evaluation of an arithmetic expression
2603 and the substitution of the result. The format for arithmetic expansion is:
2606 \fB$((\fP\fIexpression\fP\fB))\fP
2611 is treated as if it were within double quotes, but a double quote
2612 inside the parentheses is not treated specially.
2613 All tokens in the expression undergo parameter expansion, string
2614 expansion, command substitution, and quote removal.
2615 Arithmetic expansions may be nested.
2617 The evaluation is performed according to the rules listed below under
2619 .BR "ARITHMETIC EVALUATION" .
2624 prints a message indicating failure and no substitution occurs.
2625 .SS Process Substitution
2627 \fIProcess substitution\fP is supported on systems that support named
2628 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2629 It takes the form of
2630 \fB<(\fP\fIlist\^\fP\fB)\fP
2632 \fB>(\fP\fIlist\^\fP\fB)\fP.
2633 The process \fIlist\fP is run with its input or output connected to a
2634 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2635 passed as an argument to the current command as the result of the
2636 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2637 the file will provide input for \fIlist\fP. If the
2638 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2639 argument should be read to obtain the output of \fIlist\fP.
2641 When available, process substitution is performed
2642 simultaneously with parameter and variable expansion,
2643 command substitution,
2644 and arithmetic expansion.
2647 The shell scans the results of
2648 parameter expansion,
2649 command substitution,
2651 arithmetic expansion
2652 that did not occur within double quotes for
2653 .IR "word splitting" .
2655 The shell treats each character of
2658 as a delimiter, and splits the results of the other
2659 expansions into words on these characters. If
2664 .BR <space><tab><newline> ,
2669 characters serves to delimit words. If
2672 has a value other than the default, then sequences of
2673 the whitespace characters
2677 are ignored at the beginning and end of the
2678 word, as long as the whitespace character is in the
2685 whitespace character).
2692 whitespace, along with any adjacent
2695 whitespace characters, delimits a field.
2699 whitespace characters is also treated as a delimiter.
2703 is null, no word splitting occurs.
2705 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2706 Unquoted implicit null arguments, resulting from the expansion of
2707 parameters that have no values, are removed.
2708 If a parameter with no value is expanded within double quotes, a
2709 null argument results and is retained.
2711 Note that if no expansion occurs, no splitting
2713 .SS Pathname Expansion
2715 After word splitting,
2718 option has been set,
2720 scans each word for the characters
2725 If one of these characters appears, then the word is
2728 and replaced with an alphabetically sorted list of
2729 file names matching the pattern.
2730 If no matching file names are found,
2731 and the shell option
2733 is disabled, the word is left unchanged.
2736 option is set, and no matches are found,
2737 the word is removed.
2740 shell option is set, and no matches are found, an error message
2741 is printed and the command is not executed.
2744 is enabled, the match is performed without regard to the case
2745 of alphabetic characters.
2746 When a pattern is used for pathname expansion,
2749 at the start of a name or immediately following a slash
2750 must be matched explicitly, unless the shell option
2753 When matching a pathname, the slash character must always be
2757 character is not treated specially.
2758 See the description of
2762 .B SHELL BUILTIN COMMANDS
2763 for a description of the
2774 shell variable may be used to restrict the set of file names matching a
2779 is set, each matching file name that also matches one of the patterns in
2782 is removed from the list of matches.
2787 are always ignored when
2790 is set and not null. However, setting
2793 to a non-null value has the effect of enabling the
2795 shell option, so all other file names beginning with a
2798 To get the old behavior of ignoring file names beginning with a
2802 one of the patterns in
2807 option is disabled when
2812 \fBPattern Matching\fP
2814 Any character that appears in a pattern, other than the special pattern
2815 characters described below, matches itself. The NUL character may not
2816 occur in a pattern. A backslash escapes the following character; the
2817 escaping backslash is discarded when matching.
2818 The special pattern characters must be quoted if
2819 they are to be matched literally.
2821 The special pattern characters have the following meanings:
2826 Matches any string, including the null string.
2829 Matches any single character.
2832 Matches any one of the enclosed characters. A pair of characters
2833 separated by a hyphen denotes a
2834 \fIrange expression\fP;
2835 any character that sorts between those two characters, inclusive,
2836 using the current locale's collating sequence and character set,
2837 is matched. If the first character following the
2843 then any character not enclosed is matched.
2844 The sorting order of characters in range expressions is determined by
2845 the current locale and the value of the \fBLC_COLLATE\fP shell variable,
2849 may be matched by including it as the first or last character
2853 may be matched by including it as the first character
2862 \fIcharacter classes\fP can be specified using the syntax
2863 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
2864 following classes defined in the POSIX.2 standard:
2868 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
2869 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
2871 A character class matches any character belonging to that class.
2872 The \fBword\fP character class matches letters, digits, and the character _.
2880 an \fIequivalence class\fP can be specified using the syntax
2881 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
2882 same collation weight (as defined by the current locale) as
2883 the character \fIc\fP.
2891 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
2896 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
2897 builtin, several extended pattern matching operators are recognized.
2898 In the following description, a \fIpattern-list\fP is a list of one
2899 or more patterns separated by a \fB|\fP.
2900 Composite patterns may be formed using one or more of the following
2906 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
2907 Matches zero or one occurrence of the given patterns
2909 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
2910 Matches zero or more occurrences of the given patterns
2912 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
2913 Matches one or more occurrences of the given patterns
2915 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
2916 Matches one of the given patterns
2918 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
2919 Matches anything except one of the given patterns
2924 After the preceding expansions, all unquoted occurrences of the
2928 and \^\f3"\fP\^ that did not result from one of the above
2929 expansions are removed.
2931 Before a command is executed, its input and output
2934 using a special notation interpreted by the shell.
2935 Redirection may also be used to open and close files for the
2936 current shell execution environment. The following redirection
2937 operators may precede or appear anywhere within a
2941 Redirections are processed in the order they appear, from
2944 In the following descriptions, if the file descriptor number is
2945 omitted, and the first character of the redirection operator is
2947 the redirection refers to the standard input (file descriptor
2948 0). If the first character of the redirection operator is
2950 the redirection refers to the standard output (file descriptor
2953 The word following the redirection operator in the following
2954 descriptions, unless otherwise noted, is subjected to brace expansion,
2955 tilde expansion, parameter expansion, command substitution, arithmetic
2956 expansion, quote removal, pathname expansion, and word splitting.
2957 If it expands to more than one word,
2961 Note that the order of redirections is significant. For example,
2965 ls \fB>\fP dirlist 2\fB>&\fP1
2968 directs both standard output and standard error to the file
2973 ls 2\fB>&\fP1 \fB>\fP dirlist
2976 directs only the standard output to file
2978 because the standard error was duplicated as standard output
2979 before the standard output was redirected to
2982 \fBBash\fP handles several filenames specially when they are used in
2983 redirections, as described in the following table:
2989 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
2992 File descriptor 0 is duplicated.
2995 File descriptor 1 is duplicated.
2998 File descriptor 2 is duplicated.
3000 .B /dev/tcp/\fIhost\fP/\fIport\fP
3001 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3002 is an integer port number or service name, \fBbash\fP attempts to open
3003 a TCP connection to the corresponding socket.
3005 .B /dev/udp/\fIhost\fP/\fIport\fP
3006 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3007 is an integer port number or service name, \fBbash\fP attempts to open
3008 a UDP connection to the corresponding socket.
3012 A failure to open or create a file causes the redirection to fail.
3014 Redirections using file descriptors greater than 9 should be used with
3015 care, as they may conflict with file descriptors the shell uses
3017 .SS Redirecting Input
3019 Redirection of input causes the file whose name results from
3022 to be opened for reading on file descriptor
3024 or the standard input (file descriptor 0) if
3028 The general format for redirecting input is:
3031 [\fIn\fP]\fB<\fP\fIword\fP
3033 .SS Redirecting Output
3035 Redirection of output causes the file whose name results from
3038 to be opened for writing on file descriptor
3040 or the standard output (file descriptor 1) if
3042 is not specified. If the file does not exist it is created;
3043 if it does exist it is truncated to zero size.
3045 The general format for redirecting output is:
3048 [\fIn\fP]\fB>\fP\fIword\fP
3051 If the redirection operator is
3057 builtin has been enabled, the redirection will fail if the file
3058 whose name results from the expansion of \fIword\fP exists and is
3060 If the redirection operator is
3062 or the redirection operator is
3068 builtin command is not enabled, the redirection is attempted even
3069 if the file named by \fIword\fP exists.
3070 .SS Appending Redirected Output
3072 Redirection of output in this fashion
3073 causes the file whose name results from
3076 to be opened for appending on file descriptor
3078 or the standard output (file descriptor 1) if
3080 is not specified. If the file does not exist it is created.
3082 The general format for appending output is:
3085 [\fIn\fP]\fB>>\fP\fIword\fP
3088 .SS Redirecting Standard Output and Standard Error
3092 standard output (file descriptor 1) and
3093 the standard error output (file descriptor 2)
3094 to be redirected to the file whose name is the
3097 with this construct.
3099 There are two formats for redirecting standard output and
3110 Of the two forms, the first is preferred.
3111 This is semantically equivalent to
3114 \fB>\fP\fIword\fP 2\fB>&\fP1
3118 This type of redirection instructs the shell to read input from the
3119 current source until a line containing only
3121 (with no trailing blanks)
3123 the lines read up to that point are then used as the standard
3124 input for a command.
3126 The format of here-documents is:
3130 \fB<<\fP[\fB\-\fP]\fIword\fP
3136 No parameter expansion, command substitution, arithmetic expansion,
3137 or pathname expansion is performed on
3139 If any characters in
3143 is the result of quote removal on
3145 and the lines in the here-document are not expanded.
3146 If \fIword\fP is unquoted,
3147 all lines of the here-document are subjected to parameter expansion,
3148 command substitution, and arithmetic expansion. In the latter
3149 case, the character sequence
3153 must be used to quote the characters
3159 If the redirection operator is
3161 then all leading tab characters are stripped from input lines and the
3165 here-documents within shell scripts to be indented in a
3168 A variant of here documents, the format is:
3176 The \fIword\fP is expanded and supplied to the command on its standard
3178 .SS "Duplicating File Descriptors"
3180 The redirection operator
3183 [\fIn\fP]\fB<&\fP\fIword\fP
3186 is used to duplicate input file descriptors.
3189 expands to one or more digits, the file descriptor denoted by
3191 is made to be a copy of that file descriptor.
3194 do not specify a file descriptor open for input, a redirection error occurs.
3203 is not specified, the standard input (file descriptor 0) is used.
3208 [\fIn\fP]\fB>&\fP\fIword\fP
3211 is used similarly to duplicate output file descriptors. If
3213 is not specified, the standard output (file descriptor 1) is used.
3216 do not specify a file descriptor open for output, a redirection error occurs.
3217 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
3218 expand to one or more digits, the standard output and standard
3219 error are redirected as described previously.
3220 .SS "Moving File Descriptors"
3222 The redirection operator
3225 [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
3228 moves the file descriptor \fIdigit\fP to file descriptor
3230 or the standard input (file descriptor 0) if \fIn\fP is not specified.
3231 \fIdigit\fP is closed after being duplicated to \fIn\fP.
3233 Similarly, the redirection operator
3236 [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
3239 moves the file descriptor \fIdigit\fP to file descriptor
3241 or the standard output (file descriptor 1) if \fIn\fP is not specified.
3242 .SS "Opening File Descriptors for Reading and Writing"
3244 The redirection operator
3247 [\fIn\fP]\fB<>\fP\fIword\fP
3250 causes the file whose name is the expansion of
3252 to be opened for both reading and writing on file descriptor
3254 or on file descriptor 0 if
3256 is not specified. If the file does not exist, it is created.
3258 \fIAliases\fP allow a string to be substituted for a word when it is used
3259 as the first word of a simple command.
3260 The shell maintains a list of aliases that may be set and unset with the
3264 builtin commands (see
3266 .B SHELL BUILTIN COMMANDS
3268 The first word of each simple command, if unquoted,
3269 is checked to see if it has an
3270 alias. If so, that word is replaced by the text of the alias.
3271 The characters \fB/\fP, \fB$\fP, \fB`\fP, and \fB=\fP and
3272 any of the shell \fImetacharacters\fP or quoting characters
3273 listed above may not appear in an alias name.
3274 The replacement text may contain any valid shell input,
3275 including shell metacharacters.
3276 The first word of the replacement text is tested
3277 for aliases, but a word that is identical to an alias being expanded
3278 is not expanded a second time.
3279 This means that one may alias
3285 does not try to recursively expand the replacement text.
3286 If the last character of the alias value is a
3288 then the next command
3289 word following the alias is also checked for alias expansion.
3291 Aliases are created and listed with the
3293 command, and removed with the
3297 There is no mechanism for using arguments in the replacement text.
3298 If arguments are needed, a shell function should be used (see
3303 Aliases are not expanded when the shell is not interactive, unless
3306 shell option is set using
3308 (see the description of
3312 \fBSHELL BUILTIN COMMANDS\fP
3315 The rules concerning the definition and use of aliases are
3318 always reads at least one complete line
3319 of input before executing any
3320 of the commands on that line. Aliases are expanded when a
3321 command is read, not when it is executed. Therefore, an
3322 alias definition appearing on the same line as another
3323 command does not take effect until the next line of input is read.
3324 The commands following the alias definition
3325 on that line are not affected by the new alias.
3326 This behavior is also an issue when functions are executed.
3327 Aliases are expanded when a function definition is read,
3328 not when the function is executed, because a function definition
3329 is itself a compound command. As a consequence, aliases
3330 defined in a function are not available until after that
3331 function is executed. To be safe, always put
3332 alias definitions on a separate line, and do not use
3334 in compound commands.
3336 For almost every purpose, aliases are superseded by
3339 A shell function, defined as described above under
3341 .BR "SHELL GRAMMAR" ,
3342 stores a series of commands for later execution.
3343 When the name of a shell function is used as a simple command name,
3344 the list of commands associated with that function name is executed.
3345 Functions are executed in the context of the
3346 current shell; no new process is created to interpret
3347 them (contrast this with the execution of a shell script).
3348 When a function is executed, the arguments to the
3349 function become the positional parameters
3350 during its execution.
3351 The special parameter
3353 is updated to reflect the change. Special parameter 0
3355 The first element of the
3358 variable is set to the name of the function while the function
3360 All other aspects of the shell execution
3361 environment are identical between a function and its caller
3362 with the exception that the
3367 traps (see the description of the
3371 .B SHELL BUILTIN COMMANDS
3372 below) are not inherited unless the function has been given the
3373 \fBtrace\fP attribute (see the description of the
3376 builtin below) or the
3377 \fB\-o functrace\fP shell option has been enabled with
3378 the \fBset\fP builtin
3379 (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps).
3381 Variables local to the function may be declared with the
3383 builtin command. Ordinarily, variables and their values
3384 are shared between the function and its caller.
3386 If the builtin command
3388 is executed in a function, the function completes and
3389 execution resumes with the next command after the function
3391 Any command associated with the \fBRETURN\fP trap is executed
3392 before execution resumes.
3393 When a function completes, the values of the
3394 positional parameters and the special parameter
3396 are restored to the values they had prior to the function's
3399 Function names and definitions may be listed with the
3405 builtin commands. The
3411 will list the function names only
3412 (and optionally the source file and line number, if the \fBextdebug\fP
3413 shell option is enabled).
3414 Functions may be exported so that subshells
3415 automatically have them defined with the
3420 Note that shell functions and variables with the same name may result
3421 in multiple identically-named entries in the environment passed to the
3423 Care should be taken in cases where this may cause a problem.
3425 Functions may be recursive. No limit is imposed on the number
3427 .SH "ARITHMETIC EVALUATION"
3428 The shell allows arithmetic expressions to be evaluated, under
3429 certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
3430 commands and \fBArithmetic Expansion\fP).
3431 Evaluation is done in fixed-width integers with no check for overflow,
3432 though division by 0 is trapped and flagged as an error.
3433 The operators and their precedence, associativity, and values
3434 are the same as in the C language.
3435 The following list of operators is grouped into levels of
3436 equal-precedence operators.
3437 The levels are listed in order of decreasing precedence.
3441 .B \fIid\fP++ \fIid\fP\-\-
3442 variable post-increment and post-decrement
3444 .B ++\fIid\fP \-\-\fIid\fP
3445 variable pre-increment and pre-decrement
3448 unary minus and plus
3451 logical and bitwise negation
3457 multiplication, division, remainder
3460 addition, subtraction
3463 left and right bitwise shifts
3469 equality and inequality
3475 bitwise exclusive OR
3486 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
3487 conditional operator
3489 .B = *= /= %= += \-= <<= >>= &= ^= |=
3492 .B \fIexpr1\fP , \fIexpr2\fP
3496 Shell variables are allowed as operands; parameter expansion is
3497 performed before the expression is evaluated.
3498 Within an expression, shell variables may also be referenced by name
3499 without using the parameter expansion syntax.
3500 A shell variable that is null or unset evaluates to 0 when referenced
3501 by name without using the parameter expansion syntax.
3502 The value of a variable is evaluated as an arithmetic expression
3503 when it is referenced, or when a variable which has been given the
3504 \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
3505 A null value evaluates to 0.
3506 A shell variable need not have its integer attribute
3507 turned on to be used in an expression.
3509 Constants with a leading 0 are interpreted as octal numbers.
3510 A leading 0x or 0X denotes hexadecimal.
3511 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
3512 is a decimal number between 2 and 64 representing the arithmetic
3513 base, and \fIn\fP is a number in that base.
3514 If \fIbase#\fP is omitted, then base 10 is used.
3515 The digits greater than 9 are represented by the lowercase letters,
3516 the uppercase letters, @, and _, in that order.
3517 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
3518 letters may be used interchangeably to represent numbers between 10
3521 Operators are evaluated in order of precedence. Sub-expressions in
3522 parentheses are evaluated first and may override the precedence
3524 .SH "CONDITIONAL EXPRESSIONS"
3525 Conditional expressions are used by the \fB[[\fP compound command and
3526 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
3527 and perform string and arithmetic comparisons.
3528 Expressions are formed from the following unary or binary primaries.
3529 If any \fIfile\fP argument to one of the primaries is of the form
3530 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
3531 If the \fIfile\fP argument to one of the primaries is one of
3532 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
3533 descriptor 0, 1, or 2, respectively, is checked.
3535 Unless otherwise specified, primaries that operate on files follow symbolic
3536 links and operate on the target of the link, rather than the link itself.
3541 True if \fIfile\fP exists.
3544 True if \fIfile\fP exists and is a block special file.
3547 True if \fIfile\fP exists and is a character special file.
3550 True if \fIfile\fP exists and is a directory.
3553 True if \fIfile\fP exists.
3556 True if \fIfile\fP exists and is a regular file.
3559 True if \fIfile\fP exists and is set-group-id.
3562 True if \fIfile\fP exists and is a symbolic link.
3565 True if \fIfile\fP exists and its ``sticky'' bit is set.
3568 True if \fIfile\fP exists and is a named pipe (FIFO).
3571 True if \fIfile\fP exists and is readable.
3574 True if \fIfile\fP exists and has a size greater than zero.
3577 True if file descriptor
3579 is open and refers to a terminal.
3582 True if \fIfile\fP exists and its set-user-id bit is set.
3585 True if \fIfile\fP exists and is writable.
3588 True if \fIfile\fP exists and is executable.
3591 True if \fIfile\fP exists and is owned by the effective user id.
3594 True if \fIfile\fP exists and is owned by the effective group id.
3597 True if \fIfile\fP exists and is a symbolic link.
3600 True if \fIfile\fP exists and is a socket.
3603 True if \fIfile\fP exists and has been modified since it was last read.
3605 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3606 True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
3607 or if \fIfile1\fP exists and \fPfile2\fP does not.
3609 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3610 True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
3611 and \fIfile1\fP does not.
3613 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3614 True if \fIfile1\fP and \fIfile2\fP refer to the same device and
3617 .B \-o \fIoptname\fP
3618 True if shell option
3621 See the list of options under the description of the
3628 True if the length of \fIstring\fP is zero.
3635 True if the length of
3639 \fIstring1\fP \fB==\fP \fIstring2\fP
3640 True if the strings are equal. \fB=\fP may be used in place of
3641 \fB==\fP for strict POSIX compliance.
3643 \fIstring1\fP \fB!=\fP \fIstring2\fP
3644 True if the strings are not equal.
3646 \fIstring1\fP \fB<\fP \fIstring2\fP
3647 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
3648 in the current locale.
3650 \fIstring1\fP \fB>\fP \fIstring2\fP
3651 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
3652 in the current locale.
3654 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
3665 These arithmetic binary operators return true if \fIarg1\fP
3666 is equal to, not equal to, less than, less than or equal to,
3667 greater than, or greater than or equal to \fIarg2\fP, respectively.
3671 may be positive or negative integers.
3673 .SH "SIMPLE COMMAND EXPANSION"
3674 When a simple command is executed, the shell performs the following
3675 expansions, assignments, and redirections, from left to right.
3677 The words that the parser has marked as variable assignments (those
3678 preceding the command name) and redirections are saved for later
3681 The words that are not variable assignments or redirections are
3682 expanded. If any words remain after expansion, the first word
3683 is taken to be the name of the command and the remaining words are
3686 Redirections are performed as described above under
3690 The text after the \fB=\fP in each variable assignment undergoes tilde
3691 expansion, parameter expansion, command substitution, arithmetic expansion,
3692 and quote removal before being assigned to the variable.
3694 If no command name results, the variable assignments affect the current
3695 shell environment. Otherwise, the variables are added to the environment
3696 of the executed command and do not affect the current shell environment.
3697 If any of the assignments attempts to assign a value to a readonly variable,
3698 an error occurs, and the command exits with a non-zero status.
3700 If no command name results, redirections are performed, but do not
3701 affect the current shell environment. A redirection error causes the
3702 command to exit with a non-zero status.
3704 If there is a command name left after expansion, execution proceeds as
3705 described below. Otherwise, the command exits. If one of the expansions
3706 contained a command substitution, the exit status of the command is
3707 the exit status of the last command substitution performed. If there
3708 were no command substitutions, the command exits with a status of zero.
3709 .SH "COMMAND EXECUTION"
3710 After a command has been split into words, if it results in a
3711 simple command and an optional list of arguments, the following
3714 If the command name contains no slashes, the shell attempts to
3715 locate it. If there exists a shell function by that name, that
3716 function is invoked as described above in
3719 If the name does not match a function, the shell searches for
3720 it in the list of shell builtins. If a match is found, that
3723 If the name is neither a shell function nor a builtin,
3724 and contains no slashes,
3726 searches each element of the
3729 for a directory containing an executable file by that name.
3731 uses a hash table to remember the full pathnames of executable
3736 .B "SHELL BUILTIN COMMANDS"
3738 A full search of the directories in
3741 is performed only if the command is not found in the hash table.
3742 If the search is unsuccessful, the shell prints an error
3743 message and returns an exit status of 127.
3745 If the search is successful, or if the command name contains
3746 one or more slashes, the shell executes the named program in a
3747 separate execution environment.
3748 Argument 0 is set to the name given, and the remaining arguments
3749 to the command are set to the arguments given, if any.
3751 If this execution fails because the file is not in executable
3752 format, and the file is not a directory, it is assumed to be
3753 a \fIshell script\fP, a file
3754 containing shell commands. A subshell is spawned to execute
3755 it. This subshell reinitializes itself, so
3756 that the effect is as if a new shell had been invoked
3757 to handle the script, with the exception that the locations of
3758 commands remembered by the parent (see
3762 \fBSHELL BUILTIN COMMANDS\fP)
3763 are retained by the child.
3765 If the program is a file beginning with
3767 the remainder of the first line specifies an interpreter
3768 for the program. The shell executes the
3769 specified interpreter on operating systems that do not
3770 handle this executable format themselves. The arguments to the
3771 interpreter consist of a single optional argument following the
3772 interpreter name on the first line of the program, followed
3773 by the name of the program, followed by the command
3775 .SH COMMAND EXECUTION ENVIRONMENT
3776 The shell has an \fIexecution environment\fP, which consists of the
3780 open files inherited by the shell at invocation, as modified by
3781 redirections supplied to the \fBexec\fP builtin
3783 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
3784 \fBpopd\fP, or inherited by the shell at invocation
3786 the file creation mode mask as set by \fBumask\fP or inherited from
3789 current traps set by \fBtrap\fP
3791 shell parameters that are set by variable assignment or with \fBset\fP
3792 or inherited from the shell's parent in the environment
3794 shell functions defined during execution or inherited from the shell's
3795 parent in the environment
3797 options enabled at invocation (either by default or with command-line
3798 arguments) or by \fBset\fP
3800 options enabled by \fBshopt\fP
3802 shell aliases defined with \fBalias\fP
3804 various process IDs, including those of background jobs, the value
3805 of \fB$$\fP, and the value of \fB$PPID\fP
3807 When a simple command other than a builtin or shell function
3808 is to be executed, it
3809 is invoked in a separate execution environment that consists of
3810 the following. Unless otherwise noted, the values are inherited
3814 the shell's open files, plus any modifications and additions specified
3815 by redirections to the command
3817 the current working directory
3819 the file creation mode mask
3821 shell variables and functions marked for export, along with variables
3822 exported for the command, passed in the environment
3824 traps caught by the shell are reset to the values inherited from the
3825 shell's parent, and traps ignored by the shell are ignored
3827 A command invoked in this separate environment cannot affect the
3828 shell's execution environment.
3830 Command substitution, commands grouped with parentheses,
3831 and asynchronous commands are invoked in a
3832 subshell environment that is a duplicate of the shell environment,
3833 except that traps caught by the shell are reset to the values
3834 that the shell inherited from its parent at invocation. Builtin
3835 commands that are invoked as part of a pipeline are also executed in a
3836 subshell environment. Changes made to the subshell environment
3837 cannot affect the shell's execution environment.
3839 If a command is followed by a \fB&\fP and job control is not active, the
3840 default standard input for the command is the empty file \fI/dev/null\fP.
3841 Otherwise, the invoked command inherits the file descriptors of the calling
3842 shell as modified by redirections.
3844 When a program is invoked it is given an array of strings
3848 \fIname\fP\-\fIvalue\fP pairs, of the form
3849 .IR "name\fR=\fPvalue" .
3851 The shell provides several ways to manipulate the environment.
3852 On invocation, the shell scans its own environment and
3853 creates a parameter for each name found, automatically marking
3856 to child processes. Executed commands inherit the environment.
3861 commands allow parameters and functions to be added to and
3862 deleted from the environment. If the value of a parameter
3863 in the environment is modified, the new value becomes part
3864 of the environment, replacing the old. The environment
3865 inherited by any executed command consists of the shell's
3866 initial environment, whose values may be modified in the shell,
3867 less any pairs removed by the
3869 command, plus any additions via the
3875 The environment for any
3877 or function may be augmented temporarily by prefixing it with
3878 parameter assignments, as described above in
3881 These assignment statements affect only the environment seen
3886 option is set (see the
3888 builtin command below), then
3890 parameter assignments are placed in the environment for a command,
3891 not just those that precede the command name.
3895 invokes an external command, the variable
3897 is set to the full file name of the command and passed to that
3898 command in its environment.
3900 For the shell's purposes, a command which exits with a
3901 zero exit status has succeeded. An exit status of zero
3902 indicates success. A non-zero exit status indicates failure.
3903 When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
3904 the value of 128+\fIN\fP as the exit status.
3906 If a command is not found, the child process created to
3907 execute it returns a status of 127. If a command is found
3908 but is not executable, the return status is 126.
3910 If a command fails because of an error during expansion or redirection,
3911 the exit status is greater than zero.
3913 Shell builtin commands return a status of 0 (\fItrue\fP) if
3914 successful, and non-zero (\fIfalse\fP) if an error occurs
3916 All builtins return an exit status of 2 to indicate incorrect usage.
3918 \fBBash\fP itself returns the exit status of the last command
3919 executed, unless a syntax error occurs, in which case it exits
3920 with a non-zero value. See also the \fBexit\fP builtin
3923 When \fBbash\fP is interactive, in the absence of any traps, it ignores
3926 (so that \fBkill 0\fP does not kill an interactive shell),
3930 is caught and handled (so that the \fBwait\fP builtin is interruptible).
3931 In all cases, \fBbash\fP ignores
3934 If job control is in effect,
3945 Non-builtin commands run by \fBbash\fP have signal handlers
3946 set to the values inherited by the shell from its parent.
3947 When job control is not in effect, asynchronous commands
3954 in addition to these inherited handlers.
3955 Commands run as a result of command substitution ignore the
3956 keyboard-generated job control signals
3965 The shell exits by default upon receipt of a
3968 Before exiting, an interactive shell resends the
3971 to all jobs, running or stopped.
3972 Stopped jobs are sent
3975 to ensure that they receive the
3978 To prevent the shell from
3979 sending the signal to a particular job, it should be removed from the
3984 .B "SHELL BUILTIN COMMANDS"
3994 shell option has been set with
4000 to all jobs when an interactive login shell exits.
4002 If \fBbash\fP is waiting for a command to complete and receives a signal
4003 for which a trap has been set, the trap will not be executed until
4004 the command completes.
4005 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
4006 builtin, the reception of a signal for which a trap has been set will
4007 cause the \fBwait\fP builtin to return immediately with an exit status
4008 greater than 128, immediately after which the trap is executed.
4011 refers to the ability to selectively stop (\fIsuspend\fP)
4012 the execution of processes and continue (\fIresume\fP)
4013 their execution at a later point. A user typically employs
4014 this facility via an interactive interface supplied jointly
4015 by the system's terminal driver and
4018 The shell associates a
4020 with each pipeline. It keeps a table of currently executing
4021 jobs, which may be listed with the
4025 starts a job asynchronously (in the
4027 it prints a line that looks like:
4033 indicating that this job is job number 1 and that the process ID
4034 of the last process in the pipeline associated with this job is 25647.
4035 All of the processes in a single pipeline are members of the same job.
4039 abstraction as the basis for job control.
4041 To facilitate the implementation of the user interface to job
4042 control, the operating system maintains the notion of a \fIcurrent terminal
4043 process group ID\fP. Members of this process group (processes whose
4044 process group ID is equal to the current terminal process group ID)
4045 receive keyboard-generated signals such as
4048 These processes are said to be in the
4051 processes are those whose process group ID differs from the terminal's;
4052 such processes are immune to keyboard-generated signals.
4053 Only foreground processes are allowed to read from or write to the
4054 terminal. Background processes which attempt to read from (write to) the
4057 .B SIGTTIN (SIGTTOU)
4058 signal by the terminal driver,
4059 which, unless caught, suspends the process.
4061 If the operating system on which
4066 contains facilities to use it.
4069 character (typically
4071 Control-Z) while a process is running
4072 causes that process to be stopped and returns control to
4075 .I "delayed suspend"
4076 character (typically
4078 Control-Y) causes the process to be stopped when it
4079 attempts to read input from the terminal, and control to
4082 The user may then manipulate the state of this job, using the
4084 command to continue it in the background, the
4086 command to continue it in the foreground, or
4089 command to kill it. A \fB^Z\fP takes effect immediately,
4090 and has the additional side effect of causing pending output
4091 and typeahead to be discarded.
4093 There are a number of ways to refer to a job in the shell.
4096 introduces a job name. Job number
4098 may be referred to as
4100 A job may also be referred to using a prefix of the name used to
4101 start it, or using a substring that appears in its command line.
4106 job. If a prefix matches more than one job,
4108 reports an error. Using
4110 on the other hand, refers to any job containing the string
4112 in its command line. If the substring matches more than one job,
4114 reports an error. The symbols
4118 refer to the shell's notion of the
4120 which is the last job stopped while it was in
4121 the foreground or started in the background.
4124 may be referenced using
4126 In output pertaining to jobs (e.g., the output of the
4128 command), the current job is always flagged with a
4130 and the previous job with a
4132 A single % (with no accompanying job specification) also refers to the
4135 Simply naming a job can be used to bring it into the
4140 bringing job 1 from the background into the foreground.
4143 resumes job 1 in the background, equivalent to
4146 The shell learns immediately whenever a job changes state.
4149 waits until it is about to print a prompt before reporting
4150 changes in a job's status so as to not interrupt
4151 any other output. If the
4158 reports such changes immediately.
4162 is executed for each child that exits.
4164 If an attempt to exit
4166 is made while jobs are stopped, the shell prints a warning message. The
4168 command may then be used to inspect their status.
4169 If a second attempt to exit is made without an intervening command,
4170 the shell does not print another warning, and the stopped
4171 jobs are terminated.
4173 When executing interactively,
4175 displays the primary prompt
4178 when it is ready to read a command, and the secondary prompt
4181 when it needs more input to complete a command.
4183 allows these prompt strings to be customized by inserting a number of
4184 backslash-escaped special characters that are decoded as follows:
4189 an ASCII bell character (07)
4192 the date in "Weekday Month Date" format (e.g., "Tue May 26")
4194 .B \eD{\fIformat\fP}
4195 the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
4196 into the prompt string; an empty \fIformat\fP results in a locale-specific
4197 time representation. The braces are required
4200 an ASCII escape character (033)
4203 the hostname up to the first `.'
4209 the number of jobs currently managed by the shell
4212 the basename of the shell's terminal device name
4221 the name of the shell, the basename of
4223 (the portion following the final slash)
4226 the current time in 24-hour HH:MM:SS format
4229 the current time in 12-hour HH:MM:SS format
4232 the current time in 12-hour am/pm format
4235 the current time in 24-hour HH:MM format
4238 the username of the current user
4241 the version of \fBbash\fP (e.g., 2.00)
4244 the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
4247 the current working directory, with \fB$HOME\fP abbreviated with a tilde
4250 the basename of the current working directory, with \fB$HOME\fP
4251 abbreviated with a tilde
4254 the history number of this command
4257 the command number of this command
4260 if the effective UID is 0, a
4266 the character corresponding to the octal number \fInnn\fP
4272 begin a sequence of non-printing characters, which could be used to
4273 embed a terminal control sequence into the prompt
4276 end a sequence of non-printing characters
4280 The command number and the history number are usually different:
4281 the history number of a command is its position in the history
4282 list, which may include commands restored from the history file
4286 below), while the command number is the position in the sequence
4287 of commands executed during the current shell session.
4288 After the string is decoded, it is expanded via
4289 parameter expansion, command substitution, arithmetic
4290 expansion, and quote removal, subject to the value of the
4292 shell option (see the description of the
4296 .B "SHELL BUILTIN COMMANDS"
4299 This is the library that handles reading input when using an interactive
4302 option is given at shell invocation.
4303 By default, the line editing commands are similar to those of emacs.
4304 A vi-style line editing interface is also available.
4305 To turn off line editing after the shell is running, use the
4313 .B SHELL BUILTIN COMMANDS
4315 .SS "Readline Notation"
4317 In this section, the emacs-style notation is used to denote
4318 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
4319 means Control\-N. Similarly,
4321 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
4324 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
4327 key. This makes ESC the \fImeta prefix\fP.
4328 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
4329 or press the Escape key
4330 then hold the Control key while pressing the
4334 Readline commands may be given numeric
4336 which normally act as a repeat count.
4337 Sometimes, however, it is the sign of the argument that is significant.
4338 Passing a negative argument to a command that acts in the forward
4339 direction (e.g., \fBkill\-line\fP) causes that command to act in a
4341 Commands whose behavior with arguments deviates from this are noted
4344 When a command is described as \fIkilling\fP text, the text
4345 deleted is saved for possible future retrieval
4346 (\fIyanking\fP). The killed text is saved in a
4347 \fIkill ring\fP. Consecutive kills cause the text to be
4348 accumulated into one unit, which can be yanked all at once.
4349 Commands which do not kill text separate the chunks of text
4351 .SS "Readline Initialization"
4353 Readline is customized by putting commands in an initialization
4354 file (the \fIinputrc\fP file).
4355 The name of this file is taken from the value of the
4358 variable. If that variable is unset, the default is
4360 When a program which uses the readline library starts up, the
4361 initialization file is read, and the key bindings and variables
4363 There are only a few basic constructs allowed in the
4364 readline initialization file.
4365 Blank lines are ignored.
4366 Lines beginning with a \fB#\fP are comments.
4367 Lines beginning with a \fB$\fP indicate conditional constructs.
4368 Other lines denote key bindings and variable settings.
4370 The default key-bindings may be changed with an
4373 Other programs that use this library may add their own commands
4376 For example, placing
4379 M\-Control\-u: universal\-argument
4383 C\-Meta\-u: universal\-argument
4387 would make M\-C\-u execute the readline command
4388 .IR universal\-argument .
4390 The following symbolic character names are recognized:
4403 In addition to command names, readline allows keys to be bound
4404 to a string that is inserted when the key is pressed (a \fImacro\fP).
4405 .SS "Readline Key Bindings"
4407 The syntax for controlling key bindings in the
4409 file is simple. All that is required is the name of the
4410 command or the text of a macro and a key sequence to which
4411 it should be bound. The name may be specified in one of two ways:
4412 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
4413 prefixes, or as a key sequence.
4415 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4417 is the name of a key spelled out in English. For example:
4420 Control-u: universal\-argument
4422 Meta-Rubout: backward-kill-word
4424 Control-o: "> output"
4427 In the above example,
4429 is bound to the function
4430 .BR universal\-argument ,
4432 is bound to the function
4433 .BR backward\-kill\-word ,
4436 is bound to run the macro
4437 expressed on the right hand side (that is, to insert the text
4438 .if t \f(CW> output\fP
4442 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4446 above in that strings denoting
4447 an entire key sequence may be specified by placing the sequence
4448 within double quotes. Some GNU Emacs style key escapes can be
4449 used, as in the following example, but the symbolic character names
4453 "\eC\-u": universal\-argument
4455 "\eC\-x\eC\-r": re\-read\-init\-file
4457 "\ee[11~": "Function Key 1"
4462 is again bound to the function
4463 .BR universal\-argument .
4465 is bound to the function
4466 .BR re\-read\-init\-file ,
4469 is bound to insert the text
4470 .if t \f(CWFunction Key 1\fP.
4471 .if n ``Function Key 1''.
4473 The full set of GNU Emacs style escape sequences is
4497 In addition to the GNU Emacs style escape sequences, a second
4498 set of backslash escapes is available:
4527 the eight-bit character whose value is the octal value \fInnn\fP
4528 (one to three digits)
4531 the eight-bit character whose value is the hexadecimal value \fIHH\fP
4532 (one or two hex digits)
4536 When entering the text of a macro, single or double quotes must
4537 be used to indicate a macro definition.
4538 Unquoted text is assumed to be a function name.
4539 In the macro body, the backslash escapes described above are expanded.
4540 Backslash will quote any other character in the macro text,
4544 allows the current readline key bindings to be displayed or modified
4547 builtin command. The editing mode may be switched during interactive
4552 builtin command (see
4554 .B SHELL BUILTIN COMMANDS
4556 .SS "Readline Variables"
4558 Readline has variables that can be used to further customize its
4559 behavior. A variable may be set in the
4561 file with a statement of the form
4564 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
4567 Except where noted, readline variables can take the values
4571 (without regard to case).
4572 Unrecognized variable names are ignored.
4573 When a variable value is read, empty or null values, "on" (case-insensitive),
4574 and "1" are equivalent to \fBOn\fP. All other values are equivalent to
4576 The variables and their default values are:
4580 .B bell\-style (audible)
4581 Controls what happens when readline wants to ring the terminal bell.
4582 If set to \fBnone\fP, readline never rings the bell. If set to
4583 \fBvisible\fP, readline uses a visible bell if one is available.
4584 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
4586 .B bind\-tty\-special\-chars (On)
4587 If set to \fBOn\fP, readline attempts to bind the control characters
4588 treated specially by the kernel's terminal driver to their readline
4591 .B comment\-begin (``#'')
4592 The string that is inserted when the readline
4594 command is executed.
4595 This command is bound to
4597 in emacs mode and to
4601 .B completion\-ignore\-case (Off)
4602 If set to \fBOn\fP, readline performs filename matching and completion
4603 in a case\-insensitive fashion.
4605 .B completion\-query\-items (100)
4606 This determines when the user is queried about viewing
4607 the number of possible completions
4608 generated by the \fBpossible\-completions\fP command.
4609 It may be set to any integer value greater than or equal to
4610 zero. If the number of possible completions is greater than
4611 or equal to the value of this variable, the user is asked whether
4612 or not he wishes to view them; otherwise they are simply listed
4615 .B convert\-meta (On)
4616 If set to \fBOn\fP, readline will convert characters with the
4617 eighth bit set to an ASCII key sequence
4618 by stripping the eighth bit and prefixing an
4619 escape character (in effect, using escape as the \fImeta prefix\fP).
4621 .B disable\-completion (Off)
4622 If set to \fBOn\fP, readline will inhibit word completion. Completion
4623 characters will be inserted into the line as if they had been
4624 mapped to \fBself-insert\fP.
4626 .B editing\-mode (emacs)
4627 Controls whether readline begins with a set of key bindings similar
4628 to \fIemacs\fP or \fIvi\fP.
4630 can be set to either
4635 .B enable\-keypad (Off)
4636 When set to \fBOn\fP, readline will try to enable the application
4637 keypad when it is called. Some systems need this to enable the
4640 .B expand\-tilde (Off)
4641 If set to \fBon\fP, tilde expansion is performed when readline
4642 attempts word completion.
4644 .B history\-preserve\-point (Off)
4645 If set to \fBon\fP, the history code attempts to place point at the
4646 same location on each history line retrieved with \fBprevious-history\fP
4647 or \fBnext-history\fP.
4649 .B horizontal\-scroll\-mode (Off)
4650 When set to \fBOn\fP, makes readline use a single line for display,
4651 scrolling the input horizontally on a single screen line when it
4652 becomes longer than the screen width rather than wrapping to a new line.
4654 .B input\-meta (Off)
4655 If set to \fBOn\fP, readline will enable eight-bit input (that is,
4656 it will not strip the high bit from the characters it reads),
4657 regardless of what the terminal claims it can support. The name
4659 is a synonym for this variable.
4661 .B isearch\-terminators (``C\-[C\-J'')
4662 The string of characters that should terminate an incremental
4663 search without subsequently executing the character as a command.
4664 If this variable has not been given a value, the characters
4665 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
4668 Set the current readline keymap. The set of valid keymap names is
4669 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4672 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4673 equivalent to \fIemacs\-standard\fP. The default value is
4677 also affects the default keymap.
4679 .B mark\-directories (On)
4680 If set to \fBOn\fP, completed directory names have a slash
4683 .B mark\-modified\-lines (Off)
4684 If set to \fBOn\fP, history lines that have been modified are displayed
4685 with a preceding asterisk (\fB*\fP).
4687 .B mark\-symlinked\-directories (Off)
4688 If set to \fBOn\fP, completed names which are symbolic links to directories
4689 have a slash appended (subject to the value of
4690 \fBmark\-directories\fP).
4692 .B match\-hidden\-files (On)
4693 This variable, when set to \fBOn\fP, causes readline to match files whose
4694 names begin with a `.' (hidden files) when performing filename
4695 completion, unless the leading `.' is
4696 supplied by the user in the filename to be completed.
4698 .B output\-meta (Off)
4699 If set to \fBOn\fP, readline will display characters with the
4700 eighth bit set directly rather than as a meta-prefixed escape
4703 .B page\-completions (On)
4704 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
4705 to display a screenful of possible completions at a time.
4707 .B print\-completions\-horizontally (Off)
4708 If set to \fBOn\fP, readline will display completions with matches
4709 sorted horizontally in alphabetical order, rather than down the screen.
4711 .B show\-all\-if\-ambiguous (Off)
4712 This alters the default behavior of the completion functions. If
4715 words which have more than one possible completion cause the
4716 matches to be listed immediately instead of ringing the bell.
4718 .B show\-all\-if\-unmodified (Off)
4719 This alters the default behavior of the completion functions in
4720 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
4723 words which have more than one possible completion without any
4724 possible partial completion (the possible completions don't share
4725 a common prefix) cause the matches to be listed immediately instead
4726 of ringing the bell.
4728 .B visible\-stats (Off)
4729 If set to \fBOn\fP, a character denoting a file's type as reported
4730 by \fIstat\fP(2) is appended to the filename when listing possible
4733 .SS "Readline Conditional Constructs"
4735 Readline implements a facility similar in spirit to the conditional
4736 compilation features of the C preprocessor which allows key
4737 bindings and variable settings to be performed as the result
4738 of tests. There are four parser directives used.
4742 construct allows bindings to be made based on the
4743 editing mode, the terminal being used, or the application using
4744 readline. The text of the test extends to the end of the line;
4745 no characters are required to isolate it.
4748 The \fBmode=\fP form of the \fB$if\fP directive is used to test
4749 whether readline is in emacs or vi mode.
4750 This may be used in conjunction
4751 with the \fBset keymap\fP command, for instance, to set bindings in
4752 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
4753 readline is starting out in emacs mode.
4755 The \fBterm=\fP form may be used to include terminal-specific
4756 key bindings, perhaps to bind the key sequences output by the
4757 terminal's function keys. The word on the right side of the
4759 is tested against the both full name of the terminal and the portion
4760 of the terminal name before the first \fB\-\fP. This allows
4767 .IP \fBapplication\fP
4768 The \fBapplication\fP construct is used to include
4769 application-specific settings. Each program using the readline
4770 library sets the \fIapplication name\fP, and an initialization
4771 file can test for a particular value.
4772 This could be used to bind key sequences to functions useful for
4773 a specific program. For instance, the following command adds a
4774 key sequence that quotes the current or previous word in Bash:
4779 # Quote the current or previous word
4780 "\eC\-xq": "\eeb\e"\eef\e""
4786 This command, as seen in the previous example, terminates an
4789 Commands in this branch of the \fB$if\fP directive are executed if
4792 This directive takes a single filename as an argument and reads commands
4793 and bindings from that file. For example, the following directive
4794 would read \fI/etc/inputrc\fP:
4798 \fB$include\fP \^ \fI/etc/inputrc\fP
4803 Readline provides commands for searching through the command history
4807 below) for lines containing a specified string.
4808 There are two search modes:
4811 .IR non-incremental .
4813 Incremental searches begin before the user has finished typing the
4815 As each character of the search string is typed, readline displays
4816 the next entry from the history matching the string typed so far.
4817 An incremental search requires only as many characters as needed to
4818 find the desired history entry.
4819 The characters present in the value of the \fBisearch-terminators\fP
4820 variable are used to terminate an incremental search.
4821 If that variable has not been assigned a value the Escape and
4822 Control-J characters will terminate an incremental search.
4823 Control-G will abort an incremental search and restore the original
4825 When the search is terminated, the history entry containing the
4826 search string becomes the current line.
4828 To find other matching entries in the history list, type Control-S or
4829 Control-R as appropriate.
4830 This will search backward or forward in the history for the next
4831 entry matching the search string typed so far.
4832 Any other key sequence bound to a readline command will terminate
4833 the search and execute that command.
4834 For instance, a \fInewline\fP will terminate the search and accept
4835 the line, thereby executing the command from the history list.
4837 Readline remembers the last incremental search string. If two
4838 Control-Rs are typed without any intervening characters defining a
4839 new search string, any remembered search string is used.
4841 Non-incremental searches read the entire search string before starting
4842 to search for matching history lines. The search string may be
4843 typed by the user or be part of the contents of the current line.
4844 .SS "Readline Command Names"
4846 The following is a list of the names of the commands and the default
4847 key sequences to which they are bound.
4848 Command names without an accompanying key sequence are unbound by default.
4849 In the following descriptions, \fIpoint\fP refers to the current cursor
4850 position, and \fImark\fP refers to a cursor position saved by the
4851 \fBset\-mark\fP command.
4852 The text between the point and mark is referred to as the \fIregion\fP.
4853 .SS Commands for Moving
4857 .B beginning\-of\-line (C\-a)
4858 Move to the start of the current line.
4860 .B end\-of\-line (C\-e)
4861 Move to the end of the line.
4863 .B forward\-char (C\-f)
4864 Move forward a character.
4866 .B backward\-char (C\-b)
4867 Move back a character.
4869 .B forward\-word (M\-f)
4870 Move forward to the end of the next word. Words are composed of
4871 alphanumeric characters (letters and digits).
4873 .B backward\-word (M\-b)
4874 Move back to the start of the current or previous word. Words are
4875 composed of alphanumeric characters (letters and digits).
4877 .B clear\-screen (C\-l)
4878 Clear the screen leaving the current line at the top of the screen.
4879 With an argument, refresh the current line without clearing the
4882 .B redraw\-current\-line
4883 Refresh the current line.
4885 .SS Commands for Manipulating the History
4889 .B accept\-line (Newline, Return)
4890 Accept the line regardless of where the cursor is. If this line is
4891 non-empty, add it to the history list according to the state of the
4894 variable. If the line is a modified history
4895 line, then restore the history line to its original state.
4897 .B previous\-history (C\-p)
4898 Fetch the previous command from the history list, moving back in
4901 .B next\-history (C\-n)
4902 Fetch the next command from the history list, moving forward in the
4905 .B beginning\-of\-history (M\-<)
4906 Move to the first line in the history.
4908 .B end\-of\-history (M\->)
4909 Move to the end of the input history, i.e., the line currently being
4912 .B reverse\-search\-history (C\-r)
4913 Search backward starting at the current line and moving `up' through
4914 the history as necessary. This is an incremental search.
4916 .B forward\-search\-history (C\-s)
4917 Search forward starting at the current line and moving `down' through
4918 the history as necessary. This is an incremental search.
4920 .B non\-incremental\-reverse\-search\-history (M\-p)
4921 Search backward through the history starting at the current line
4922 using a non-incremental search for a string supplied by the user.
4924 .B non\-incremental\-forward\-search\-history (M\-n)
4925 Search forward through the history using a non-incremental search for
4926 a string supplied by the user.
4928 .B history\-search\-forward
4929 Search forward through the history for the string of characters
4930 between the start of the current line and the point.
4931 This is a non-incremental search.
4933 .B history\-search\-backward
4934 Search backward through the history for the string of characters
4935 between the start of the current line and the point.
4936 This is a non-incremental search.
4938 .B yank\-nth\-arg (M\-C\-y)
4939 Insert the first argument to the previous command (usually
4940 the second word on the previous line) at point.
4943 insert the \fIn\fPth word from the previous command (the words
4944 in the previous command begin with word 0). A negative argument
4945 inserts the \fIn\fPth word from the end of the previous command.
4946 Once the argument \fIn\fP is computed, the argument is extracted
4947 as if the "!\fIn\fP" history expansion had been specified.
4950 yank\-last\-arg (M\-.\^, M\-_\^)
4951 Insert the last argument to the previous command (the last word of
4952 the previous history entry). With an argument,
4953 behave exactly like \fByank\-nth\-arg\fP.
4954 Successive calls to \fByank\-last\-arg\fP move back through the history
4955 list, inserting the last argument of each line in turn.
4956 The history expansion facilities are used to extract the last argument,
4957 as if the "!$" history expansion had been specified.
4959 .B shell\-expand\-line (M\-C\-e)
4960 Expand the line as the shell does. This
4961 performs alias and history expansion as well as all of the shell
4962 word expansions. See
4964 .B HISTORY EXPANSION
4965 below for a description of history expansion.
4967 .B history\-expand\-line (M\-^)
4968 Perform history expansion on the current line.
4971 .B HISTORY EXPANSION
4972 below for a description of history expansion.
4975 Perform history expansion on the current line and insert a space.
4978 .B HISTORY EXPANSION
4979 below for a description of history expansion.
4981 .B alias\-expand\-line
4982 Perform alias expansion on the current line.
4986 above for a description of alias expansion.
4988 .B history\-and\-alias\-expand\-line
4989 Perform history and alias expansion on the current line.
4991 .B insert\-last\-argument (M\-.\^, M\-_\^)
4992 A synonym for \fByank\-last\-arg\fP.
4994 .B operate\-and\-get\-next (C\-o)
4995 Accept the current line for execution and fetch the next line
4996 relative to the current line from the history for editing. Any
4997 argument is ignored.
4999 .B edit\-and\-execute\-command (C\-xC\-e)
5000 Invoke an editor on the current command line, and execute the result as shell
5002 \fBBash\fP attempts to invoke
5007 and \fIemacs\fP as the editor, in that order.
5009 .SS Commands for Changing Text
5013 .B delete\-char (C\-d)
5014 Delete the character at point. If point is at the
5015 beginning of the line, there are no characters in the line, and
5016 the last character typed was not bound to \fBdelete\-char\fP,
5021 .B backward\-delete\-char (Rubout)
5022 Delete the character behind the cursor. When given a numeric argument,
5023 save the deleted text on the kill ring.
5025 .B forward\-backward\-delete\-char
5026 Delete the character under the cursor, unless the cursor is at the
5027 end of the line, in which case the character behind the cursor is
5030 .B quoted\-insert (C\-q, C\-v)
5031 Add the next character typed to the line verbatim. This is
5032 how to insert characters like \fBC\-q\fP, for example.
5034 .B tab\-insert (C\-v TAB)
5035 Insert a tab character.
5037 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
5038 Insert the character typed.
5040 .B transpose\-chars (C\-t)
5041 Drag the character before point forward over the character at point,
5042 moving point forward as well.
5043 If point is at the end of the line, then this transposes
5044 the two characters before point.
5045 Negative arguments have no effect.
5047 .B transpose\-words (M\-t)
5048 Drag the word before point past the word after point,
5049 moving point over that word as well.
5050 If point is at the end of the line, this transposes
5051 the last two words on the line.
5053 .B upcase\-word (M\-u)
5054 Uppercase the current (or following) word. With a negative argument,
5055 uppercase the previous word, but do not move point.
5057 .B downcase\-word (M\-l)
5058 Lowercase the current (or following) word. With a negative argument,
5059 lowercase the previous word, but do not move point.
5061 .B capitalize\-word (M\-c)
5062 Capitalize the current (or following) word. With a negative argument,
5063 capitalize the previous word, but do not move point.
5066 Toggle overwrite mode. With an explicit positive numeric argument,
5067 switches to overwrite mode. With an explicit non-positive numeric
5068 argument, switches to insert mode. This command affects only
5069 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
5070 Each call to \fIreadline()\fP starts in insert mode.
5071 In overwrite mode, characters bound to \fBself\-insert\fP replace
5072 the text at point rather than pushing the text to the right.
5073 Characters bound to \fBbackward\-delete\-char\fP replace the character
5074 before point with a space. By default, this command is unbound.
5076 .SS Killing and Yanking
5080 .B kill\-line (C\-k)
5081 Kill the text from point to the end of the line.
5083 .B backward\-kill\-line (C\-x Rubout)
5084 Kill backward to the beginning of the line.
5086 .B unix\-line\-discard (C\-u)
5087 Kill backward from point to the beginning of the line.
5088 The killed text is saved on the kill-ring.
5089 .\" There is no real difference between this and backward-kill-line
5091 .B kill\-whole\-line
5092 Kill all characters on the current line, no matter where point is.
5094 .B kill\-word (M\-d)
5095 Kill from point to the end of the current word, or if between
5096 words, to the end of the next word.
5097 Word boundaries are the same as those used by \fBforward\-word\fP.
5099 .B backward\-kill\-word (M\-Rubout)
5100 Kill the word behind point.
5101 Word boundaries are the same as those used by \fBbackward\-word\fP.
5103 .B unix\-word\-rubout (C\-w)
5104 Kill the word behind point, using white space as a word boundary.
5105 The killed text is saved on the kill-ring.
5107 .B unix\-filename\-rubout
5108 Kill the word behind point, using white space and the slash character
5109 as the word boundaries.
5110 The killed text is saved on the kill-ring.
5112 .B delete\-horizontal\-space (M\-\e)
5113 Delete all spaces and tabs around point.
5116 Kill the text in the current region.
5118 .B copy\-region\-as\-kill
5119 Copy the text in the region to the kill buffer.
5121 .B copy\-backward\-word
5122 Copy the word before point to the kill buffer.
5123 The word boundaries are the same as \fBbackward\-word\fP.
5125 .B copy\-forward\-word
5126 Copy the word following point to the kill buffer.
5127 The word boundaries are the same as \fBforward\-word\fP.
5130 Yank the top of the kill ring into the buffer at point.
5133 Rotate the kill ring, and yank the new top. Only works following
5138 .SS Numeric Arguments
5142 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
5143 Add this digit to the argument already accumulating, or start a new
5144 argument. M\-\- starts a negative argument.
5146 .B universal\-argument
5147 This is another way to specify an argument.
5148 If this command is followed by one or more digits, optionally with a
5149 leading minus sign, those digits define the argument.
5150 If the command is followed by digits, executing
5151 .B universal\-argument
5152 again ends the numeric argument, but is otherwise ignored.
5153 As a special case, if this command is immediately followed by a
5154 character that is neither a digit or minus sign, the argument count
5155 for the next command is multiplied by four.
5156 The argument count is initially one, so executing this function the
5157 first time makes the argument count four, a second time makes the
5158 argument count sixteen, and so on.
5165 Attempt to perform completion on the text before point.
5167 attempts completion treating the text as a variable (if the
5168 text begins with \fB$\fP), username (if the text begins with
5169 \fB~\fP), hostname (if the text begins with \fB@\fP), or
5170 command (including aliases and functions) in turn. If none
5171 of these produces a match, filename completion is attempted.
5173 .B possible\-completions (M\-?)
5174 List the possible completions of the text before point.
5176 .B insert\-completions (M\-*)
5177 Insert all completions of the text before point
5178 that would have been generated by
5179 \fBpossible\-completions\fP.
5182 Similar to \fBcomplete\fP, but replaces the word to be completed
5183 with a single match from the list of possible completions.
5184 Repeated execution of \fBmenu\-complete\fP steps through the list
5185 of possible completions, inserting each match in turn.
5186 At the end of the list of completions, the bell is rung
5187 (subject to the setting of \fBbell\-style\fP)
5188 and the original text is restored.
5189 An argument of \fIn\fP moves \fIn\fP positions forward in the list
5190 of matches; a negative argument may be used to move backward
5192 This command is intended to be bound to \fBTAB\fP, but is unbound
5195 .B delete\-char\-or\-list
5196 Deletes the character under the cursor if not at the beginning or
5197 end of the line (like \fBdelete\-char\fP).
5198 If at the end of the line, behaves identically to
5199 \fBpossible\-completions\fP.
5200 This command is unbound by default.
5202 .B complete\-filename (M\-/)
5203 Attempt filename completion on the text before point.
5205 .B possible\-filename\-completions (C\-x /)
5206 List the possible completions of the text before point,
5207 treating it as a filename.
5209 .B complete\-username (M\-~)
5210 Attempt completion on the text before point, treating
5213 .B possible\-username\-completions (C\-x ~)
5214 List the possible completions of the text before point,
5215 treating it as a username.
5217 .B complete\-variable (M\-$)
5218 Attempt completion on the text before point, treating
5219 it as a shell variable.
5221 .B possible\-variable\-completions (C\-x $)
5222 List the possible completions of the text before point,
5223 treating it as a shell variable.
5225 .B complete\-hostname (M\-@)
5226 Attempt completion on the text before point, treating
5229 .B possible\-hostname\-completions (C\-x @)
5230 List the possible completions of the text before point,
5231 treating it as a hostname.
5233 .B complete\-command (M\-!)
5234 Attempt completion on the text before point, treating
5235 it as a command name. Command completion attempts to
5236 match the text against aliases, reserved words, shell
5237 functions, shell builtins, and finally executable filenames,
5240 .B possible\-command\-completions (C\-x !)
5241 List the possible completions of the text before point,
5242 treating it as a command name.
5244 .B dynamic\-complete\-history (M\-TAB)
5245 Attempt completion on the text before point, comparing
5246 the text against lines from the history list for possible
5249 .B complete\-into\-braces (M\-{)
5250 Perform filename completion and insert the list of possible completions
5251 enclosed within braces so the list is available to the shell (see
5259 .B start\-kbd\-macro (C\-x (\^)
5260 Begin saving the characters typed into the current keyboard macro.
5262 .B end\-kbd\-macro (C\-x )\^)
5263 Stop saving the characters typed into the current keyboard macro
5264 and store the definition.
5266 .B call\-last\-kbd\-macro (C\-x e)
5267 Re-execute the last keyboard macro defined, by making the characters
5268 in the macro appear as if typed at the keyboard.
5274 .B re\-read\-init\-file (C\-x C\-r)
5275 Read in the contents of the \fIinputrc\fP file, and incorporate
5276 any bindings or variable assignments found there.
5279 Abort the current editing command and
5280 ring the terminal's bell (subject to the setting of
5283 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
5284 If the metafied character \fIx\fP is lowercase, run the command
5285 that is bound to the corresponding uppercase character.
5287 .B prefix\-meta (ESC)
5288 Metafy the next character typed.
5295 .B undo (C\-_, C\-x C\-u)
5296 Incremental undo, separately remembered for each line.
5298 .B revert\-line (M\-r)
5299 Undo all changes made to this line. This is like executing the
5301 command enough times to return the line to its initial state.
5303 .B tilde\-expand (M\-&)
5304 Perform tilde expansion on the current word.
5306 .B set\-mark (C\-@, M\-<space>)
5307 Set the mark to the point. If a
5308 numeric argument is supplied, the mark is set to that position.
5310 .B exchange\-point\-and\-mark (C\-x C\-x)
5311 Swap the point with the mark. The current cursor position is set to
5312 the saved position, and the old cursor position is saved as the mark.
5314 .B character\-search (C\-])
5315 A character is read and point is moved to the next occurrence of that
5316 character. A negative count searches for previous occurrences.
5318 .B character\-search\-backward (M\-C\-])
5319 A character is read and point is moved to the previous occurrence of that
5320 character. A negative count searches for subsequent occurrences.
5322 .B insert\-comment (M\-#)
5323 Without a numeric argument, the value of the readline
5325 variable is inserted at the beginning of the current line.
5326 If a numeric argument is supplied, this command acts as a toggle: if
5327 the characters at the beginning of the line do not match the value
5328 of \fBcomment\-begin\fP, the value is inserted, otherwise
5329 the characters in \fBcomment-begin\fP are deleted from the beginning of
5331 In either case, the line is accepted as if a newline had been typed.
5332 The default value of
5333 \fBcomment\-begin\fP causes this command to make the current line
5335 If a numeric argument causes the comment character to be removed, the line
5336 will be executed by the shell.
5338 .B glob\-complete\-word (M\-g)
5339 The word before point is treated as a pattern for pathname expansion,
5340 with an asterisk implicitly appended. This pattern is used to
5341 generate a list of matching file names for possible completions.
5343 .B glob\-expand\-word (C\-x *)
5344 The word before point is treated as a pattern for pathname expansion,
5345 and the list of matching file names is inserted, replacing the word.
5346 If a numeric argument is supplied, an asterisk is appended before
5349 .B glob\-list\-expansions (C\-x g)
5350 The list of expansions that would have been generated by
5351 .B glob\-expand\-word
5352 is displayed, and the line is redrawn.
5353 If a numeric argument is supplied, an asterisk is appended before
5357 Print all of the functions and their key bindings to the
5358 readline output stream. If a numeric argument is supplied,
5359 the output is formatted in such a way that it can be made part
5360 of an \fIinputrc\fP file.
5363 Print all of the settable readline variables and their values to the
5364 readline output stream. If a numeric argument is supplied,
5365 the output is formatted in such a way that it can be made part
5366 of an \fIinputrc\fP file.
5369 Print all of the readline key sequences bound to macros and the
5370 strings they output. If a numeric argument is supplied,
5371 the output is formatted in such a way that it can be made part
5372 of an \fIinputrc\fP file.
5374 .B display\-shell\-version (C\-x C\-v)
5375 Display version information about the current instance of
5378 .SS Programmable Completion
5380 When word completion is attempted for an argument to a command for
5381 which a completion specification (a \fIcompspec\fP) has been defined
5382 using the \fBcomplete\fP builtin (see
5384 .B "SHELL BUILTIN COMMANDS"
5385 below), the programmable completion facilities are invoked.
5387 First, the command name is identified.
5388 If a compspec has been defined for that command, the
5389 compspec is used to generate the list of possible completions for the word.
5390 If the command word is a full pathname, a compspec for the full
5391 pathname is searched for first.
5392 If no compspec is found for the full pathname, an attempt is made to
5393 find a compspec for the portion following the final slash.
5395 Once a compspec has been found, it is used to generate the list of
5397 If a compspec is not found, the default \fBbash\fP completion as
5398 described above under \fBCompleting\fP is performed.
5400 First, the actions specified by the compspec are used.
5401 Only matches which are prefixed by the word being completed are
5407 option is used for filename or directory name completion, the shell
5411 is used to filter the matches.
5413 Any completions specified by a filename expansion pattern to the
5414 \fB\-G\fP option are generated next.
5415 The words generated by the pattern need not match the word
5420 shell variable is not used to filter the matches, but the
5425 Next, the string specified as the argument to the \fB\-W\fP option
5427 The string is first split using the characters in the
5430 special variable as delimiters.
5431 Shell quoting is honored.
5432 Each word is then expanded using
5433 brace expansion, tilde expansion, parameter and variable expansion,
5434 command substitution, and arithmetic expansion,
5435 as described above under
5438 The results are split using the rules described above under
5439 \fBWord Splitting\fP.
5440 The results of the expansion are prefix-matched against the word being
5441 completed, and the matching words become the possible completions.
5443 After these matches have been generated, any shell function or command
5444 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
5445 When the command or function is invoked, the
5451 variables are assigned values as described above under
5452 \fBShell Variables\fP.
5453 If a shell function is being invoked, the
5459 variables are also set.
5460 When the function or command is invoked, the first argument is the
5461 name of the command whose arguments are being completed, the
5462 second argument is the word being completed, and the third argument
5463 is the word preceding the word being completed on the current command line.
5464 No filtering of the generated completions against the word being completed
5465 is performed; the function or command has complete freedom in generating
5468 Any function specified with \fB\-F\fP is invoked first.
5469 The function may use any of the shell facilities, including the
5470 \fBcompgen\fP builtin described below, to generate the matches.
5471 It must put the possible completions in the
5476 Next, any command specified with the \fB\-C\fP option is invoked
5477 in an environment equivalent to command substitution.
5478 It should print a list of completions, one per line, to the
5480 Backslash may be used to escape a newline, if necessary.
5482 After all of the possible completions are generated, any filter
5483 specified with the \fB\-X\fP option is applied to the list.
5484 The filter is a pattern as used for pathname expansion; a \fB&\fP
5485 in the pattern is replaced with the text of the word being completed.
5486 A literal \fB&\fP may be escaped with a backslash; the backslash
5487 is removed before attempting a match.
5488 Any completion that matches the pattern will be removed from the list.
5489 A leading \fB!\fP negates the pattern; in this case any completion
5490 not matching the pattern will be removed.
5492 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
5493 options are added to each member of the completion list, and the result is
5494 returned to the readline completion code as the list of possible
5497 If the previously-applied actions do not generate any matches, and the
5498 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
5499 compspec was defined, directory name completion is attempted.
5501 If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
5502 compspec was defined, directory name completion is attempted and any
5503 matches are added to the results of the other actions.
5505 By default, if a compspec is found, whatever it generates is returned
5506 to the completion code as the full set of possible completions.
5507 The default \fBbash\fP completions are not attempted, and the readline
5508 default of filename completion is disabled.
5509 If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when
5510 the compspec was defined, the \fBbash\fP default completions are attempted
5511 if the compspec generates no matches.
5512 If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
5513 compspec was defined, readline's default completion will be performed
5514 if the compspec (and, if attempted, the default \fBbash\fP completions)
5515 generate no matches.
5517 When a compspec indicates that directory name completion is desired,
5518 the programmable completion functions force readline to append a slash
5519 to completed names which are symbolic links to directories, subject to
5520 the value of the \fBmark\-directories\fP readline variable, regardless
5521 of the setting of the \fBmark-symlinked\-directories\fP readline variable.
5527 builtin is enabled, the shell provides access to the
5528 \fIcommand history\fP,
5529 the list of commands previously typed.
5530 The value of the \fBHISTSIZE\fP variable is used as the
5531 number of commands to save in a history list.
5532 The text of the last
5535 commands (default 500) is saved. The shell
5536 stores each command in the history list prior to parameter and
5537 variable expansion (see
5540 above) but after history expansion is performed, subject to the
5541 values of the shell variables
5548 On startup, the history is initialized from the file named by
5552 (default \fI~/.bash_history\fP).
5553 The file named by the value of
5556 is truncated, if necessary, to contain no more than
5557 the number of lines specified by the value of
5560 When an interactive shell exits, the last
5563 lines are copied from the history list to
5568 shell option is enabled
5569 (see the description of
5573 .B "SHELL BUILTIN COMMANDS"
5574 below), the lines are appended to the history file,
5575 otherwise the history file is overwritten.
5579 is unset, or if the history file is unwritable, the history is
5580 not saved. After saving the history, the history file is truncated
5581 to contain no more than
5587 is not set, no truncation is performed.
5593 .B SHELL BUILTIN COMMANDS
5594 below) may be used to list or edit and re-execute a portion of
5598 builtin may be used to display or modify the history list and
5599 manipulate the history file.
5600 When using command-line editing, search commands
5601 are available in each editing mode that provide access to the
5604 The shell allows control over which commands are saved on the history
5611 variables may be set to cause the shell to save only a subset of the
5615 shell option, if enabled, causes the shell to attempt to save each
5616 line of a multi-line command in the same history entry, adding
5617 semicolons where necessary to preserve syntactic correctness.
5620 shell option causes the shell to save the command with embedded newlines
5621 instead of semicolons. See the description of the
5625 .B "SHELL BUILTIN COMMANDS"
5626 for information on setting and unsetting shell options.
5627 .SH "HISTORY EXPANSION"
5629 The shell supports a history expansion feature that
5630 is similar to the history expansion in
5632 This section describes what syntax features are available. This
5633 feature is enabled by default for interactive shells, and can be
5638 builtin command (see
5640 .B SHELL BUILTIN COMMANDS
5641 below). Non-interactive shells do not perform history expansion
5644 History expansions introduce words from the history list into
5645 the input stream, making it easy to repeat commands, insert the
5646 arguments to a previous command into the current input line, or
5647 fix errors in previous commands quickly.
5649 History expansion is performed immediately after a complete line
5650 is read, before the shell breaks it into words.
5651 It takes place in two parts.
5652 The first is to determine which line from the history list
5653 to use during substitution.
5654 The second is to select portions of that line for inclusion into
5656 The line selected from the history is the \fIevent\fP,
5657 and the portions of that line that are acted upon are \fIwords\fP.
5658 Various \fImodifiers\fP are available to manipulate the selected words.
5659 The line is broken into words in the same fashion as when reading input,
5660 so that several \fImetacharacter\fP-separated words surrounded by
5661 quotes are considered one word.
5662 History expansions are introduced by the appearance of the
5663 history expansion character, which is \^\fB!\fP\^ by default.
5664 Only backslash (\^\fB\e\fP\^) and single quotes can quote
5665 the history expansion character.
5667 Several characters inhibit history expansion if found immediately
5668 following the history expansion character, even if it is unquoted:
5669 space, tab, newline, carriage return, and \fB=\fP.
5670 If the \fBextglob\fP shell option is enabled, \fB(\fP will also
5673 Several shell options settable with the
5675 builtin may be used to tailor the behavior of history expansion.
5678 shell option is enabled (see the description of the
5682 is being used, history substitutions are not immediately passed to
5684 Instead, the expanded line is reloaded into the
5686 editing buffer for further modification.
5689 is being used, and the
5691 shell option is enabled, a failed history substitution will be reloaded
5694 editing buffer for correction.
5699 builtin command may be used to see what a history expansion will
5705 builtin may be used to add commands to the end of the history list
5706 without actually executing them, so that they are available for
5709 The shell allows control of the various characters used by the
5710 history expansion mechanism (see the description of
5713 .BR "Shell Variables" ).
5714 .SS Event Designators
5716 An event designator is a reference to a command line entry in the
5722 Start a history substitution, except when followed by a
5724 newline, carriage return, =
5725 or ( (when the \fBextglob\fP shell option is enabled using
5726 the \fBshopt\fP builtin).
5729 Refer to command line
5733 Refer to the current command line minus
5737 Refer to the previous command. This is a synonym for `!\-1'.
5740 Refer to the most recent command starting with
5743 .B !?\fIstring\fR\fB[?]\fR
5744 Refer to the most recent command containing
5746 The trailing \fB?\fP may be omitted if
5748 is followed immediately by a newline.
5750 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
5751 Quick substitution. Repeat the last command, replacing
5756 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
5757 (see \fBModifiers\fP below).
5760 The entire command line typed so far.
5762 .SS Word Designators
5764 Word designators are used to select desired words from the event.
5767 separates the event specification from the word designator.
5768 It may be omitted if the word designator begins with a
5775 Words are numbered from the beginning of the line,
5776 with the first word being denoted by 0 (zero).
5777 Words are inserted into the current line separated by single spaces.
5782 The zeroth word. For the shell, this is the command
5789 The first argument. That is, word 1.
5795 The word matched by the most recent `?\fIstring\fR?' search.
5798 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
5801 All of the words but the zeroth. This is a synonym
5802 for `\fI1\-$\fP'. It is not an error to use
5804 if there is just one
5805 word in the event; the empty string is returned in that case.
5808 Abbreviates \fIx\-$\fP.
5811 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
5814 If a word designator is supplied without an event specification, the
5815 previous command is used as the event.
5818 After the optional word designator, there may appear a sequence of
5819 one or more of the following modifiers, each preceded by a `:'.
5825 Remove a trailing file name component, leaving only the head.
5828 Remove all leading file name components, leaving the tail.
5831 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
5835 Remove all but the trailing suffix.
5838 Print the new command but do not execute it.
5841 Quote the substituted words, escaping further substitutions.
5844 Quote the substituted words as with
5846 but break into words at
5850 .B s/\fIold\fP/\fInew\fP/
5853 for the first occurrence of
5855 in the event line. Any delimiter can be used in place of /. The
5856 final delimiter is optional if it is the last character of the
5857 event line. The delimiter may be quoted in
5861 with a single backslash. If & appears in
5865 A single backslash will quote the &. If
5867 is null, it is set to the last
5869 substituted, or, if no previous history substitutions took place,
5873 .B !?\fIstring\fR\fB[?]\fR
5877 Repeat the previous substitution.
5880 Cause changes to be applied over the entire event line. This is
5881 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
5882 or `\fB:&\fP'. If used with
5883 `\fB:s\fP', any delimiter can be used
5884 in place of /, and the final delimiter is optional
5885 if it is the last character of the event line.
5886 An \fBa\fP may be used as a synonym for \fBg\fP.
5889 Apply the following `\fBs\fP' modifier once to each word in the event line.
5891 .SH "SHELL BUILTIN COMMANDS"
5892 .\" start of bash_builtins
5895 Unless otherwise noted, each builtin command documented in this
5896 section as accepting options preceded by
5900 to signify the end of the options.
5901 For example, the \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
5902 do not accept options.
5906 \fB:\fP [\fIarguments\fP]
5908 No effect; the command does nothing beyond expanding
5910 and performing any specified
5911 redirections. A zero exit code is returned.
5913 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
5916 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
5918 Read and execute commands from
5921 shell environment and return the exit status of the last command
5926 does not contain a slash, file names in
5929 are used to find the directory containing
5931 The file searched for in
5934 need not be executable.
5935 When \fBbash\fP is not in \fIposix mode\fP, the current directory is
5936 searched if no file is found in
5943 builtin command is turned off, the
5947 If any \fIarguments\fP are supplied, they become the positional
5948 parameters when \fIfilename\fP is executed. Otherwise the positional
5949 parameters are unchanged.
5950 The return status is the status of the last command exited within
5951 the script (0 if no commands are executed), and false if
5953 is not found or cannot be read.
5955 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
5956 \fBAlias\fP with no arguments or with the
5958 option prints the list of aliases in the form
5959 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
5960 When arguments are supplied, an alias is defined for
5961 each \fIname\fP whose \fIvalue\fP is given.
5962 A trailing space in \fIvalue\fP causes the next word to be
5963 checked for alias substitution when the alias is expanded.
5964 For each \fIname\fP in the argument list for which no \fIvalue\fP
5965 is supplied, the name and value of the alias is printed.
5966 \fBAlias\fP returns true unless a \fIname\fP is given for which
5967 no alias has been defined.
5969 \fBbg\fP [\fIjobspec\fP ...]
5970 Resume each suspended job \fIjobspec\fP in the background, as if it
5971 had been started with
5973 If \fIjobspec\fP is not present, the shell's notion of the
5974 \fIcurrent job\fP is used.
5977 returns 0 unless run when job control is disabled or, when run with
5978 job control enabled, any specified \fIjobspec\fP was not found
5979 or was started without job control.
5981 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
5984 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
5986 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
5988 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
5990 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
5992 \fBbind\fP \fIreadline\-command\fP
5996 key and function bindings, bind a key sequence to a
5998 function or macro, or set a
6001 Each non-option argument is a command as it would appear in
6003 but each binding or command must be passed as a separate argument;
6004 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
6005 Options, if supplied, have the following meanings:
6012 as the keymap to be affected by the subsequent bindings.
6016 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
6017 vi\-move, vi\-command\fP, and
6019 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
6020 equivalent to \fIemacs\-standard\fP.
6023 List the names of all \fBreadline\fP functions.
6026 Display \fBreadline\fP function names and bindings in such a way
6027 that they can be re-read.
6030 List current \fBreadline\fP function names and bindings.
6033 Display \fBreadline\fP variable names and values in such a way that they
6037 List current \fBreadline\fP variable names and values.
6040 Display \fBreadline\fP key sequences bound to macros and the strings
6041 they output in such a way that they can be re-read.
6044 Display \fBreadline\fP key sequences bound to macros and the strings
6047 .B \-f \fIfilename\fP
6048 Read key bindings from \fIfilename\fP.
6050 .B \-q \fIfunction\fP
6051 Query about which keys invoke the named \fIfunction\fP.
6053 .B \-u \fIfunction\fP
6054 Unbind all keys bound to the named \fIfunction\fP.
6057 Remove any current binding for \fIkeyseq\fP.
6059 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
6060 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
6064 The return value is 0 unless an unrecognized option is given or an
6068 \fBbreak\fP [\fIn\fP]
6075 loop. If \fIn\fP is specified, break \fIn\fP levels.
6079 is greater than the number of enclosing loops, all enclosing loops
6080 are exited. The return value is 0 unless the shell is not executing
6085 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
6086 Execute the specified shell builtin, passing it
6088 and return its exit status.
6089 This is useful when defining a
6090 function whose name is the same as a shell builtin,
6091 retaining the functionality of the builtin within the function.
6092 The \fBcd\fP builtin is commonly redefined this way.
6093 The return status is false if
6095 is not a shell builtin command.
6097 \fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
6098 Change the current directory to \fIdir\fP. The variable
6107 defines the search path for the directory containing
6109 Alternative directory names in
6112 are separated by a colon (:). A null directory name in
6115 is the same as the current directory, i.e., ``\fB.\fP''. If
6117 begins with a slash (/),
6123 option says to use the physical directory structure instead of
6124 following symbolic links (see also the
6128 builtin command); the
6130 option forces symbolic links to be followed. An argument of
6135 If a non-empty directory name from \fBCDPATH\fP is used, or if
6136 \fB\-\fP is the first argument, and the directory change is
6137 successful, the absolute pathname of the new working directory is
6138 written to the standard output.
6139 The return value is true if the directory was successfully changed;
6142 \fBcaller\fP [\fIexpr\fP]
6143 Returns the context of any active subroutine call (a shell function or
6144 a script executed with the \fB.\fP or \fBsource\fP builtins.
6145 Without \fIexpr\fP, \fBcaller\fP displays the line number and source
6146 filename of the current subroutine call.
6147 If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP
6148 displays the line number, subroutine name, and source file corresponding
6149 to that position in the current execution call stack. This extra
6150 information may be used, for example, to print a stack trace. The
6151 current frame is frame 0.
6152 The return value is 0 unless the shell is not executing a subroutine
6153 call or \fIexpr\fP does not correspond to a valid position in the
6156 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
6161 suppressing the normal shell function lookup. Only builtin
6162 commands or commands found in the
6165 are executed. If the
6167 option is given, the search for
6169 is performed using a default value for
6171 that is guaranteed to find all of the standard utilities.
6176 option is supplied, a description of
6180 option causes a single word indicating the command or file name
6183 to be displayed; the
6185 option produces a more verbose description.
6190 option is supplied, the exit status is 0 if
6192 was found, and 1 if not. If neither option is supplied and
6193 an error occurred or
6195 cannot be found, the exit status is 127. Otherwise, the exit status of the
6197 builtin is the exit status of
6200 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
6201 Generate possible completion matches for \fIword\fP according to
6202 the \fIoption\fPs, which may be any option accepted by the
6204 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
6205 the matches to the standard output.
6206 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
6207 set by the programmable completion facilities, while available, will not
6210 The matches will be generated in the same way as if the programmable
6211 completion code had generated them directly from a completion specification
6212 with the same flags.
6213 If \fIword\fP is specified, only those completions matching \fIword\fP
6216 The return value is true unless an invalid option is supplied, or no
6217 matches were generated.
6219 \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
6221 [\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
6224 \fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
6226 Specify how arguments to each \fIname\fP should be completed.
6227 If the \fB\-p\fP option is supplied, or if no options are supplied,
6228 existing completion specifications are printed in a way that allows
6229 them to be reused as input.
6230 The \fB\-r\fP option removes a completion specification for
6231 each \fIname\fP, or, if no \fIname\fPs are supplied, all
6232 completion specifications.
6234 The process of applying these completion specifications when word completion
6235 is attempted is described above under \fBProgrammable Completion\fP.
6237 Other options, if specified, have the following meanings.
6238 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
6239 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
6240 should be quoted to protect them from expansion before the
6246 \fB\-o\fP \fIcomp-option\fP
6247 The \fIcomp-option\fP controls several aspects of the compspec's behavior
6248 beyond the simple generation of completions.
6249 \fIcomp-option\fP may be one of:
6253 Perform the rest of the default \fBbash\fP completions if the compspec
6254 generates no matches.
6257 Use readline's default filename completion if the compspec generates
6261 Perform directory name completion if the compspec generates no matches.
6264 Tell readline that the compspec generates filenames, so it can perform any
6265 filename\-specific processing (like adding a slash to directory names or
6266 suppressing trailing spaces). Intended to be used with shell functions.
6269 Tell readline not to append a space (the default) to words completed at
6270 the end of the line.
6273 After any matches defined by the compspec are generated,
6274 directory name completion is attempted and any
6275 matches are added to the results of the other actions.
6278 \fB\-A\fP \fIaction\fP
6279 The \fIaction\fP may be one of the following to generate a list of possible
6284 Alias names. May also be specified as \fB\-a\fP.
6287 Array variable names.
6290 \fBReadline\fP key binding names.
6293 Names of shell builtin commands. May also be specified as \fB\-b\fP.
6296 Command names. May also be specified as \fB\-c\fP.
6299 Directory names. May also be specified as \fB\-d\fP.
6302 Names of disabled shell builtins.
6305 Names of enabled shell builtins.
6308 Names of exported shell variables. May also be specified as \fB\-e\fP.
6311 File names. May also be specified as \fB\-f\fP.
6314 Names of shell functions.
6317 Group names. May also be specified as \fB\-g\fP.
6320 Help topics as accepted by the \fBhelp\fP builtin.
6323 Hostnames, as taken from the file specified by the
6329 Job names, if job control is active. May also be specified as \fB\-j\fP.
6332 Shell reserved words. May also be specified as \fB\-k\fP.
6335 Names of running jobs, if job control is active.
6338 Service names. May also be specified as \fB\-s\fP.
6341 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
6344 Shell option names as accepted by the \fBshopt\fP builtin.
6350 Names of stopped jobs, if job control is active.
6353 User names. May also be specified as \fB\-u\fP.
6356 Names of all shell variables. May also be specified as \fB\-v\fP.
6359 \fB\-G\fP \fIglobpat\fP
6360 The filename expansion pattern \fIglobpat\fP is expanded to generate
6361 the possible completions.
6363 \fB\-W\fP \fIwordlist\fP
6364 The \fIwordlist\fP is split using the characters in the
6367 special variable as delimiters, and each resultant word is expanded.
6368 The possible completions are the members of the resultant list which
6369 match the word being completed.
6371 \fB\-C\fP \fIcommand\fP
6372 \fIcommand\fP is executed in a subshell environment, and its output is
6373 used as the possible completions.
6375 \fB\-F\fP \fIfunction\fP
6376 The shell function \fIfunction\fP is executed in the current shell
6378 When it finishes, the possible completions are retrieved from the value
6384 \fB\-X\fP \fIfilterpat\fP
6385 \fIfilterpat\fP is a pattern as used for filename expansion.
6386 It is applied to the list of possible completions generated by the
6387 preceding options and arguments, and each completion matching
6388 \fIfilterpat\fP is removed from the list.
6389 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
6390 case, any completion not matching \fIfilterpat\fP is removed.
6392 \fB\-P\fP \fIprefix\fP
6393 \fIprefix\fP is added at the beginning of each possible completion
6394 after all other options have been applied.
6396 \fB\-S\fP \fIsuffix\fP
6397 \fIsuffix\fP is appended to each possible completion
6398 after all other options have been applied.
6401 The return value is true unless an invalid option is supplied, an option
6402 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
6403 argument, an attempt is made to remove a completion specification for
6404 a \fIname\fP for which no specification exists, or
6405 an error occurs adding a completion specification.
6408 \fBcontinue\fP [\fIn\fP]
6409 Resume the next iteration of the enclosing
6418 is specified, resume at the \fIn\fPth enclosing loop.
6422 is greater than the number of enclosing loops, the last enclosing loop
6423 (the ``top-level'' loop) is resumed. The return value is 0 unless the
6424 shell is not executing a loop when
6428 \fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6431 \fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6433 Declare variables and/or give them attributes.
6434 If no \fIname\fPs are given then display the values of variables.
6437 option will display the attributes and values of each
6441 is used, additional options are ignored.
6444 option inhibits the display of function definitions; only the
6445 function name and attributes are printed.
6446 If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
6447 the source file name and line number where the function is defined
6448 are displayed as well. The
6452 The following options can
6453 be used to restrict output to variables with the specified attribute or
6454 to give variables attributes:
6459 Each \fIname\fP is an array variable (see
6464 Use function names only.
6467 The variable is treated as an integer; arithmetic evaluation (see
6469 .B "ARITHMETIC EVALUATION" ") "
6470 is performed when the variable is assigned a value.
6473 Make \fIname\fPs readonly. These names cannot then be assigned values
6474 by subsequent assignment statements or unset.
6477 Give each \fIname\fP the \fItrace\fP attribute.
6478 Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
6480 The trace attribute has no special meaning for variables.
6483 Mark \fIname\fPs for export to subsequent commands via the environment.
6486 Using `+' instead of `\-'
6487 turns off the attribute instead, with the exception that \fB+a\fP
6488 may not be used to destroy an array variable. When used in a function,
6490 \fIname\fP local, as with the
6493 If a variable name is followed by =\fIvalue\fP, the value of
6494 the variable is set to \fIvalue\fP.
6495 The return value is 0 unless an invalid option is encountered,
6496 an attempt is made to define a function using
6497 .if n ``\-f foo=bar'',
6498 .if t \f(CW\-f foo=bar\fP,
6499 an attempt is made to assign a value to a readonly variable,
6500 an attempt is made to assign a value to an array variable without
6501 using the compound assignment syntax (see
6503 above), one of the \fInames\fP is not a valid shell variable name,
6504 an attempt is made to turn off readonly status for a readonly variable,
6505 an attempt is made to turn off array status for an array variable,
6506 or an attempt is made to display a non-existent function with \fB\-f\fP.
6509 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
6510 Without options, displays the list of currently remembered directories.
6511 The default display is on a single line with directory names separated
6513 Directories are added to the list with the
6517 command removes entries from the list.
6522 Displays the \fIn\fPth entry counting from the left of the list
6525 when invoked without options, starting with zero.
6528 Displays the \fIn\fPth entry counting from the right of the list
6531 when invoked without options, starting with zero.
6534 Clears the directory stack by deleting all of the entries.
6537 Produces a longer listing; the default listing format uses a
6538 tilde to denote the home directory.
6541 Print the directory stack with one entry per line.
6544 Print the directory stack with one entry per line,
6545 prefixing each entry with its index in the stack.
6548 The return value is 0 unless an
6549 invalid option is supplied or \fIn\fP indexes beyond the end
6550 of the directory stack.
6553 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
6554 Without options, each
6556 is removed from the table of active jobs.
6557 If the \fB\-h\fP option is given, each
6559 is not removed from the table, but is marked so that
6562 is not sent to the job if the shell receives a
6567 is present, and neither the
6571 option is supplied, the \fIcurrent job\fP is used.
6576 option means to remove or mark all jobs; the
6580 argument restricts operation to running jobs.
6581 The return value is 0 unless a
6583 does not specify a valid job.
6585 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
6586 Output the \fIarg\fPs, separated by spaces, followed by a newline.
6587 The return status is always 0.
6588 If \fB\-n\fP is specified, the trailing newline is
6589 suppressed. If the \fB\-e\fP option is given, interpretation of
6590 the following backslash-escaped characters is enabled. The
6592 option disables the interpretation of these escape characters,
6593 even on systems where they are interpreted by default.
6594 The \fBxpg_echo\fP shell option may be used to
6595 dynamically determine whether or not \fBecho\fP expands these
6596 escape characters by default.
6598 does not interpret \fB\-\-\fP to mean the end of options.
6600 interprets the following escape sequences:
6611 suppress trailing newline
6635 the eight-bit character whose value is the octal value \fInnn\fP
6636 (zero to three octal digits)
6639 the eight-bit character whose value is the octal value \fInnn\fP
6640 (one to three octal digits)
6643 the eight-bit character whose value is the hexadecimal value \fIHH\fP
6644 (one or two hex digits)
6648 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
6649 Enable and disable builtin shell commands.
6650 Disabling a builtin allows a disk command which has the same name
6651 as a shell builtin to be executed without specifying a full pathname,
6652 even though the shell normally searches for builtins before disk commands.
6653 If \fB\-n\fP is used, each \fIname\fP
6654 is disabled; otherwise,
6655 \fInames\fP are enabled. For example, to use the
6657 binary found via the
6660 instead of the shell builtin version, run
6661 .if t \f(CWenable -n test\fP.
6662 .if n ``enable -n test''.
6665 option means to load the new builtin command
6669 on systems that support dynamic loading. The
6671 option will delete a builtin previously loaded with
6673 If no \fIname\fP arguments are given, or if the
6675 option is supplied, a list of shell builtins is printed.
6676 With no other option arguments, the list consists of all enabled
6678 If \fB\-n\fP is supplied, only disabled builtins are printed.
6679 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
6680 indication of whether or not each is enabled.
6681 If \fB\-s\fP is supplied, the output is restricted to the POSIX
6682 \fIspecial\fP builtins.
6683 The return value is 0 unless a
6685 is not a shell builtin or there is an error loading a new builtin
6686 from a shared object.
6688 \fBeval\fP [\fIarg\fP ...]
6689 The \fIarg\fPs are read and concatenated together into a single
6690 command. This command is then read and executed by the shell, and
6691 its exit status is returned as the value of
6695 or only null arguments,
6699 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
6702 is specified, it replaces the shell.
6703 No new process is created. The
6705 become the arguments to \fIcommand\fP.
6709 the shell places a dash at the beginning of the zeroth arg passed to
6717 to be executed with an empty environment. If
6719 is supplied, the shell passes
6721 as the zeroth argument to the executed command. If
6723 cannot be executed for some reason, a non-interactive shell exits,
6724 unless the shell option
6726 is enabled, in which case it returns failure.
6727 An interactive shell returns failure if the file cannot be executed.
6730 is not specified, any redirections take effect in the current shell,
6731 and the return status is 0. If there is a redirection error, the
6734 \fBexit\fP [\fIn\fP]
6735 Cause the shell to exit
6736 with a status of \fIn\fP. If
6738 is omitted, the exit status
6739 is that of the last command executed.
6743 is executed before the shell terminates.
6745 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
6752 are marked for automatic export to the environment of
6753 subsequently executed commands. If the
6761 are given, or if the
6763 option is supplied, a list
6764 of all names that are exported in this shell is printed.
6767 option causes the export property to be removed from each
6769 If a variable name is followed by =\fIword\fP, the value of
6770 the variable is set to \fIword\fP.
6772 returns an exit status of 0 unless an invalid option is
6774 one of the \fInames\fP is not a valid shell variable name, or
6778 that is not a function.
6780 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
6783 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
6785 Fix Command. In the first form, a range of commands from
6789 is selected from the history list.
6793 may be specified as a string (to locate the last command beginning
6794 with that string) or as a number (an index into the history list,
6795 where a negative number is used as an offset from the current
6798 is not specified it is set to
6799 the current command for listing (so that
6800 .if n ``fc \-l \-10''
6801 .if t \f(CWfc \-l \-10\fP
6802 prints the last 10 commands) and to
6807 is not specified it is set to the previous
6808 command for editing and \-16 for listing.
6813 the command numbers when listing. The
6815 option reverses the order of
6816 the commands. If the
6819 the commands are listed on
6820 standard output. Otherwise, the editor given by
6823 on a file containing those commands. If
6829 variable is used, and
6836 is not set. If neither variable is set,
6838 is used. When editing is complete, the edited commands are
6839 echoed and executed.
6841 In the second form, \fIcommand\fP is re-executed after each instance
6842 of \fIpat\fP is replaced by \fIrep\fP.
6843 A useful alias to use with this is
6844 .if n ``r="fc -s"'',
6845 .if t \f(CWr='fc \-s'\fP,
6849 runs the last command beginning with
6855 re-executes the last command.
6857 If the first form is used, the return value is 0 unless an invalid
6858 option is encountered or
6862 specify history lines out of range.
6865 option is supplied, the return value is the value of the last
6866 command executed or failure if an error occurs with the temporary
6867 file of commands. If the second form is used, the return status
6868 is that of the command re-executed, unless
6870 does not specify a valid history line, in which case
6874 \fBfg\fP [\fIjobspec\fP]
6877 in the foreground, and make it the current job.
6880 is not present, the shell's notion of the \fIcurrent job\fP is used.
6881 The return value is that of the command placed into the foreground,
6882 or failure if run when job control is disabled or, when run with
6883 job control enabled, if
6885 does not specify a valid job or
6887 specifies a job that was started without job control.
6889 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
6891 is used by shell procedures to parse positional parameters.
6893 contains the option characters to be recognized; if a character
6894 is followed by a colon, the option is expected to have an
6895 argument, which should be separated from it by white space.
6896 The colon and question mark characters may not be used as
6898 Each time it is invoked,
6900 places the next option in the shell variable
6904 if it does not exist,
6905 and the index of the next argument to be processed into the
6911 is initialized to 1 each time the shell or a shell script
6912 is invoked. When an option requires an argument,
6914 places that argument into the variable
6917 The shell does not reset
6920 automatically; it must be manually reset between multiple
6923 within the same shell invocation if a new set of parameters
6926 When the end of options is encountered, \fBgetopts\fP exits with a
6927 return value greater than zero.
6928 \fBOPTIND\fP is set to the index of the first non-option argument,
6929 and \fBname\fP is set to ?.
6932 normally parses the positional parameters, but if more arguments are
6936 parses those instead.
6939 can report errors in two ways. If the first character of
6943 error reporting is used. In normal operation diagnostic messages
6944 are printed when invalid options or missing option arguments are
6949 is set to 0, no error messages will be displayed, even if the first
6954 If an invalid option is seen,
6959 prints an error message and unsets
6965 the option character found is placed in
6968 and no diagnostic message is printed.
6970 If a required argument is not found, and
6973 a question mark (\^\fB?\fP\^) is placed in
6977 is unset, and a diagnostic message is printed.
6980 is silent, then a colon (\^\fB:\fP\^) is placed in
6985 is set to the option character found.
6988 returns true if an option, specified or unspecified, is found.
6989 It returns false if the end of options is encountered or an
6992 \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
6995 the full file name of the command is determined by searching
7001 option is supplied, no path search is performed, and
7003 is used as the full file name of the command.
7006 option causes the shell to forget all
7007 remembered locations.
7010 option causes the shell to forget the remembered location of each \fIname\fP.
7013 option is supplied, the full pathname to which each \fIname\fP corresponds
7014 is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
7015 the \fIname\fP is printed before the hashed full pathname.
7018 option causes output to be displayed in a format that may be reused as input.
7019 If no arguments are given, or if only \fB\-l\fP is supplied,
7020 information about remembered commands is printed.
7021 The return status is true unless a
7023 is not found or an invalid option is supplied.
7025 \fBhelp\fP [\fB\-s\fP] [\fIpattern\fP]
7026 Display helpful information about builtin commands. If
7030 gives detailed help on all commands matching
7032 otherwise help for all the builtins and shell control structures
7034 The \fB\-s\fP option restricts the information displayed to a short
7036 The return status is 0 unless no command matches
7039 \fBhistory [\fIn\fP]
7042 \fBhistory\fP \fB\-c\fP
7044 \fBhistory \-d\fP \fIoffset\fP
7046 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
7048 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
7050 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
7052 With no options, display the command
7053 history list with line numbers. Lines listed
7056 have been modified. An argument of
7061 If the shell variable \fBHISTTIMEFORMAT\fP is set and not null,
7062 it is used as a format string for \fIstrftime\fP(3) to display
7063 the time stamp associated with each displayed history entry.
7064 No intervening blank is printed between the formatted time stamp
7065 and the history line.
7066 If \fIfilename\fP is supplied, it is used as the
7067 name of the history file; if not, the value of
7070 is used. Options, if supplied, have the following meanings:
7075 Clear the history list by deleting all the entries.
7077 \fB\-d\fP \fIoffset\fP
7078 Delete the history entry at position \fIoffset\fP.
7081 Append the ``new'' history lines (history lines entered since the
7082 beginning of the current \fBbash\fP session) to the history file.
7085 Read the history lines not already read from the history
7086 file into the current history list. These are lines
7087 appended to the history file since the beginning of the
7088 current \fBbash\fP session.
7091 Read the contents of the history file
7092 and use them as the current history.
7095 Write the current history to the history file, overwriting the
7096 history file's contents.
7099 Perform history substitution on the following \fIargs\fP and display
7100 the result on the standard output.
7101 Does not store the results in the history list.
7102 Each \fIarg\fP must be quoted to disable normal history expansion.
7107 in the history list as a single entry. The last command in the
7108 history list is removed before the
7113 If the \fBHISTTIMEFORMAT\fP is set, the time stamp information
7114 associated with each history entry is written to the history file.
7115 The return value is 0 unless an invalid option is encountered, an
7116 error occurs while reading or writing the history file, an invalid
7117 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
7118 history expansion supplied as an argument to \fB\-p\fP fails.
7121 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
7124 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
7126 The first form lists the active jobs. The options have the following
7133 in addition to the normal information.
7136 List only the process ID of the job's process group
7140 Display information only about jobs that have changed status since
7141 the user was last notified of their status.
7144 Restrict output to running jobs.
7147 Restrict output to stopped jobs.
7152 is given, output is restricted to information about that job.
7153 The return status is 0 unless an invalid option is encountered
7168 with the corresponding process group ID, and executes
7172 returning its exit status.
7175 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
7178 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
7180 Send the signal named by
7184 to the processes named by
7189 is either a case-insensitive signal name such as
7192 (with or without the
7195 prefix) or a signal number;
7200 is not present, then
7206 lists the signal names.
7207 If any arguments are supplied when
7209 is given, the names of the signals corresponding to the arguments are
7210 listed, and the return status is 0.
7211 The \fIexit_status\fP argument to
7213 is a number specifying either a signal number or the exit status of
7214 a process terminated by a signal.
7216 returns true if at least one signal was successfully sent, or false
7217 if an error occurs or an invalid option is encountered.
7219 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
7222 is an arithmetic expression to be evaluated (see
7224 .BR "ARITHMETIC EVALUATION" ).
7229 returns 1; 0 is returned otherwise.
7231 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
7232 For each argument, a local variable named
7234 is created, and assigned
7236 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
7239 is used within a function, it causes the variable
7241 to have a visible scope restricted to that function and its children.
7244 writes a list of local variables to the standard output. It is
7247 when not within a function. The return status is 0 unless
7249 is used outside a function, an invalid
7252 \fIname\fP is a readonly variable.
7257 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
7258 Removes entries from the directory stack. With no arguments,
7259 removes the top directory from the stack, and performs a
7261 to the new top directory.
7262 Arguments, if supplied, have the following meanings:
7267 Removes the \fIn\fPth entry counting from the left of the list
7270 starting with zero. For example:
7272 .if t \f(CWpopd +0\fP
7273 removes the first directory,
7275 .if t \f(CWpopd +1\fP
7279 Removes the \fIn\fPth entry counting from the right of the list
7282 starting with zero. For example:
7284 .if t \f(CWpopd -0\fP
7285 removes the last directory,
7287 .if t \f(CWpopd -1\fP
7291 Suppresses the normal change of directory when removing directories
7292 from the stack, so that only the stack is manipulated.
7297 command is successful, a
7299 is performed as well, and the return status is 0.
7301 returns false if an invalid option is encountered, the directory stack
7302 is empty, a non-existent directory stack entry is specified, or the
7303 directory change fails.
7306 \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
7307 Write the formatted \fIarguments\fP to the standard output under the
7308 control of the \fIformat\fP.
7309 The \fIformat\fP is a character string which contains three types of objects:
7310 plain characters, which are simply copied to standard output, character
7311 escape sequences, which are converted and copied to the standard output, and
7312 format specifications, each of which causes printing of the next successive
7314 In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
7315 \fBprintf\fP to expand backslash escape sequences in the corresponding
7316 \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in
7317 \fB\e'\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes
7318 beginning with \fB\e0\fP may contain up to four digits),
7319 and \fB%q\fP causes \fBprintf\fP to output the corresponding
7320 \fIargument\fP in a format that can be reused as shell input.
7322 The \fB\-v\fP option causes the output to be assigned to the variable
7323 \fIvar\fP rather than being printed to the standard output.
7325 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
7326 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
7327 extra format specifications behave as if a zero value or null string, as
7328 appropriate, had been supplied. The return value is zero on success,
7329 non-zero on failure.
7331 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
7334 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
7336 Adds a directory to the top of the directory stack, or rotates
7337 the stack, making the new top of the stack the current working
7338 directory. With no arguments, exchanges the top two directories
7339 and returns 0, unless the directory stack is empty.
7340 Arguments, if supplied, have the following meanings:
7345 Rotates the stack so that the \fIn\fPth directory
7346 (counting from the left of the list shown by
7352 Rotates the stack so that the \fIn\fPth directory
7353 (counting from the right of the list shown by
7355 starting with zero) is at the top.
7358 Suppresses the normal change of directory when adding directories
7359 to the stack, so that only the stack is manipulated.
7364 to the directory stack at the top, making it the
7365 new current working directory.
7370 command is successful, a
7372 is performed as well.
7373 If the first form is used,
7375 returns 0 unless the cd to
7377 fails. With the second form,
7379 returns 0 unless the directory stack is empty,
7380 a non-existent directory stack element is specified,
7381 or the directory change to the specified new current directory
7385 \fBpwd\fP [\fB\-LP\fP]
7386 Print the absolute pathname of the current working directory.
7387 The pathname printed contains no symbolic links if the
7389 option is supplied or the
7393 builtin command is enabled.
7396 option is used, the pathname printed may contain symbolic links.
7397 The return status is 0 unless an error occurs while
7398 reading the name of the current directory or an
7399 invalid option is supplied.
7401 \fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
7402 One line is read from the standard input, or from the file descriptor
7403 \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
7404 is assigned to the first
7406 the second word to the second
7408 and so on, with leftover words and their intervening separators assigned
7411 If there are fewer words read from the input stream than names,
7412 the remaining names are assigned empty values.
7416 are used to split the line into words.
7417 The backslash character (\fB\e\fP) may be used to remove any special
7418 meaning for the next character read and for line continuation.
7419 Options, if supplied, have the following meanings:
7424 The words are assigned to sequential indices
7425 of the array variable
7429 is unset before any new values are assigned.
7430 Other \fIname\fP arguments are ignored.
7433 The first character of \fIdelim\fP is used to terminate the input line,
7434 rather than newline.
7437 If the standard input
7438 is coming from a terminal,
7443 above) is used to obtain the line.
7446 \fBread\fP returns after reading \fInchars\fP characters rather than
7447 waiting for a complete line of input.
7450 Display \fIprompt\fP on standard error, without a
7451 trailing newline, before attempting to read any input. The prompt
7452 is displayed only if input is coming from a terminal.
7455 Backslash does not act as an escape character.
7456 The backslash is considered to be part of the line.
7457 In particular, a backslash-newline pair may not be used as a line
7461 Silent mode. If input is coming from a terminal, characters are
7464 .B \-t \fItimeout\fP
7465 Cause \fBread\fP to time out and return failure if a complete line of
7466 input is not read within \fItimeout\fP seconds.
7467 This option has no effect if \fBread\fP is not reading input from the
7471 Read input from file descriptor \fIfd\fP.
7476 are supplied, the line read is assigned to the variable
7479 The return code is zero, unless end-of-file is encountered, \fBread\fP
7480 times out, or an invalid file descriptor is supplied as the argument to
7484 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP[=\fIword\fP] ...]
7487 \fInames\fP are marked readonly; the values of these
7489 may not be changed by subsequent assignment.
7492 option is supplied, the functions corresponding to the
7497 option restricts the variables to arrays.
7500 arguments are given, or if the
7502 option is supplied, a list of all readonly names is printed.
7505 option causes output to be displayed in a format that
7506 may be reused as input.
7507 If a variable name is followed by =\fIword\fP, the value of
7508 the variable is set to \fIword\fP.
7509 The return status is 0 unless an invalid option is encountered,
7512 is not a valid shell variable name, or
7516 that is not a function.
7518 \fBreturn\fP [\fIn\fP]
7519 Causes a function to exit with the return value specified by
7523 is omitted, the return status is that of the last command
7524 executed in the function body. If used outside a function,
7525 but during execution of a script by the
7527 (\fBsource\fP) command, it causes the shell to stop executing
7528 that script and return either
7530 or the exit status of the last command executed within the
7531 script as the exit status of the script. If used outside a
7532 function and not during execution of a script by \fB.\fP\^,
7533 the return status is false.
7534 Any command associated with the \fBRETURN\fP trap is executed
7535 before execution resumes after the function or script.
7537 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
7538 Without options, the name and value of each shell variable are displayed
7539 in a format that can be reused as input
7540 for setting or resetting the currently-set variables.
7541 Read-only variables cannot be reset.
7542 In \fIposix mode\fP, only shell variables are listed.
7543 The output is sorted according to the current locale.
7544 When options are specified, they set or unset shell attributes.
7545 Any arguments remaining after the options are processed are treated
7546 as values for the positional parameters and are assigned, in order, to
7551 Options, if specified, have the following meanings:
7556 Automatically mark variables and functions which are modified or
7557 created for export to the environment of subsequent commands.
7560 Report the status of terminated background jobs
7561 immediately, rather than before the next primary prompt. This is
7562 effective only when job control is enabled.
7565 Exit immediately if a \fIsimple command\fP (see
7568 above) exits with a non-zero status.
7569 The shell does not exit if the
7570 command that fails is part of the command list immediately following a
7575 part of the test in an
7577 statement, part of a
7581 list, or if the command's return value is
7584 A trap on \fBERR\fP, if set, is executed before the shell exits.
7587 Disable pathname expansion.
7590 Remember the location of commands as they are looked up for execution.
7591 This is enabled by default.
7594 All arguments in the form of assignment statements
7595 are placed in the environment for a command, not just
7596 those that precede the command name.
7599 Monitor mode. Job control is enabled. This option is on
7600 by default for interactive shells on systems that support
7604 above). Background processes run in a separate process
7605 group and a line containing their exit status is printed
7606 upon their completion.
7609 Read commands but do not execute them. This may be used to
7610 check a shell script for syntax errors. This is ignored by
7613 .B \-o \fIoption\-name\fP
7614 The \fIoption\-name\fP can be one of the following:
7626 Use an emacs-style command line editing interface. This is enabled
7627 by default when the shell is interactive, unless the shell is started
7653 Enable command history, as described above under
7656 This option is on by default in interactive shells.
7659 The effect is as if the shell command
7660 .if t \f(CWIGNOREEOF=10\fP
7661 .if n ``IGNOREEOF=10''
7706 If set, the return value of a pipeline is the value of the last
7707 (rightmost) command to exit with a non-zero status, or zero if all
7708 commands in the pipeline exit successfully.
7709 This option is disabled by default.
7712 Change the behavior of
7714 where the default operation differs
7715 from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
7726 Use a vi-style command line editing interface.
7735 is supplied with no \fIoption\-name\fP, the values of the current options are
7739 is supplied with no \fIoption\-name\fP, a series of
7741 commands to recreate the current option settings is displayed on
7742 the standard output.
7748 mode. In this mode, the
7754 files are not processed, shell functions are not inherited from the
7755 environment, and the
7758 variable, if it appears in the environment, is ignored.
7759 If the shell is started with the effective user (group) id not equal to the
7760 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
7761 are taken and the effective user id is set to the real user id.
7762 If the \fB\-p\fP option is supplied at startup, the effective user id is
7764 Turning this option off causes the effective user
7765 and group ids to be set to the real user and group ids.
7768 Exit after reading and executing one command.
7771 Treat unset variables as an error when performing
7772 parameter expansion. If expansion is attempted on an
7773 unset variable, the shell prints an error message, and,
7774 if not interactive, exits with a non-zero status.
7777 Print shell input lines as they are read.
7780 After expanding each \fIsimple command\fP,
7781 \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
7782 arithmetic \fBfor\fP command, display the expanded value of
7785 followed by the command and its expanded arguments
7786 or associated word list.
7789 The shell performs brace expansion (see
7791 above). This is on by default.
7796 does not overwrite an existing file with the
7801 redirection operators. This may be overridden when
7802 creating output files by using the redirection operator
7808 If set, any trap on \fBERR\fP is inherited by shell functions, command
7809 substitutions, and commands executed in a subshell environment.
7810 The \fBERR\fP trap is normally not inherited in such cases.
7815 style history substitution. This option is on by
7816 default when the shell is interactive.
7819 If set, the shell does not follow symbolic links when executing
7822 that change the current working directory. It uses the
7823 physical directory structure instead. By default,
7825 follows the logical chain of directories when performing commands
7826 which change the current directory.
7829 If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
7830 functions, command substitutions, and commands executed in a
7831 subshell environment.
7832 The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
7836 If no arguments follow this option, then the positional parameters are
7837 unset. Otherwise, the positional parameters are set to the
7838 \fIarg\fPs, even if some of them begin with a
7842 Signal the end of options, cause all remaining \fIarg\fPs to be
7843 assigned to the positional parameters. The
7847 options are turned off.
7848 If there are no \fIarg\fPs,
7849 the positional parameters remain unchanged.
7852 The options are off by default unless otherwise noted.
7853 Using + rather than \- causes these options to be turned off.
7854 The options can also be specified as arguments to an invocation of
7856 The current set of options may be found in
7858 The return status is always true unless an invalid option is encountered.
7861 \fBshift\fP [\fIn\fP]
7862 The positional parameters from \fIn\fP+1 ... are renamed to
7865 Parameters represented by the numbers \fB$#\fP
7866 down to \fB$#\fP\-\fIn\fP+1 are unset.
7868 must be a non-negative number less than or equal to \fB$#\fP.
7871 is 0, no parameters are changed.
7874 is not given, it is assumed to be 1.
7877 is greater than \fB$#\fP, the positional parameters are not changed.
7878 The return status is greater than zero if
7882 or less than zero; otherwise 0.
7884 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
7885 Toggle the values of variables controlling optional shell behavior.
7886 With no options, or with the
7888 option, a list of all settable options is displayed, with
7889 an indication of whether or not each is set.
7890 The \fB\-p\fP option causes output to be displayed in a form that
7891 may be reused as input.
7892 Other options have the following meanings:
7897 Enable (set) each \fIoptname\fP.
7900 Disable (unset) each \fIoptname\fP.
7903 Suppresses normal output (quiet mode); the return status indicates
7904 whether the \fIoptname\fP is set or unset.
7905 If multiple \fIoptname\fP arguments are given with
7907 the return status is zero if all \fIoptnames\fP are enabled; non-zero
7911 Restricts the values of \fIoptname\fP to be those defined for the
7922 is used with no \fIoptname\fP arguments, the display is limited to
7923 those options which are set or unset, respectively.
7924 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
7927 The return status when listing options is zero if all \fIoptnames\fP
7928 are enabled, non-zero otherwise. When setting or unsetting options,
7929 the return status is zero unless an \fIoptname\fP is not a valid shell
7932 The list of \fBshopt\fP options is:
7938 If set, an argument to the
7940 builtin command that
7941 is not a directory is assumed to be the name of a variable whose
7942 value is the directory to change to.
7945 If set, minor errors in the spelling of a directory component in a
7947 command will be corrected.
7948 The errors checked for are transposed characters,
7949 a missing character, and one character too many.
7950 If a correction is found, the corrected file name is printed,
7951 and the command proceeds.
7952 This option is only used by interactive shells.
7955 If set, \fBbash\fP checks that a command found in the hash
7956 table exists before trying to execute it. If a hashed command no
7957 longer exists, a normal path search is performed.
7960 If set, \fBbash\fP checks the window size after each command
7961 and, if necessary, updates the values of
7971 attempts to save all lines of a multiple-line
7972 command in the same history entry. This allows
7973 easy re-editing of multi-line commands.
7978 includes filenames beginning with a `.' in the results of pathname
7982 If set, a non-interactive shell will not exit if
7983 it cannot execute the file specified as an argument to the
7985 builtin command. An interactive shell does not exit if
7990 If set, aliases are expanded as described above under
7993 This option is enabled by default for interactive shells.
7996 If set, behavior intended for use by debuggers is enabled:
8000 The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
8001 file name and line number corresponding to each function name supplied
8005 If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
8006 next command is skipped and not executed.
8009 If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
8010 shell is executing in a subroutine (a shell function or a shell script
8011 executed by the \fB.\fP or \fBsource\fP builtins), a call to
8012 \fBreturn\fP is simulated.
8015 \fBBASH_ARGC\fP and \fBBASH_ARGV\fP are updated as described in their
8019 Function tracing is enabled: command substitution, shell functions, and
8020 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8021 \fBDEBUG\fP and \fBRETURN\fP traps.
8024 Error tracing is enabled: command substitution, shell functions, and
8025 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8030 If set, the extended pattern matching features described above under
8031 \fBPathname Expansion\fP are enabled.
8034 If set, \fB$\fP'\fIstring\fP' and \fB$\fP"\fIstring\fP" quoting is
8035 performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
8036 enclosed in double quotes. This option is enabled by default.
8039 If set, patterns which fail to match filenames during pathname expansion
8040 result in an expansion error.
8043 If set, the suffixes specified by the \fBFIGNORE\fP shell variable
8044 cause words to be ignored when performing word completion even if
8045 the ignored words are the only possible completions.
8048 \fBSHELL VARIABLES\fP
8049 above for a description of \fBFIGNORE\fP.
8050 This option is enabled by default.
8053 If set, shell error messages are written in the standard GNU error
8057 If set, the history list is appended to the file named by the value
8060 variable when the shell exits, rather than overwriting the file.
8065 is being used, a user is given the opportunity to re-edit a
8066 failed history substitution.
8071 is being used, the results of history substitution are not immediately
8072 passed to the shell parser. Instead, the resulting line is loaded into
8073 the \fBreadline\fP editing buffer, allowing further modification.
8078 is being used, \fBbash\fP will attempt to perform hostname completion when a
8079 word containing a \fB@\fP is being completed (see
8085 This is enabled by default.
8088 If set, \fBbash\fP will send
8091 to all jobs when an interactive login shell exits.
8093 .B interactive_comments
8094 If set, allow a word beginning with
8096 to cause that word and all remaining characters on that
8097 line to be ignored in an interactive shell (see
8100 above). This option is enabled by default.
8105 option is enabled, multi-line commands are saved to the history with
8106 embedded newlines rather than using semicolon separators where possible.
8109 The shell sets this option if it is started as a login shell (see
8113 The value may not be changed.
8116 If set, and a file that \fBbash\fP is checking for mail has been
8117 accessed since the last time it was checked, the message ``The mail in
8118 \fImailfile\fP has been read'' is displayed.
8120 .B no_empty_cmd_completion
8125 will not attempt to search the \fBPATH\fP for possible completions when
8126 completion is attempted on an empty line.
8131 matches filenames in a case\-insensitive fashion when performing pathname
8133 .B Pathname Expansion
8139 matches patterns in a case\-insensitive fashion when performing matching
8140 while executing \fBcase\fP or \fB[[\fP conditional commands.
8145 allows patterns which match no
8147 .B Pathname Expansion
8149 to expand to a null string, rather than themselves.
8152 If set, the programmable completion facilities (see
8153 \fBProgrammable Completion\fP above) are enabled.
8154 This option is enabled by default.
8157 If set, prompt strings undergo
8158 parameter expansion, command substitution, arithmetic
8159 expansion, and quote removal after being expanded as described in
8162 above. This option is enabled by default.
8165 The shell sets this option if it is started in restricted mode (see
8167 .B "RESTRICTED SHELL"
8169 The value may not be changed.
8170 This is not reset when the startup files are executed, allowing
8171 the startup files to discover whether or not a shell is restricted.
8176 builtin prints an error message when the shift count exceeds the
8177 number of positional parameters.
8181 \fBsource\fP (\fB.\fP) builtin uses the value of
8184 to find the directory containing the file supplied as an argument.
8185 This option is enabled by default.
8188 If set, the \fBecho\fP builtin expands backslash-escape sequences
8192 \fBsuspend\fP [\fB\-f\fP]
8193 Suspend the execution of this shell until it receives a
8198 option says not to complain if this is
8199 a login shell; just suspend anyway. The return status is 0 unless
8200 the shell is a login shell and
8202 is not supplied, or if job control is not enabled.
8204 \fBtest\fP \fIexpr\fP
8207 \fB[\fP \fIexpr\fP \fB]\fP
8208 Return a status of 0 or 1 depending on
8209 the evaluation of the conditional expression
8211 Each operator and operand must be a separate argument.
8212 Expressions are composed of the primaries described above under
8214 .BR "CONDITIONAL EXPRESSIONS" .
8215 \fBtest\fP does not accept any options, nor does it accept and ignore
8216 an argument of \fB\-\-\fP as signifying the end of options.
8219 Expressions may be combined using the following operators, listed
8220 in decreasing order of precedence.
8230 Returns the value of \fIexpr\fP.
8231 This may be used to override the normal precedence of operators.
8233 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
8240 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
8248 \fBtest\fP and \fB[\fP evaluate conditional
8249 expressions using a set of rules based on the number of arguments.
8255 The expression is false.
8258 The expression is true if and only if the argument is not null.
8261 If the first argument is \fB!\fP, the expression is true if and
8262 only if the second argument is null.
8263 If the first argument is one of the unary conditional operators listed above
8266 .BR "CONDITIONAL EXPRESSIONS" ,
8267 the expression is true if the unary test is true.
8268 If the first argument is not a valid unary conditional operator, the expression
8272 If the second argument is one of the binary conditional operators listed above
8275 .BR "CONDITIONAL EXPRESSIONS" ,
8276 the result of the expression is the result of the binary test using
8277 the first and third arguments as operands.
8278 If the first argument is \fB!\fP, the value is the negation of
8279 the two-argument test using the second and third arguments.
8280 If the first argument is exactly \fB(\fP and the third argument is
8281 exactly \fB)\fP, the result is the one-argument test of the second
8283 Otherwise, the expression is false.
8284 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
8288 If the first argument is \fB!\fP, the result is the negation of
8289 the three-argument expression composed of the remaining arguments.
8290 Otherwise, the expression is parsed and evaluated according to
8291 precedence using the rules listed above.
8294 The expression is parsed and evaluated according to precedence
8295 using the rules listed above.
8300 Print the accumulated user and system times for the shell and
8301 for processes run from the shell. The return status is 0.
8303 \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
8306 is to be read and executed when the shell receives
8311 is absent (and there is a single \fIsigspec\fP) or
8313 each specified signal is
8314 reset to its original disposition (the value it had
8315 upon entrance to the shell).
8318 is the null string the signal specified by each
8320 is ignored by the shell and by the commands it invokes.
8325 has been supplied, then the trap commands associated with each
8328 If no arguments are supplied or if only
8332 prints the list of commands associated with each signal.
8335 option causes the shell to print a list of signal names and
8336 their corresponding numbers.
8340 a signal name defined in <\fIsignal.h\fP>, or a signal number.
8341 Signal names are case insensitive and the SIG prefix is optional.
8349 is executed on exit from the shell.
8357 is executed before every \fIsimple command\fP, \fIfor\fP command,
8358 \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
8359 command, and before the first command executes in a shell function (see
8363 Refer to the description of the \fBextdebug\fP option to the
8364 \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
8372 is executed whenever a simple command has a non\-zero exit status,
8373 subject to the following conditions.
8377 trap is not executed if the failed
8378 command is part of the command list immediately following a
8383 part of the test in an
8385 statement, part of a
8389 list, or if the command's return value is
8392 These are the same conditions obeyed by the \fBerrexit\fP option.
8400 is executed each time a shell function or a script executed with the
8401 \fB.\fP or \fBsource\fP builtins finishes executing.
8402 Signals ignored upon entry to the shell cannot be trapped or reset.
8403 Trapped signals are reset to their original values in a child
8404 process when it is created.
8405 The return status is false if any
8407 is invalid; otherwise
8411 \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
8415 would be interpreted if used as a command name.
8420 prints a string which is one of
8429 is an alias, shell reserved word, function, builtin, or disk file,
8433 is not found, then nothing is printed, and an exit status of false
8439 either returns the name of the disk file
8440 that would be executed if
8442 were specified as a command name,
8444 .if t \f(CWtype -t name\fP
8445 .if n ``type -t name''
8453 search for each \fIname\fP, even if
8454 .if t \f(CWtype -t name\fP
8455 .if n ``type -t name''
8458 If a command is hashed,
8462 print the hashed value, not necessarily the file that appears
8470 prints all of the places that contain
8473 This includes aliases and functions,
8476 option is not also used.
8477 The table of hashed commands is not consulted
8482 option suppresses shell function lookup, as with the \fBcommand\fP builtin.
8484 returns true if any of the arguments are found, false if
8487 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
8488 Provides control over the resources available to the shell and to
8489 processes started by it, on systems that allow such control.
8490 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
8491 set for the given resource. A hard limit cannot be increased once it
8492 is set; a soft limit may be increased up to the value of the hard limit.
8493 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
8497 can be a number in the unit specified for the resource
8498 or one of the special values
8503 which stand for the current hard limit, the current soft limit, and
8504 no limit, respectively.
8507 is omitted, the current value of the soft limit of the resource is
8508 printed, unless the \fB\-H\fP option is given. When more than one
8509 resource is specified, the limit name and unit are printed before the value.
8510 Other options are interpreted as follows:
8515 All current limits are reported
8518 The maximum size of core files created
8521 The maximum size of a process's data segment
8524 The maximum size of files created by the shell
8527 The maximum size that may be locked into memory
8530 The maximum resident set size
8533 The maximum number of open file descriptors (most systems do not
8534 allow this value to be set)
8537 The pipe size in 512-byte blocks (this may not be set)
8540 The maximum stack size
8543 The maximum amount of cpu time in seconds
8546 The maximum number of processes available to a single user
8549 The maximum amount of virtual memory available to the shell
8554 is given, it is the new value of the specified resource (the
8556 option is display only).
8557 If no option is given, then
8559 is assumed. Values are in 1024-byte increments, except for
8561 which is in seconds,
8563 which is in units of 512-byte blocks,
8568 which are unscaled values.
8569 The return status is 0 unless an invalid option or argument is supplied,
8570 or an error occurs while setting a new limit.
8573 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
8574 The user file-creation mask is set to
8578 begins with a digit, it
8579 is interpreted as an octal number; otherwise
8580 it is interpreted as a symbolic mode mask similar
8585 is omitted, the current value of the mask is printed.
8588 option causes the mask to be printed in symbolic form; the
8589 default output is an octal number.
8592 option is supplied, and
8594 is omitted, the output is in a form that may be reused as input.
8595 The return status is 0 if the mode was successfully changed or if
8596 no \fImode\fP argument was supplied, and false otherwise.
8598 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
8599 Remove each \fIname\fP from the list of defined aliases. If
8601 is supplied, all alias definitions are removed. The return
8602 value is true unless a supplied
8604 is not a defined alias.
8606 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
8609 remove the corresponding variable or function.
8610 If no options are supplied, or the
8612 option is given, each
8614 refers to a shell variable.
8615 Read-only variables may not be unset.
8620 refers to a shell function, and the function definition
8622 Each unset variable or function is removed from the environment
8623 passed to subsequent commands.
8640 are unset, they lose their special properties, even if they are
8641 subsequently reset. The exit status is true unless a
8645 \fBwait\fP [\fIn ...\fP]
8646 Wait for each specified process and return its termination status.
8650 ID or a job specification; if a job spec is given, all processes
8651 in that job's pipeline are waited for. If
8653 is not given, all currently active child processes
8654 are waited for, and the return status is zero. If
8656 specifies a non-existent process or job, the return status is
8657 127. Otherwise, the return status is the exit status of the last
8658 process or job waited for.
8661 .SH "RESTRICTED SHELL"
8667 is started with the name
8671 option is supplied at invocation,
8672 the shell becomes restricted.
8673 A restricted shell is used to
8674 set up an environment more controlled than the standard shell.
8675 It behaves identically to
8677 with the exception that the following are disallowed or not performed:
8679 changing directories with \fBcd\fP
8681 setting or unsetting the values of
8688 specifying command names containing
8691 specifying a file name containing a
8693 as an argument to the
8697 Specifying a filename containing a slash as an argument to the
8703 importing function definitions from the shell environment at startup
8705 parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
8707 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
8711 builtin command to replace the shell with another command
8713 adding or deleting builtin commands with the
8721 Using the \fBenable\fP builtin command to enable disabled shell builtins
8729 turning off restricted mode with
8730 \fBset +r\fP or \fBset +o restricted\fP.
8732 These restrictions are enforced after any startup files are read.
8734 .ie \n(zY=1 When a command that is found to be a shell script is executed,
8735 .el \{ When a command that is found to be a shell script is executed
8738 .B "COMMAND EXECUTION"
8742 turns off any restrictions in the shell spawned to execute the
8749 \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
8751 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
8753 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
8755 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
8757 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
8759 \fIemacs\fP(1), \fIvi\fP(1)
8767 The \fBbash\fP executable
8770 The systemwide initialization file, executed for login shells
8773 The personal initialization file, executed for login shells
8776 The individual per-interactive-shell startup file
8779 The individual login shell cleanup file, executed when a login shell exits
8782 Individual \fIreadline\fP initialization file
8785 Brian Fox, Free Software Foundation
8789 Chet Ramey, Case Western Reserve University
8793 If you find a bug in
8795 you should report it. But first, you should
8796 make sure that it really is a bug, and that it appears in the latest
8799 The latest version is always available from
8800 \fIftp://ftp.gnu.org/pub/bash/\fP.
8802 Once you have determined that a bug actually exists, use the
8804 command to submit a bug report.
8805 If you have a fix, you are encouraged to mail that as well!
8806 Suggestions and `philosophical' bug reports may be mailed
8807 to \fIbug-bash@gnu.org\fP or posted to the Usenet
8811 ALL bug reports should include:
8815 The version number of \fBbash\fR
8817 The hardware and operating system
8819 The compiler used to compile
8821 A description of the bug behaviour
8823 A short script or `recipe' which exercises the bug
8827 inserts the first three items automatically into the template
8828 it provides for filing a bug report.
8830 Comments and bug reports concerning
8831 this manual page should be directed to
8832 .IR chet@po.cwru.edu .
8835 It's too big and too slow.
8837 There are some subtle differences between
8839 and traditional versions of
8841 mostly because of the
8846 Aliases are confusing in some uses.
8848 Shell builtin commands and functions are not stoppable/restartable.
8850 Compound commands and command sequences of the form `a ; b ; c'
8851 are not handled gracefully when process suspension is attempted.
8852 When a process is stopped, the shell immediately executes the next
8853 command in the sequence.
8854 It suffices to place the sequence of commands between
8855 parentheses to force it into a subshell, which may be stopped as
8858 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
8859 parsed until substitution is attempted. This will delay error
8860 reporting until some time after the command is entered. For example,
8861 unmatched parentheses, even inside shell comments, will result in
8862 error messages while the construct is being read.
8864 Array variables may not (yet) be exported.