2 <TITLE>BASH(
1) Manual Page
</TITLE>
4 <BODY><TABLE WIDTH=
100%
>
6 <TH ALIGN=LEFT width=
33%
>BASH(
1)
<TH ALIGN=CENTER width=
33%
>2022 September
19<TH ALIGN=RIGHT width=
33%
>BASH(
1)
9 <BR><A HREF=
"#index">Index
</A>
42 <A NAME=
"lbAB"> </A>
45 bash - GNU Bourne-Again SHell
46 <A NAME=
"lbAC"> </A>
52 [command_string | file]
53 <A NAME=
"lbAD"> </A>
57 Bash is Copyright
© 1989-
2022 by the Free Software Foundation, Inc.
58 <A NAME=
"lbAE"> </A>
63 is an
<B>sh
</B>-compatible command language interpreter that
64 executes commands read from the standard input or from a file.
67 also incorporates useful features from the
<I>Korn
</I> and
<I>C
</I>
68 shells (
<B>ksh
</B> and
<B>csh
</B>).
73 is intended to be a conformant implementation of the
74 Shell and Utilities portion of the IEEE POSIX specification
75 (IEEE Standard
1003.1).
78 can be configured to be POSIX-conformant by default.
79 <A NAME=
"lbAF"> </A>
82 All of the single-character shell options documented in the
83 description of the
<B>set
</B> builtin command, including
<B>-o
</B>,
84 can be used as options when the shell is invoked.
85 In addition,
<B>bash
</B>
86 interprets the following options when it is invoked:
97 option is present, then commands are read from the first non-option argument
98 <I>command_string
</I>.
100 If there are arguments after the
101 <I>command_string
</I>,
103 the first argument is assigned to
106 and any remaining arguments are assigned to the positional parameters.
110 sets the name of the shell, which is used in warning and error messages.
117 option is present, the shell is
126 act as if it had been invoked as a login shell (see
127 <FONT SIZE=-
1><B>INVOCATION
</B>
137 option is present, the shell becomes
141 <FONT SIZE=-
1><B>RESTRICTED SHELL
</B>
151 option is present, or if no arguments remain after option
152 processing, then commands are read from the standard input.
153 This option allows the positional parameters to be set
154 when invoking an interactive shell or when reading input
159 A list of all double-quoted strings preceded by
<B>$
</B>
160 is printed on the standard output.
161 These are the strings that
162 are subject to language translation when the current locale
163 is not
<B>C
</B> or
<B>POSIX
</B>.
164 This implies the
<B>-n
</B> option; no commands will be executed.
165 <DT><B>[-+]O [
</B><I>shopt_option
</I>]
168 <I>shopt_option
</I> is one of the shell options accepted by the
169 <B>shopt
</B> builtin (see
170 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
174 If
<I>shopt_option
</I> is present,
<B>-O
</B> sets the value of that option;
176 If
<I>shopt_option
</I> is not supplied, the names and values of the shell
177 options accepted by
<B>shopt
</B> are printed on the standard output.
178 If the invocation option is
<B>+O
</B>, the output is displayed in a format
179 that may be reused as input.
186 signals the end of options and disables further option processing.
187 Any arguments after the
190 are treated as filenames and arguments. An argument of
193 is equivalent to
<B>--
</B>.
200 also interprets a number of multi-character options.
201 These options must appear on the command line before the
202 single-character options to be recognized.
207 <DT><B>--debugger
</B>
210 Arrange for the debugger profile to be executed before the shell
212 Turns on extended debugging mode (see the description of the
219 <DT><B>--dump-po-strings
</B>
222 Equivalent to
<B>-D
</B>, but the output is in the GNU
<I>gettext
</I>
223 <B>po
</B> (portable object) file format.
224 <DT><B>--dump-strings
</B>
227 Equivalent to
<B>-D
</B>.
231 Display a usage message on standard output and exit successfully.
232 <DT><B>--init-file
</B> <I>file
</I><DD>
234 <DT><B>--rcfile
</B> <I>file
</I><DD>
236 Execute commands from
239 instead of the standard personal initialization file
240 <A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>
242 if the shell is interactive (see
243 <FONT SIZE=-
1><B>INVOCATION
</B>
250 Equivalent to
<B>-l
</B>.
251 <DT><B>--noediting
</B>
257 library to read command lines when the shell is interactive.
258 <DT><B>--noprofile
</B>
261 Do not read either the system-wide startup file
263 <A HREF=
"file:/etc/profile"><I>/etc/profile
</I></A>
265 or any of the personal initialization files
266 <A HREF=
"file:~/.bash_profile"><I>~/.bash_profile
</I></A>,
268 <A HREF=
"file:~/.bash_login"><I>~/.bash_login
</I></A>,
271 <A HREF=
"file:~/.profile"><I>~/.profile
</I></A>.
276 reads these files when it is invoked as a login shell (see
277 <FONT SIZE=-
1><B>INVOCATION
</B>
284 Do not read and execute the personal initialization file
285 <A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>
287 if the shell is interactive.
288 This option is on by default if the shell is invoked as
294 Change the behavior of
<B>bash
</B> where the default operation differs
295 from the POSIX standard to match the standard (
<I>posix mode
</I>).
297 <FONT SIZE=-
1><B>SEE ALSO
</B>
300 below for a reference to a document that details how posix mode affects
302 <DT><B>--restricted
</B>
305 The shell becomes restricted (see
306 <FONT SIZE=-
1><B>RESTRICTED SHELL
</B>
313 Equivalent to
<B>-v
</B>.
317 Show version information for this instance of
320 on the standard output and exit successfully.
323 <A NAME=
"lbAG"> </A>
326 If arguments remain after option processing, and neither the
332 option has been supplied, the first argument is assumed to
333 be the name of a file containing shell commands.
337 is invoked in this fashion,
340 is set to the name of the file, and the positional parameters
341 are set to the remaining arguments.
344 reads and executes commands from this file, then exits.
345 <B>Bash
</B>'s exit status is the exit status of the last command
346 executed in the script.
347 If no commands are executed, the exit status is
0.
348 An attempt is first made to open the file in the current directory, and,
349 if no file is found, then the shell searches the directories in
350 <FONT SIZE=-
1><B>PATH
</B>
354 <A NAME=
"lbAH"> </A>
357 A
<I>login shell
</I> is one whose first character of argument zero is a
360 or one started with the
366 An
<I>interactive
</I> shell is one started without non-option arguments
367 (unless
<B>-s
</B> is specified)
372 whose standard input and error are
373 both connected to terminals (as determined by
376 or one started with the
380 <FONT SIZE=-
1><B>PS1
</B>
393 allowing a shell script or a startup file to test this state.
396 The following paragraphs describe how
399 executes its startup files.
400 If any of the files exist but cannot be read,
404 Tildes are expanded in filenames as described below under
405 <B>Tilde Expansion
</B>
408 <FONT SIZE=-
1><B>EXPANSION
</B>
417 is invoked as an interactive login shell, or as a non-interactive shell
418 with the
<B>--login
</B> option, it first reads and
419 executes commands from the file
<A HREF=
"file:/etc/profile"><I>/etc/profile
</I></A>, if that
421 After reading that file, it looks for
<A HREF=
"file:~/.bash_profile"><I>~/.bash_profile
</I></A>,
422 <A HREF=
"file:~/.bash_login"><I>~/.bash_login
</I></A>, and
<A HREF=
"file:~/.profile"><I>~/.profile
</I></A>, in that order, and reads
423 and executes commands from the first one that exists and is readable.
427 option may be used when the shell is started to inhibit this behavior.
430 When an interactive login shell exits,
431 or a non-interactive login shell executes the
<B>exit
</B> builtin command,
434 reads and executes commands from the file
<A HREF=
"file:~/.bash_logout"><I>~/.bash_logout
</I></A>, if it
438 When an interactive shell that is not a login shell is started,
441 reads and executes commands from
<A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>, if that file exists.
442 This may be inhibited by using the
446 The
<B>--rcfile
</B> <I>file
</I> option will force
449 to read and execute commands from
<I>file
</I> instead of
<A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>.
455 is started non-interactively, to run a shell script, for example, it
456 looks for the variable
457 <FONT SIZE=-
1><B>BASH_ENV
</B>
460 in the environment, expands its value if it appears there, and uses the
461 expanded value as the name of a file to read and execute.
464 behaves as if the following command were executed:
467 <TT>if [ -n
"$BASH_ENV
" ]; then .
"$BASH_ENV
"; fi
</TT>
473 <FONT SIZE=-
1><B>PATH
</B>
476 variable is not used to search for the filename.
482 is invoked with the name
485 it tries to mimic the startup behavior of historical versions of
488 as closely as possible,
489 while conforming to the POSIX standard as well.
490 When invoked as an interactive login shell, or a non-interactive
491 shell with the
<B>--login
</B> option, it first attempts to
492 read and execute commands from
493 <A HREF=
"file:/etc/profile"><I>/etc/profile
</I></A>
496 <A HREF=
"file:~/.profile"><I>~/.profile
</I></A>,
502 option may be used to inhibit this behavior.
503 When invoked as an interactive shell with the name
508 looks for the variable
509 <FONT SIZE=-
1><B>ENV
</B>,
512 expands its value if it is defined, and uses the
513 expanded value as the name of a file to read and execute.
514 Since a shell invoked as
517 does not attempt to read and execute commands from any other startup
521 option has no effect.
522 A non-interactive shell invoked with the name
525 does not attempt to read any other startup files.
534 mode after the startup files are read.
546 command line option, it follows the POSIX standard for startup files.
547 In this mode, interactive shells expand the
548 <FONT SIZE=-
1><B>ENV
</B>
551 variable and commands are read and executed from the file
552 whose name is the expanded value.
553 No other startup files are read.
558 attempts to determine when it is being run with its standard input
559 connected to a network connection, as when executed by
560 the historical remote shell daemon, usually
<I>rshd
</I>,
561 or the secure shell daemon
<I>sshd
</I>.
565 determines it is being run non-interactively in this fashion,
566 it reads and executes commands from
<A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>,
567 if that file exists and is readable.
568 It will not do this if invoked as
<B>sh
</B>.
572 option may be used to inhibit this behavior, and the
575 option may be used to force another file to be read, but neither
576 <I>rshd
</I> nor
<I>sshd
</I> generally invoke the shell with those options
577 or allow them to be specified.
580 If the shell is started with the effective user (group) id not equal to the
581 real user (group) id, and the
<B>-p
</B> option is not supplied, no startup
582 files are read, shell functions are not inherited from the environment, the
583 <FONT SIZE=-
1><B>SHELLOPTS
</B>,
586 <FONT SIZE=-
1><B>BASHOPTS
</B>,
589 <FONT SIZE=-
1><B>CDPATH
</B>,
593 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
596 variables, if they appear in the environment, are ignored,
597 and the effective user id is set to the real user id.
598 If the
<B>-p
</B> option is supplied at invocation, the startup behavior is
599 the same, but the effective user id is not reset.
600 <A NAME=
"lbAI"> </A>
603 The following definitions are used throughout the rest of this
614 A sequence of characters considered as a single unit by the shell.
624 consisting only of alphanumeric characters and underscores, and
625 beginning with an alphabetic character or an underscore. Also
629 <DT><B>metacharacter
</B>
632 A character that, when unquoted, separates words. One of the following:
638 <B>|
& ; ( )
< > space tab newline
</B>
642 <DT><B>control operator
</B>
645 A
<I>token
</I> that performs a control function. It is one of the following
650 <B>||
& && ; ;; ;
& ;;
& ( ) | |
& <newline
></B>
656 <A NAME=
"lbAJ"> </A>
657 <H3>RESERVED WORDS
</H3>
659 <I>Reserved words
</I> are words that have a special meaning to the shell.
660 The following words are recognized as reserved when unquoted and either
661 the first word of a command (see
662 <FONT SIZE=-
1><B>SHELL GRAMMAR
</B>
665 below), the third word of a
672 (only
<B>in
</B> is valid), or the third word of a
675 command (only
<B>in
</B> and
<B>do
</B> are valid):
683 ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
687 <A NAME=
"lbAK"> </A>
688 <H3>SHELL GRAMMAR
</H3>
690 This section describes the syntax of the various forms of shell commands.
691 <A NAME=
"lbAL"> </A>
692 <H4>Simple Commands
</H4>
694 A
<I>simple command
</I> is a sequence of optional variable assignments
695 followed by
<B>blank
</B>-separated words and redirections, and
696 terminated by a
<I>control operator
</I>. The first word
697 specifies the command to be executed, and is passed as argument zero.
698 The remaining words are passed as arguments to the invoked command.
701 The return value of a
<I>simple command
</I> is its exit status, or
702 128+
<I>n
</I> if the command is terminated by signal
705 <A NAME=
"lbAM"> </A>
708 A
<I>pipeline
</I> is a sequence of one or more commands separated by
709 one of the control operators
713 The format for a pipeline is:
717 [
<B>time
</B> [
<B>-p
</B>]] [ ! ]
<I>command1
</I> [ [
<B>|
</B>|
<B>|
&</B>]
<I>command2
</I> ... ]
722 The standard output of
725 is connected via a pipe to the standard input of
728 This connection is performed before any redirections specified by the
731 <FONT SIZE=-
1><B>REDIRECTION
</B>
735 If
<B>|
&</B> is used,
<I>command1
</I>'s standard error, in addition to its
736 standard output, is connected to
737 <I>command2
</I>'s standard input through the pipe;
738 it is shorthand for
<B>2>&1 |
</B>.
739 This implicit redirection of the standard error to the standard output is
740 performed after any redirections specified by
<I>command1
</I>.
743 The return status of a pipeline is the exit status of the last
744 command, unless the
<B>pipefail
</B> option is enabled.
745 If
<B>pipefail
</B> is enabled, the pipeline's return status is the
746 value of the last (rightmost) command to exit with a non-zero status,
747 or zero if all commands exit successfully.
751 precedes a pipeline, the exit status of that pipeline is the logical
752 negation of the exit status as described above.
753 The shell waits for all commands in the pipeline to
754 terminate before returning a value.
760 reserved word precedes a pipeline, the elapsed as well as user and
761 system time consumed by its execution are reported when the pipeline
763 The
<B>-p
</B> option changes the output format to that specified by POSIX.
764 When the shell is in
<I>posix mode
</I>, it does not recognize
765 <B>time
</B> as a reserved word if the next token begins with a `-'.
767 <FONT SIZE=-
1><B>TIMEFORMAT
</B>
770 variable may be set to a format string that specifies how the timing
771 information should be displayed; see the description of
772 <FONT SIZE=-
1><B>TIMEFORMAT
</B>
776 <B>Shell Variables
</B>
781 When the shell is in
<I>posix mode
</I>,
<B>time
</B>
782 may be followed by a newline. In this case, the shell displays the
783 total user and system time consumed by the shell and its children.
785 <FONT SIZE=-
1><B>TIMEFORMAT
</B>
788 variable may be used to specify the format of
789 the time information.
792 Each command in a multi-command pipeline,
793 where pipes are created,
794 is executed in a
<I>subshell
</I>, which is a
797 <FONT SIZE=-
1><B>COMMAND EXECUTION ENVIRONMENT
</B></FONT>
798 for a description of subshells and a subshell environment.
799 If the
<B>lastpipe
</B> option is enabled using the
<B>shopt
</B> builtin
800 (see the description of
<B>shopt
</B> below),
801 the last element of a pipeline may be run by the shell process
802 when job control is not active.
803 <A NAME=
"lbAN"> </A>
806 A
<I>list
</I> is a sequence of one or more pipelines separated by one
817 and optionally terminated by one of
823 <B><newline
></B>.
827 Of these list operators,
833 have equal precedence, followed by
839 which have equal precedence.
842 A sequence of one or more newlines may appear in a
<I>list
</I> instead
843 of a semicolon to delimit commands.
846 If a command is terminated by the control operator
849 the shell executes the command in the
<I>background
</I>
851 The shell does not wait for the command to
852 finish, and the return status is
0.
853 These are referred to as
<I>asynchronous
</I> commands.
854 Commands separated by a
857 are executed sequentially; the shell waits for each
858 command to terminate in turn. The return status is the
859 exit status of the last command executed.
862 AND and OR lists are sequences of one or more pipelines separated by the
863 <B>&&</B> and
<B>||
</B> control operators, respectively.
864 AND and OR lists are executed with left associativity.
865 An AND list has the form
869 <I>command1
</I> <B>&&</B> <I>command2
</I>
876 is executed if, and only if,
879 returns an exit status of zero (success).
882 An OR list has the form
886 <I>command1
</I> <B>||
</B> <I>command2
</I>
893 is executed if, and only if,
896 returns a non-zero exit status.
898 AND and OR lists is the exit status of the last command
899 executed in the list.
900 <A NAME=
"lbAO"> </A>
901 <H4>Compound Commands
</H4>
903 A
<I>compound command
</I> is one of the following.
904 In most cases a
<I>list
</I> in a command's description may be separated from
905 the rest of the command by one or more newlines, and may be followed by a
906 newline in place of a semicolon.
908 <DT>(
<I>list
</I>)
<DD>
909 <I>list
</I> is executed in a subshell (see
910 <FONT SIZE=-
1><B>COMMAND EXECUTION ENVIRONMENT
</B></FONT>
911 below for a description of a subshell environment).
912 Variable assignments and builtin
913 commands that affect the shell's environment do not remain in effect
914 after the command completes. The return status is the exit status of
916 <DT>{
<I>list
</I>; }
<DD>
917 <I>list
</I> is simply executed in the current shell environment.
918 <I>list
</I> must be terminated with a newline or semicolon.
919 This is known as a
<I>group command
</I>.
920 The return status is the exit status of
922 Note that unlike the metacharacters
<B>(
</B> and
<B>)
</B>,
<B>{
</B> and
923 <B>}
</B> are
<I>reserved words
</I> and must occur where a reserved
924 word is permitted to be recognized. Since they do not cause a word
925 break, they must be separated from
<I>list
</I> by whitespace or another
927 <DT>((
<I>expression
</I>))
<DD>
928 The
<I>expression
</I> is evaluated according to the rules described
930 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>.
933 If the value of the expression is non-zero, the return status is
0;
934 otherwise the return status is
1.
935 The
<I>expression
</I>
936 undergoes the same expansions
937 as if it were within double quotes,
938 but double quote characters in
<I>expression
</I> are not treated specially
940 <DT><B>[[
</B> <I>expression
</I> <B>]]
</B><DD>
941 Return a status of
0 or
1 depending on the evaluation of
942 the conditional expression
<I>expression
</I>.
943 Expressions are composed of the primaries described below under
944 <FONT SIZE=-
1><B>CONDITIONAL EXPRESSIONS
</B>.
947 The words between the
<B>[[
</B> and
<B>]]
</B> do not undergo word splitting
948 and pathname expansion.
949 The shell performs tilde expansion, parameter and
950 variable expansion, arithmetic expansion, command substitution, process
951 substitution, and quote removal on those words
952 (the expansions that would occur if the words were enclosed in double quotes).
953 Conditional operators such as
<B>-f
</B> must be unquoted to be recognized
958 When used with
<B>[[
</B>, the
<B><</B> and
<B>></B> operators sort
959 lexicographically using the current locale.
963 When the
<B>==
</B> and
<B>!=
</B> operators are used, the string to the
964 right of the operator is considered a pattern and matched according
965 to the rules described below under
<B>Pattern Matching
</B>,
966 as if the
<B>extglob
</B> shell option were enabled.
967 The
<B>=
</B> operator is equivalent to
<B>==
</B>.
971 shell option is enabled, the match is performed without regard to the case
972 of alphabetic characters.
973 The return value is
0 if the string matches (
<B>==
</B>) or does not match
974 (
<B>!=
</B>) the pattern, and
1 otherwise.
975 Any part of the pattern may be quoted to force the quoted portion
976 to be matched as a string.
980 An additional binary operator,
<B>=~
</B>, is available, with the same
981 precedence as
<B>==
</B> and
<B>!=
</B>.
982 When it is used, the string to the right of the operator is considered
983 a POSIX extended regular expression and matched accordingly
984 (using the POSIX
<I>regcomp
</I> and
<I>regexec
</I> interfaces
985 usually described in
<I>regex
</I>(
3)).
986 The return value is
0 if the string matches
987 the pattern, and
1 otherwise.
988 If the regular expression is syntactically incorrect, the conditional
989 expression's return value is
2.
993 shell option is enabled, the match is performed without regard to the case
994 of alphabetic characters.
995 If any part of the pattern is quoted, the quoted portion is matched literally.
996 This means every character in the quoted portion matches itself,
997 instead of having any special pattern matching meaning.
998 If the pattern is stored in a shell variable, quoting the variable
999 expansion forces the entire pattern to be matched literally.
1000 Treat bracket expressions in regular expressions carefully,
1001 since normal quoting and pattern characters lose their meanings
1006 The pattern will match if it matches any part of the string.
1007 Anchor the pattern using the
<B>^
</B> and
<B>$
</B> regular expression
1008 operators to force it to match the entire string.
1010 <FONT SIZE=-
1><B>BASH_REMATCH
</B>
1013 records which parts of the string matched the pattern.
1015 <FONT SIZE=-
1><B>BASH_REMATCH
</B>
1018 with index
0 contains the portion of
1019 the string matching the entire regular expression.
1020 Substrings matched by parenthesized subexpressions within the regular
1021 expression are saved in the remaining
1022 <FONT SIZE=-
1><B>BASH_REMATCH
</B>
1025 indices. The element of
1026 <FONT SIZE=-
1><B>BASH_REMATCH
</B>
1029 with index
<I>n
</I> is the portion of the
1030 string matching the
<I>n
</I>th parenthesized subexpression.
1032 <FONT SIZE=-
1><B>BASH_REMATCH
</B>
1035 in the global scope; declaring it as a local variable will lead to
1040 Expressions may be combined using the following operators, listed
1041 in decreasing order of precedence:
1045 <DL COMPACT
><DT><DD>
1048 <DT><B>(
</B><I>expression
</I> )
1051 Returns the value of
<I>expression
</I>.
1052 This may be used to override the normal precedence of operators.
1053 <DT><B>!
</B><I>expression
</I>
1060 <DT><I>expression1
</I> <B>&&</B> <I>expression2
</I><DD>
1068 <DT><I>expression1
</I> <B>||
</B> <I>expression2
</I><DD>
1080 The
<B>&&</B> and
<B>||
</B>
1081 operators do not evaluate
<I>expression2
</I> if the value of
1082 <I>expression1
</I> is sufficient to determine the return value of
1083 the entire conditional expression.
1086 <DT><B>for
</B> <I>name
</I> [ [
<B>in
</B> [
<I>word ...
</I> ] ] ; ]
<B>do
</B> <I>list
</I> ;
<B>done
</B><DD>
1087 The list of words following
<B>in
</B> is expanded, generating a list
1089 The variable
<I>name
</I> is set to each element of this list
1090 in turn, and
<I>list
</I> is executed each time.
1091 If the
<B>in
</B> <I>word
</I> is omitted, the
<B>for
</B> command executes
1092 <I>list
</I> once for each positional parameter that is set (see
1093 <FONT SIZE=-
1><B>PARAMETERS
</B>
1097 The return status is the exit status of the last command that executes.
1098 If the expansion of the items following
<B>in
</B> results in an empty
1099 list, no commands are executed, and the return status is
0.
1100 <DT><B>for
</B> ((
<I>expr1
</I> ;
<I>expr2
</I> ;
<I>expr3
</I> )) ;
<B>do
</B> <I>list
</I> ;
<B>done
</B><DD>
1101 First, the arithmetic expression
<I>expr1
</I> is evaluated according
1102 to the rules described below under
1103 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>.
1106 The arithmetic expression
<I>expr2
</I> is then evaluated repeatedly
1107 until it evaluates to zero.
1108 Each time
<I>expr2
</I> evaluates to a non-zero value,
<I>list
</I> is
1109 executed and the arithmetic expression
<I>expr3
</I> is evaluated.
1110 If any expression is omitted, it behaves as if it evaluates to
1.
1111 The return value is the exit status of the last command in
<I>list
</I>
1112 that is executed, or false if any of the expressions is invalid.
1113 <DT><B>select
</B> <I>name
</I> [
<B>in
</B> <I>word
</I> ] ;
<B>do
</B> <I>list
</I> ;
<B>done
</B><DD>
1114 The list of words following
<B>in
</B> is expanded, generating a list
1115 of items, and the set of expanded words is printed on the standard
1116 error, each preceded by a number. If the
<B>in
</B>
1117 <I>word
</I> is omitted, the positional parameters are printed (see
1118 <FONT SIZE=-
1><B>PARAMETERS
</B>
1125 <FONT SIZE=-
1><B>PS3
</B>
1128 prompt and reads a line from the standard input.
1129 If the line consists of a number corresponding to one of
1130 the displayed words, then the value of
1133 is set to that word.
1134 If the line is empty, the words and prompt are displayed again.
1135 If EOF is read, the
<B>select
</B> command completes and returns
1.
1136 Any other value read causes
1139 to be set to null. The line read is saved in the variable
1140 <FONT SIZE=-
1><B>REPLY
</B>.
1146 is executed after each selection until a
1149 command is executed.
1153 is the exit status of the last command executed in
1156 or zero if no commands were executed.
1157 <DT><B>case
</B> <I>word
</I> <B>in
</B> [ [(]
<I>pattern
</I> [
<B>|
</B> <I>pattern
</I> ]
1159 A
<B>case
</B> command first expands
<I>word
</I>, and tries to match
1160 it against each
<I>pattern
</I> in turn, using the matching rules
1162 <B>Pattern Matching
</B>
1165 The
<I>word
</I> is expanded using tilde
1166 expansion, parameter and variable expansion, arithmetic expansion,
1167 command substitution, process substitution and quote removal.
1168 Each
<I>pattern
</I> examined is expanded using tilde
1169 expansion, parameter and variable expansion, arithmetic expansion,
1170 command substitution, process substitution, and quote removal.
1174 shell option is enabled, the match is performed without regard to the case
1175 of alphabetic characters.
1176 When a match is found, the corresponding
<I>list
</I> is executed.
1177 If the
<B>;;
</B> operator is used, no subsequent matches are attempted after
1178 the first pattern match.
1179 Using
<B>;
&</B> in place of
<B>;;
</B> causes execution to continue with
1180 the
<I>list
</I> associated with the next set of patterns.
1181 Using
<B>;;
&</B> in place of
<B>;;
</B> causes the shell to test the next
1182 pattern list in the statement, if any, and execute any associated
<I>list
</I>
1183 on a successful match,
1184 continuing the case statement execution as if the pattern list had not matched.
1185 The exit status is zero if no
1186 pattern matches. Otherwise, it is the exit status of the
1187 last command executed in
<I>list
</I>.
1188 <DT><B>if
</B> <I>list
</I>;
<B>then
</B> <I>list
</I>; [
<B>elif
</B> <I>list
</I>;
<B>then
</B> <I>list
</I>; ] ... [
<B>else
</B> <I>list
</I>; ]
<B>fi
</B><DD>
1194 is executed. If its exit status is zero, the
1195 <B>then
</B> <I>list
</I> is executed. Otherwise, each
<B>elif
</B>
1196 <I>list
</I> is executed in turn, and if its exit status is zero,
1197 the corresponding
<B>then
</B> <I>list
</I> is executed and the
1198 command completes. Otherwise, the
<B>else
</B> <I>list
</I> is
1199 executed, if present. The exit status is the exit status of the
1200 last command executed, or zero if no condition tested true.
1201 <DT><B>while
</B> <I>list-
1</I>;
<B>do
</B> <I>list-
2</I>;
<B>done
</B><DD>
1203 <DT><B>until
</B> <I>list-
1</I>;
<B>do
</B> <I>list-
2</I>;
<B>done
</B><DD>
1205 The
<B>while
</B> command continuously executes the list
1206 <I>list-
2</I> as long as the last command in the list
<I>list-
1</I> returns
1207 an exit status of zero. The
<B>until
</B> command is identical
1208 to the
<B>while
</B> command, except that the test is negated:
1211 is executed as long as the last command in
1214 returns a non-zero exit status.
1215 The exit status of the
<B>while
</B> and
<B>until
</B> commands
1217 of the last command executed in
<I>list-
2</I>, or zero if
1220 <A NAME=
"lbAP"> </A>
1221 <H4>Coprocesses
</H4>
1223 A
<I>coprocess
</I> is a shell command preceded by the
<B>coproc
</B> reserved
1225 A coprocess is executed asynchronously in a subshell, as if the command
1226 had been terminated with the
<B>&</B> control operator, with a two-way pipe
1227 established between the executing shell and the coprocess.
1230 The syntax for a coprocess is:
1231 <DL COMPACT
><DT><DD>
1234 <B>coproc
</B> [
<I>NAME
</I>]
<I>command
</I> [
<I>redirections
</I>]
1239 This creates a coprocess named
<I>NAME
</I>.
1240 <I>command
</I> may be either a simple command or a compound
1241 command (see above).
1242 <I>NAME
</I> is a shell variable name.
1243 If
<I>NAME
</I> is not supplied, the default name is
<B>COPROC
</B>.
1246 The recommended form to use for a coprocess is
1247 <DL COMPACT
><DT><DD>
1250 <B>coproc
</B> <I>NAME
</I> {
<I>command
</I> [
<I>redirections
</I>]; }
1255 This form is recommended because simple commands result in the coprocess
1256 always being named
<B>COPROC
</B>, and it is simpler to use and more complete
1257 than the other compound commands.
1260 If
<I>command
</I> is a compound command,
<I>NAME
</I> is optional. The
1261 word following
<B>coproc
</B> determines whether that word is interpreted
1262 as a variable name: it is interpreted as
<I>NAME
</I> if it is not a
1263 reserved word that introduces a compound command.
1264 If
<I>command
</I> is a simple command,
<I>NAME
</I> is not allowed; this
1265 is to avoid confusion between
<I>NAME
</I> and the first word of the simple
1269 When the coprocess is executed, the shell creates an array variable (see
1272 below) named
<I>NAME
</I> in the context of the executing shell.
1273 The standard output of
1276 is connected via a pipe to a file descriptor in the executing shell,
1277 and that file descriptor is assigned to
<I>NAME
</I>[
0].
1278 The standard input of
1281 is connected via a pipe to a file descriptor in the executing shell,
1282 and that file descriptor is assigned to
<I>NAME
</I>[
1].
1283 This pipe is established before any redirections specified by the
1285 <FONT SIZE=-
1><B>REDIRECTION
</B>
1289 The file descriptors can be utilized as arguments to shell commands
1290 and redirections using standard word expansions.
1291 Other than those created to execute command and process substitutions,
1292 the file descriptors are not available in subshells.
1295 The process ID of the shell spawned to execute the coprocess is
1296 available as the value of the variable
<I>NAME
</I>_PID.
1298 builtin command may be used to wait for the coprocess to terminate.
1301 Since the coprocess is created as an asynchronous command,
1302 the
<B>coproc
</B> command always returns success.
1303 The return status of a coprocess is the exit status of
<I>command
</I>.
1304 <A NAME=
"lbAQ"> </A>
1305 <H4>Shell Function Definitions
</H4>
1307 A shell function is an object that is called like a simple command and
1308 executes a compound command with a new set of positional parameters.
1309 Shell functions are declared as follows:
1311 <DT><I>fname
</I> ()
<I>compound-command
</I> [
<I>redirection
</I>]
<DD>
1313 <DT><B>function
</B> <I>fname
</I> [()]
<I>compound-command
</I> [
<I>redirection
</I>]
<DD>
1315 This defines a function named
<I>fname
</I>.
1316 The reserved word
<B>function
</B> is optional.
1317 If the
<B>function
</B> reserved word is supplied, the parentheses are optional.
1318 The
<I>body
</I> of the function is the compound command
1319 <I>compound-command
</I>
1321 (see
<B>Compound Commands
</B> above).
1322 That command is usually a
<I>list
</I> of commands between { and }, but
1323 may be any command listed under
<B>Compound Commands
</B> above.
1324 If the
<B>function
</B> reserved word is used, but the
1325 parentheses are not supplied, the braces are recommended.
1326 <I>compound-command
</I> is executed whenever
<I>fname
</I> is specified as the
1327 name of a simple command.
1328 When in
<I>posix mode
</I>,
<I>fname
</I> must be a valid shell
<I>name
</I>
1329 and may not be the name of one of the
1330 POSIX
<I>special builtins
</I>.
1331 In default mode, a function name can be any unquoted shell word that does
1332 not contain
<B>$
</B>.
1333 Any redirections (see
1334 <FONT SIZE=-
1><B>REDIRECTION
</B>
1337 below) specified when a function is defined are performed
1338 when the function is executed.
1339 The exit status of a function definition is zero unless a syntax error
1340 occurs or a readonly function with the same name already exists.
1341 When executed, the exit status of a function is the exit status of the
1342 last command executed in the body. (See
1343 <FONT SIZE=-
1><B>FUNCTIONS
</B>
1348 <A NAME=
"lbAR"> </A>
1351 In a non-interactive shell, or an interactive shell in which the
1352 <B>interactive_comments
</B>
1357 builtin is enabled (see
1358 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
1361 below), a word beginning with
1364 causes that word and all remaining characters on that line to
1365 be ignored. An interactive shell without the
1366 <B>interactive_comments
</B>
1368 option enabled does not allow comments. The
1369 <B>interactive_comments
</B>
1371 option is on by default in interactive shells.
1372 <A NAME=
"lbAS"> </A>
1375 <I>Quoting
</I> is used to remove the special meaning of certain
1376 characters or words to the shell. Quoting can be used to
1377 disable special treatment for special characters, to prevent
1378 reserved words from being recognized as such, and to prevent
1379 parameter expansion.
1382 Each of the
<I>metacharacters
</I> listed above under
1383 <FONT SIZE=-
1><B>DEFINITIONS
</B>
1386 has special meaning to the shell and must be quoted if it is to
1390 When the command history expansion facilities are being used
1392 <FONT SIZE=-
1><B>HISTORY EXPANSION
</B>
1396 <I>history expansion
</I> character, usually
<B>!
</B>, must be quoted
1397 to prevent history expansion.
1400 There are three quoting mechanisms: the
1401 <I>escape character
</I>,
1403 single quotes, and double quotes.
1406 A non-quoted backslash (
<B>\
</B>) is the
1407 <I>escape character
</I>.
1409 It preserves the literal value of the next character that follows,
1410 with the exception of
<newline
>. If a
<B>\
</B><newline
> pair
1411 appears, and the backslash is not itself quoted, the
<B>\
</B><newline
>
1412 is treated as a line continuation (that is, it is removed from the
1413 input stream and effectively ignored).
1416 Enclosing characters in single quotes preserves the literal value
1417 of each character within the quotes. A single quote may not occur
1418 between single quotes, even when preceded by a backslash.
1421 Enclosing characters in double quotes preserves the literal value
1422 of all characters within the quotes, with the exception of
1429 and, when history expansion is enabled,
1432 When the shell is in
<I>posix mode
</I>, the
<B>!
</B> has no special meaning
1433 within double quotes, even when history expansion is enabled.
1440 retain their special meaning within double quotes. The backslash
1441 retains its special meaning only when followed by one of the following
1451 <B><newline
></B>.
1453 A double quote may be quoted within double quotes by preceding it with
1455 If enabled, history expansion will be performed unless an
1458 appearing in double quotes is escaped using a backslash.
1459 The backslash preceding the
1465 The special parameters
1471 have special meaning when in double
1473 <FONT SIZE=-
1><B>PARAMETERS
</B>
1479 Character sequences of the form
<B>$
</B>aq
<I>string
</I>aq are treated
1480 as a special variant of single quotes.
1481 The sequence expands to
<I>string
</I>, with backslash-escaped characters
1482 in
<I>string
</I> replaced as specified by the ANSI C standard.
1483 Backslash escape sequences, if present, are decoded as follows:
1484 <DL COMPACT
><DT><DD>
1538 <DT><B>\
</B><I>nnn
</I>
1541 the eight-bit character whose value is the octal value
<I>nnn
</I>
1542 (one to three octal digits)
1543 <DT><B>\x
</B><I>HH
</I>
1546 the eight-bit character whose value is the hexadecimal value
<I>HH
</I>
1547 (one or two hex digits)
1548 <DT><B>\u
</B><I>HHHH
</I>
1551 the Unicode (ISO/IEC
10646) character whose value is the hexadecimal value
1552 <I>HHHH
</I> (one to four hex digits)
1553 <DT><B>\U
</B><I>HHHHHHHH
</I>
1556 the Unicode (ISO/IEC
10646) character whose value is the hexadecimal value
1557 <I>HHHHHHHH
</I> (one to eight hex digits)
1558 <DT><B>\c
</B><I>x
</I>
1561 a control-
<I>x
</I> character
1567 The expanded result is single-quoted, as if the dollar sign had
1571 A double-quoted string preceded by a dollar sign (
<B>$
</B>dq
<I>string
</I>dq)
1572 will cause the string to be translated according to the current locale.
1573 The
<I>gettext
</I> infrastructure performs the lookup and
1574 translation, using the
<B>LC_MESSAGES
</B>,
<B>TEXTDOMAINDIR
</B>,
1575 and
<B>TEXTDOMAIN
</B> shell variables.
1576 If the current locale is
<B>C
</B> or
<B>POSIX
</B>,
1577 if there are no translations available,
1578 or if the string is not translated,
1579 the dollar sign is ignored.
1580 This is a form of double quoting, so the string remains double-quoted
1581 by default, whether or not it is translated and replaced.
1582 If the
<B>noexpand_translation
</B> option is enabled
1583 using the
<B>shopt
</B> builtin,
1584 translated strings are single-quoted instead of double-quoted.
1585 See the description of
1589 <FONT SIZE=-
1><B>SHELL
</B>BUILTIN
<B>COMMANDS
</B>.
1592 <A NAME=
"lbAT"> </A>
1598 is an entity that stores values.
1602 a number, or one of the special characters listed below under
1603 <B>Special Parameters
</B>.
1608 is a parameter denoted by a
1611 A variable has a
<I>value
</I> and zero or more
<I>attributes
</I>.
1612 Attributes are assigned using the
1615 builtin command (see
1619 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>).
1624 A parameter is set if it has been assigned a value. The null string is
1625 a valid value. Once a variable is set, it may be unset only by using
1629 builtin command (see
1630 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
1639 may be assigned to by a statement of the form
1640 <DL COMPACT
><DT><DD>
1643 <I>name
</I>=[
<I>value
</I>]
1651 is not given, the variable is assigned the null string. All
1654 undergo tilde expansion, parameter and variable expansion,
1655 command substitution, arithmetic expansion, and quote
1657 <FONT SIZE=-
1><B>EXPANSION
</B>
1660 below). If the variable has its
1666 is evaluated as an arithmetic expression even if the $((...)) expansion is
1668 <B>Arithmetic Expansion
</B>
1671 Word splitting and pathname expansion are not performed.
1672 Assignment statements may also appear as arguments to the
1686 builtin commands (
<I>declaration
</I> commands).
1687 When in
<I>posix mode
</I>, these builtins may appear in a command after
1688 one or more instances of the
<B>command
</B> builtin and retain these
1689 assignment statement properties.
1692 In the context where an assignment statement is assigning a value
1693 to a shell variable or array index, the += operator can be used to
1694 append to or add to the variable's previous value.
1695 This includes arguments to builtin commands such as
<B>declare
</B> that
1696 accept assignment statements (
<I>declaration
</I> commands).
1697 When += is applied to a variable for which the
<B>integer
</B> attribute has been
1698 set,
<I>value
</I> is evaluated as an arithmetic expression and added to the
1699 variable's current value, which is also evaluated.
1700 When += is applied to an array variable using compound assignment (see
1704 variable's value is not unset (as it is when using =), and new values are
1705 appended to the array beginning at one greater than the array's maximum index
1706 (for indexed arrays) or added as additional key-value pairs in an
1708 When applied to a string-valued variable,
<I>value
</I> is expanded and
1709 appended to the variable's value.
1712 A variable can be assigned the
<I>nameref
</I> attribute using the
1713 <B>-n
</B> option to the
<B>declare
</B> or
<B>local
</B> builtin commands
1714 (see the descriptions of
<B>declare
</B> and
<B>local
</B> below)
1715 to create a
<I>nameref
</I>, or a reference to another variable.
1716 This allows variables to be manipulated indirectly.
1717 Whenever the nameref variable is referenced, assigned to, unset, or has
1718 its attributes modified (other than using or changing the
<I>nameref
</I>
1719 attribute itself), the
1720 operation is actually performed on the variable specified by the nameref
1722 A nameref is commonly used within shell functions to refer to a variable
1723 whose name is passed as an argument to the function.
1724 For instance, if a variable name is passed to a shell function as its first
1727 <DL COMPACT
><DT><DD>
1728 <TT>declare -n ref=$
1</TT>
1733 inside the function creates a nameref variable
<B>ref
</B> whose value is
1734 the variable name passed as the first argument.
1735 References and assignments to
<B>ref
</B>, and changes to its attributes,
1736 are treated as references, assignments, and attribute modifications
1737 to the variable whose name was passed as
<B>$
1</B>.
1738 If the control variable in a
<B>for
</B> loop has the nameref attribute,
1739 the list of words can be a list of shell variables, and a name reference
1740 will be established for each word in the list, in turn, when the loop is
1742 Array variables cannot be given the
<B>nameref
</B> attribute.
1743 However, nameref variables can reference array variables and subscripted
1745 Namerefs can be unset using the
<B>-n
</B> option to the
<B>unset
</B> builtin.
1746 Otherwise, if
<B>unset
</B> is executed with the name of a nameref variable
1747 as an argument, the variable referenced by the nameref variable will be unset.
1748 <A NAME=
"lbAU"> </A>
1749 <H4>Positional Parameters
</H4>
1752 <I>positional parameter
</I>
1754 is a parameter denoted by one or more
1755 digits, other than the single digit
0. Positional parameters are
1756 assigned from the shell's arguments when it is invoked,
1757 and may be reassigned using the
1760 builtin command. Positional parameters may not be assigned to
1761 with assignment statements. The positional parameters are
1762 temporarily replaced when a shell function is executed (see
1763 <FONT SIZE=-
1><B>FUNCTIONS
</B>
1769 When a positional parameter consisting of more than a single
1770 digit is expanded, it must be enclosed in braces (see
1771 <FONT SIZE=-
1><B>EXPANSION
</B>
1775 <A NAME=
"lbAV"> </A>
1776 <H4>Special Parameters
</H4>
1778 The shell treats several parameters specially. These parameters may
1779 only be referenced; assignment to them is not allowed.
1785 Expands to the positional parameters, starting from one.
1786 When the expansion is not within double quotes, each positional parameter
1787 expands to a separate word.
1788 In contexts where it is performed, those words
1789 are subject to further word splitting and pathname expansion.
1790 When the expansion occurs within double quotes, it expands to a single word
1791 with the value of each parameter separated by the first character of the
1792 <FONT SIZE=-
1><B>IFS
</B>
1795 special variable. That is,
"<B>$*
</B>" is equivalent
1796 to
"<B>$
1</B><I>c
</I><B>$
2</B><I>c
</I><B>...
</B>", where
1799 is the first character of the value of the
1800 <FONT SIZE=-
1><B>IFS
</B>
1804 <FONT SIZE=-
1><B>IFS
</B>
1807 is unset, the parameters are separated by spaces.
1809 <FONT SIZE=-
1><B>IFS
</B>
1812 is null, the parameters are joined without intervening separators.
1816 Expands to the positional parameters, starting from one.
1817 In contexts where word splitting is performed, this expands each
1818 positional parameter to a separate word; if not within double
1819 quotes, these words are subject to word splitting.
1820 In contexts where word splitting is not performed,
1821 this expands to a single word
1822 with each positional parameter separated by a space.
1824 expansion occurs within double quotes, each parameter expands to a
1825 separate word. That is,
"<B>$@
</B>" is equivalent to
1826 "<B>$
1</B>" "<B>$
2</B>" ...
1827 If the double-quoted expansion occurs within a word, the expansion of
1828 the first parameter is joined with the beginning part of the original
1829 word, and the expansion of the last parameter is joined with the last
1830 part of the original word.
1831 When there are no positional parameters,
"<B>$@
</B>" and
1834 expand to nothing (i.e., they are removed).
1838 Expands to the number of positional parameters in decimal.
1842 Expands to the exit status of the most recently executed foreground
1847 Expands to the current option flags as specified upon invocation,
1851 builtin command, or those set by the shell itself
1859 Expands to the process ID of the shell. In a subshell, it
1860 expands to the process ID of the current shell, not the
1865 Expands to the process ID of the job most recently placed into the
1866 background, whether executed as an asynchronous command or using
1867 the
<B>bg
</B> builtin (see
1868 <FONT SIZE=-
1><B>JOB CONTROL
</B>
1875 Expands to the name of the shell or shell script. This is set at
1876 shell initialization. If
1879 is invoked with a file of commands,
1882 is set to the name of that file. If
1891 is set to the first argument after the string to be
1892 executed, if one is present. Otherwise, it is set
1893 to the filename used to invoke
1896 as given by argument zero.
1899 <A NAME=
"lbAW"> </A>
1900 <H4>Shell Variables
</H4>
1902 The following variables are set by the shell:
1910 At shell startup, set to the pathname used to invoke the
1911 shell or shell script being executed as passed in the environment
1913 Subsequently, expands to the last argument to the previous simple
1914 command executed in the foreground, after expansion.
1915 Also set to the full pathname used to invoke each command executed
1916 and placed in the environment exported to that command.
1917 When checking mail, this parameter holds the name of the mail file
1918 currently being checked.
1922 Expands to the full filename used to invoke this instance of
1928 A colon-separated list of enabled shell options. Each word in
1929 the list is a valid argument for the
1935 builtin command (see
1936 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
1939 below). The options appearing in
1940 <FONT SIZE=-
1><B>BASHOPTS
</B>
1943 are those reported as
1947 If this variable is in the environment when
1950 starts up, each shell option in the list will be enabled before
1951 reading any startup files.
1952 This variable is read-only.
1956 Expands to the process ID of the current
<B>bash
</B> process.
1957 This differs from
<B>$$
</B> under certain circumstances, such as subshells
1958 that do not require
<B>bash
</B> to be re-initialized.
1960 <FONT SIZE=-
1><B>BASHPID
</B>
1967 is unset, it loses its special properties, even if it is
1969 <DT><B>BASH_ALIASES
</B>
1972 An associative array variable whose members correspond to the internal
1973 list of aliases as maintained by the
<B>alias
</B> builtin.
1974 Elements added to this array appear in the alias list; however,
1975 unsetting array elements currently does not cause aliases to be removed
1976 from the alias list.
1980 is unset, it loses its special properties, even if it is
1982 <DT><B>BASH_ARGC
</B>
1985 An array variable whose values are the number of parameters in each
1986 frame of the current
<B>bash
</B> execution call stack.
1988 parameters to the current subroutine (shell function or script executed
1989 with
<B>.
</B> or
<B>source
</B>) is at the top of the stack.
1990 When a subroutine is executed, the number of parameters passed is pushed onto
1991 <FONT SIZE=-
1><B>BASH_ARGC
</B>.
1995 <FONT SIZE=-
1><B>BASH_ARGC
</B>
1998 only when in extended debugging mode (see the description of the
2005 Setting
<B>extdebug
</B> after the shell has started to execute a script,
2006 or referencing this variable when
<B>extdebug
</B> is not set,
2007 may result in inconsistent values.
2008 <DT><B>BASH_ARGV
</B>
2011 An array variable containing all of the parameters in the current
<B>bash
</B>
2012 execution call stack. The final parameter of the last subroutine call
2013 is at the top of the stack; the first parameter of the initial call is
2014 at the bottom. When a subroutine is executed, the parameters supplied
2016 <FONT SIZE=-
1><B>BASH_ARGV
</B>.
2020 <FONT SIZE=-
1><B>BASH_ARGV
</B>
2023 only when in extended debugging mode
2024 (see the description of the
2031 Setting
<B>extdebug
</B> after the shell has started to execute a script,
2032 or referencing this variable when
<B>extdebug
</B> is not set,
2033 may result in inconsistent values.
2034 <DT><B>BASH_ARGV0
</B>
2037 When referenced, this variable expands to the name of the shell or shell
2038 script (identical to
2041 see the description of special parameter
0 above).
2045 causes the value assigned to also be assigned to
<B>$
0</B>.
2049 is unset, it loses its special properties, even if it is
2051 <DT><B>BASH_CMDS
</B>
2054 An associative array variable whose members correspond to the internal
2055 hash table of commands as maintained by the
<B>hash
</B> builtin.
2056 Elements added to this array appear in the hash table; however,
2057 unsetting array elements currently does not cause command names to be removed
2058 from the hash table.
2062 is unset, it loses its special properties, even if it is
2064 <DT><B>BASH_COMMAND
</B>
2067 The command currently being executed or about to be executed, unless the
2068 shell is executing a command as the result of a trap,
2069 in which case it is the command executing at the time of the trap.
2073 is unset, it loses its special properties, even if it is
2075 <DT><B>BASH_EXECUTION_STRING
</B>
2078 The command argument to the
<B>-c
</B> invocation option.
2079 <DT><B>BASH_LINENO
</B>
2082 An array variable whose members are the line numbers in source files
2083 where each corresponding member of
2084 <FONT SIZE=-
1><B>FUNCNAME
</B>
2088 <B>${BASH_LINENO[
</B><I>$i
</I><B>]}
</B> is the line number in the source
2089 file (
<B>${BASH_SOURCE[
</B><I>$i+
1</I><B>]}
</B>) where
2090 <B>${FUNCNAME[
</B><I>$i
</I><B>]}
</B> was called
2091 (or
<B>${BASH_LINENO[
</B><I>$i-
1</I><B>]}
</B> if referenced within another
2094 <FONT SIZE=-
1><B>LINENO
</B>
2097 to obtain the current line number.
2098 <DT><B>BASH_LOADABLES_PATH
</B>
2101 A colon-separated list of directories in which the shell looks for
2102 dynamically loadable builtins specified by the
2106 <DT><B>BASH_REMATCH
</B>
2109 An array variable whose members are assigned by the
<B>=~
</B> binary
2110 operator to the
<B>[[
</B> conditional command.
2111 The element with index
0 is the portion of the string
2112 matching the entire regular expression.
2113 The element with index
<I>n
</I> is the portion of the
2114 string matching the
<I>n
</I>th parenthesized subexpression.
2115 <DT><B>BASH_SOURCE
</B>
2118 An array variable whose members are the source filenames
2119 where the corresponding shell function names in the
2120 <FONT SIZE=-
1><B>FUNCNAME
</B>
2123 array variable are defined.
2125 <B>${FUNCNAME[
</B><I>$i
</I><B>]}
</B> is defined in the file
2126 <B>${BASH_SOURCE[
</B><I>$i
</I><B>]}
</B> and called from
2127 <B>${BASH_SOURCE[
</B><I>$i+
1</I><B>]}
</B>.
2128 <DT><B>BASH_SUBSHELL
</B>
2131 Incremented by one within each subshell or subshell environment when
2132 the shell begins executing in that environment.
2133 The initial value is
0.
2135 <B>BASH_SUBSHELL
</B>
2137 is unset, it loses its special properties, even if it is
2139 <DT><B>BASH_VERSINFO
</B>
2142 A readonly array variable whose members hold version information for
2146 The values assigned to the array members are as follows:
2148 <DL COMPACT
><DT><DD>
2150 <DT><B>BASH_VERSINFO[
</B>0]
2153 The major version number (the
<I>release
</I>).
2154 <DT><B>BASH_VERSINFO[
</B>1]
2157 The minor version number (the
<I>version
</I>).
2158 <DT><B>BASH_VERSINFO[
</B>2]
2162 <DT><B>BASH_VERSINFO[
</B>3]
2166 <DT><B>BASH_VERSINFO[
</B>4]
2169 The release status (e.g.,
<I>beta1
</I>).
2170 <DT><B>BASH_VERSINFO[
</B>5]
2174 <FONT SIZE=-
1><B>MACHTYPE
</B>.
2179 <DT><B>BASH_VERSION
</B>
2182 Expands to a string describing the version of this instance of
2185 <DT><B>COMP_CWORD
</B>
2188 An index into
<B>${COMP_WORDS}
</B> of the word containing the current
2190 This variable is available only in shell functions invoked by the
2191 programmable completion facilities (see
<B>Programmable Completion
</B>
2196 The key (or final key of a key sequence) used to invoke the current
2197 completion function.
2198 <DT><B>COMP_LINE
</B>
2201 The current command line.
2202 This variable is available only in shell functions and external
2203 commands invoked by the
2204 programmable completion facilities (see
<B>Programmable Completion
</B>
2206 <DT><B>COMP_POINT
</B>
2209 The index of the current cursor position relative to the beginning of
2210 the current command.
2211 If the current cursor position is at the end of the current command,
2212 the value of this variable is equal to
<B>${#COMP_LINE}
</B>.
2213 This variable is available only in shell functions and external
2214 commands invoked by the
2215 programmable completion facilities (see
<B>Programmable Completion
</B>
2217 <DT><B>COMP_TYPE
</B>
2220 Set to an integer value corresponding to the type of completion attempted
2221 that caused a completion function to be called:
2222 <I>TAB
</I>, for normal completion,
2223 <I>?
</I>, for listing completions after successive tabs,
2224 <I>!
</I>, for listing alternatives on partial word completion,
2225 <I>@
</I>, to list completions if the word is not unmodified,
2227 <I>%
</I>, for menu completion.
2228 This variable is available only in shell functions and external
2229 commands invoked by the
2230 programmable completion facilities (see
<B>Programmable Completion
</B>
2232 <DT><B>COMP_WORDBREAKS
</B>
2235 The set of characters that the
<B>readline
</B> library treats as word
2236 separators when performing word completion.
2238 <FONT SIZE=-
1><B>COMP_WORDBREAKS
</B>
2241 is unset, it loses its special properties, even if it is
2243 <DT><B>COMP_WORDS
</B>
2246 An array variable (see
<B>Arrays
</B> below) consisting of the individual
2247 words in the current command line.
2248 The line is split into words as
<B>readline
</B> would split it, using
2249 <FONT SIZE=-
1><B>COMP_WORDBREAKS
</B>
2253 This variable is available only in shell functions invoked by the
2254 programmable completion facilities (see
<B>Programmable Completion
</B>
2259 An array variable (see
<B>Arrays
</B> below) created to hold the file descriptors
2260 for output from and input to an unnamed coprocess (see
<B>Coprocesses
</B>
2265 An array variable (see
2268 below) containing the current contents of the directory stack.
2269 Directories appear in the stack in the order they are displayed by the
2273 Assigning to members of this array variable may be used to modify
2274 directories already in the stack, but the
2280 builtins must be used to add and remove directories.
2281 Assignment to this variable will not change the current directory.
2283 <FONT SIZE=-
1><B>DIRSTACK
</B>
2286 is unset, it loses its special properties, even if it is
2288 <DT><B>EPOCHREALTIME
</B>
2291 Each time this parameter is referenced, it expands to the number of seconds
2292 since the Unix Epoch (see
<I>time
</I>(
3)) as a floating point value
2293 with micro-second granularity.
2295 <FONT SIZE=-
1><B>EPOCHREALTIME
</B>
2300 <FONT SIZE=-
1><B>EPOCHREALTIME
</B>
2303 is unset, it loses its special properties, even if it is
2305 <DT><B>EPOCHSECONDS
</B>
2308 Each time this parameter is referenced, it expands to the number of seconds
2309 since the Unix Epoch (see
<I>time
</I>(
3)).
2311 <FONT SIZE=-
1><B>EPOCHSECONDS
</B>
2316 <FONT SIZE=-
1><B>EPOCHSECONDS
</B>
2319 is unset, it loses its special properties, even if it is
2324 Expands to the effective user ID of the current user, initialized at
2325 shell startup. This variable is readonly.
2329 An array variable containing the names of all shell functions
2330 currently in the execution call stack.
2331 The element with index
0 is the name of any currently-executing
2333 The bottom-most element (the one with the highest index) is
2334 <TT>"main
"</TT>.
2336 This variable exists only when a shell function is executing.
2338 <FONT SIZE=-
1><B>FUNCNAME
</B>
2343 <FONT SIZE=-
1><B>FUNCNAME
</B>
2346 is unset, it loses its special properties, even if it is
2351 This variable can be used with
<B>BASH_LINENO
</B> and
<B>BASH_SOURCE
</B>.
2352 Each element of
<B>FUNCNAME
</B> has corresponding elements in
2353 <B>BASH_LINENO
</B> and
<B>BASH_SOURCE
</B> to describe the call stack.
2354 For instance,
<B>${FUNCNAME[
</B><I>$i
</I><B>]}
</B> was called from the file
2355 <B>${BASH_SOURCE[
</B><I>$i+
1</I><B>]}
</B> at line number
2356 <B>${BASH_LINENO[
</B><I>$i
</I><B>]}
</B>.
2357 The
<B>caller
</B> builtin displays the current call stack using this
2362 An array variable containing the list of groups of which the current
2365 <FONT SIZE=-
1><B>GROUPS
</B>
2370 <FONT SIZE=-
1><B>GROUPS
</B>
2373 is unset, it loses its special properties, even if it is
2378 The history number, or index in the history list, of the current
2381 <FONT SIZE=-
1><B>HISTCMD
</B>
2386 <FONT SIZE=-
1><B>HISTCMD
</B>
2389 is unset, it loses its special properties, even if it is
2394 Automatically set to the name of the current host.
2398 Automatically set to a string that uniquely
2399 describes the type of machine on which
2403 The default is system-dependent.
2407 Each time this parameter is referenced, the shell substitutes
2408 a decimal number representing the current sequential line number
2409 (starting with
1) within a script or function. When not in a
2410 script or function, the value substituted is not guaranteed to
2413 <FONT SIZE=-
1><B>LINENO
</B>
2416 is unset, it loses its special properties, even if it is
2421 Automatically set to a string that fully describes the system
2425 is executing, in the standard GNU
<I>cpu-company-system
</I> format.
2426 The default is system-dependent.
2430 An array variable (see
<B>Arrays
</B> below) created to hold the text
2431 read by the
<B>mapfile
</B> builtin when no variable name is supplied.
2435 The previous working directory as set by the
2442 The value of the last option argument processed by the
2445 builtin command (see
2446 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2453 The index of the next argument to be processed by the
2456 builtin command (see
2457 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2464 Automatically set to a string that
2465 describes the operating system on which
2469 The default is system-dependent.
2470 <DT><B>PIPESTATUS
</B>
2473 An array variable (see
2476 below) containing a list of exit status values from the processes
2477 in the most-recently-executed foreground pipeline (which may
2478 contain only a single command).
2482 The process ID of the shell's parent. This variable is readonly.
2486 The current working directory as set by the
2493 Each time this parameter is referenced, it expands to a random integer
2494 between
0 and
32767.
2497 <FONT SIZE=-
1><B>RANDOM
</B>
2500 initializes (seeds) the sequence of random numbers.
2502 <FONT SIZE=-
1><B>RANDOM
</B>
2505 is unset, it loses its special properties, even if it is
2507 <DT><B>READLINE_ARGUMENT
</B>
2510 Any numeric argument given to a readline command that was defined using
2514 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2518 when it was invoked.
2519 <DT><B>READLINE_LINE
</B>
2525 line buffer, for use with
2529 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2533 <DT><B>READLINE_MARK
</B>
2536 The position of the mark (saved insertion point) in the
2539 line buffer, for use with
2543 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2547 The characters between the insertion point and the mark are often
2548 called the
<I>region
</I>.
2549 <DT><B>READLINE_POINT
</B>
2552 The position of the insertion point in the
2555 line buffer, for use with
2559 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2566 Set to the line of input read by the
2569 builtin command when no arguments are supplied.
2573 Each time this parameter is
2574 referenced, it expands to the number of seconds since shell invocation.
2575 If a value is assigned to
2576 <FONT SIZE=-
1><B>SECONDS
</B>,
2579 the value returned upon subsequent
2581 the number of seconds since the assignment plus the value assigned.
2582 The number of seconds at shell invocation and the current time are always
2583 determined by querying the system clock.
2585 <FONT SIZE=-
1><B>SECONDS
</B>
2588 is unset, it loses its special properties, even if it is
2590 <DT><B>SHELLOPTS
</B>
2593 A colon-separated list of enabled shell options. Each word in
2594 the list is a valid argument for the
2600 builtin command (see
2601 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
2604 below). The options appearing in
2605 <FONT SIZE=-
1><B>SHELLOPTS
</B>
2608 are those reported as
2612 If this variable is in the environment when
2615 starts up, each shell option in the list will be enabled before
2616 reading any startup files.
2617 This variable is read-only.
2621 Incremented by one each time an instance of
2628 This variable expands to a
32-bit pseudo-random number each time it is
2629 referenced. The random number generator is not linear on systems that
2630 support
<TT>/dev/urandom
</TT> or
<I>arc4random
</I>, so each returned number
2631 has no relationship to the numbers preceding it.
2632 The random number generator cannot be seeded, so assignments to this
2633 variable have no effect.
2635 <FONT SIZE=-
1><B>SRANDOM
</B>
2638 is unset, it loses its special properties,
2639 even if it is subsequently reset.
2643 Expands to the user ID of the current user, initialized at shell startup.
2644 This variable is readonly.
2649 The following variables are used by the shell. In some cases,
2652 assigns a default value to a variable; these cases are noted
2658 <DT><B>BASH_COMPAT
</B>
2661 The value is used to set the shell's compatibility level.
2663 <FONT SIZE=-
1><B>SHELL COMPATIBILITY MODE
</B>
2666 below for a description of the various compatibility
2667 levels and their effects.
2668 The value may be a decimal number (e.g.,
4.2) or an integer (e.g.,
42)
2669 corresponding to the desired compatibility level.
2670 If
<B>BASH_COMPAT
</B> is unset or set to the empty string, the compatibility
2671 level is set to the default for the current version.
2672 If
<B>BASH_COMPAT
</B> is set to a value that is not one of the valid
2673 compatibility levels, the shell prints an error message and sets the
2674 compatibility level to the default for the current version.
2675 The valid values correspond to the compatibility levels
2676 described below under
2677 <FONT SIZE=-
1><B>SHELL COMPATIBILITY MODE
</B>.
2680 For example,
4.2 and
42 are valid values that correspond
2681 to the
<B>compat42
</B> <B>shopt
</B> option
2682 and set the compatibility level to
42.
2683 The current version is also a valid value.
2687 If this parameter is set when
<B>bash
</B> is executing a shell script,
2688 its value is interpreted as a filename containing commands to
2689 initialize the shell, as in
2690 <A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>.
2693 <FONT SIZE=-
1><B>BASH_ENV
</B>
2696 is subjected to parameter expansion, command substitution, and arithmetic
2697 expansion before being interpreted as a filename.
2698 <FONT SIZE=-
1><B>PATH
</B>
2701 is not used to search for the resultant filename.
2702 <DT><B>BASH_XTRACEFD
</B>
2705 If set to an integer corresponding to a valid file descriptor,
<B>bash
</B>
2706 will write the trace output generated when
2709 is enabled to that file descriptor.
2710 The file descriptor is closed when
2711 <FONT SIZE=-
1><B>BASH_XTRACEFD
</B>
2714 is unset or assigned a new value.
2716 <FONT SIZE=-
1><B>BASH_XTRACEFD
</B>
2719 or assigning it the empty string causes the
2720 trace output to be sent to the standard error.
2722 <FONT SIZE=-
1><B>BASH_XTRACEFD
</B>
2725 to
2 (the standard error file
2726 descriptor) and then unsetting it will result in the standard error
2731 The search path for the
2735 This is a colon-separated list of directories in which the shell looks
2736 for destination directories specified by the
2741 <TT>".:~:/usr
"</TT>.
2743 <DT><B>CHILD_MAX
</B>
2746 Set the number of exited child status values for the shell to remember.
2747 Bash will not allow this value to be decreased below a POSIX-mandated
2748 minimum, and there is a maximum value (currently
8192) that this may
2750 The minimum value is system-dependent.
2754 Used by the
<B>select
</B> compound command to determine the terminal width
2755 when printing selection lists.
2756 Automatically set if the
2759 option is enabled or in an interactive shell upon receipt of a
2760 <FONT SIZE=-
1><B>SIGWINCH
</B>.
2763 <DT><B>COMPREPLY
</B>
2766 An array variable from which
<B>bash
</B> reads the possible completions
2767 generated by a shell function invoked by the programmable completion
2768 facility (see
<B>Programmable Completion
</B> below).
2769 Each array element contains one possible completion.
2773 If
<B>bash
</B> finds this variable in the environment when the shell starts
2777 it assumes that the shell is running in an Emacs shell buffer and disables
2782 Expanded and executed similarly to
2783 <FONT SIZE=-
1><B>BASH_ENV
</B>
2786 (see
<B>INVOCATION
</B> above)
2787 when an interactive shell is invoked in
<I>posix mode
</I>.
2788 <DT><B>EXECIGNORE
</B>
2791 A colon-separated list of shell patterns (see
<B>Pattern Matching
</B>)
2792 defining the list of filenames to be ignored by command search using
2794 Files whose full pathnames match one of these patterns are not considered
2795 executable files for the purposes of completion and command execution
2796 via
<B>PATH
</B> lookup.
2797 This does not affect the behavior of the
<B>[
</B>,
<B>test
</B>, and
<B>[[
</B>
2799 Full pathnames in the command hash table are not subject to
<B>EXECIGNORE
</B>.
2800 Use this variable to ignore shared library files that have the executable
2801 bit set, but are not executable files.
2802 The pattern matching honors the setting of the
<B>extglob
</B> shell
2807 The default editor for the
2814 A colon-separated list of suffixes to ignore when performing
2815 filename completion (see
2816 <FONT SIZE=-
1><B>READLINE
</B>
2820 A filename whose suffix matches one of the entries in
2821 <FONT SIZE=-
1><B>FIGNORE
</B>
2824 is excluded from the list of matched filenames.
2826 <TT>".o:~
"</TT>.
2831 If set to a numeric value greater than
0, defines a maximum function
2832 nesting level. Function invocations that exceed this nesting level
2833 will cause the current command to abort.
2834 <DT><B>GLOBIGNORE
</B>
2837 A colon-separated list of patterns defining the set of file names to
2838 be ignored by pathname expansion.
2839 If a file name matched by a pathname expansion pattern also matches one
2841 <FONT SIZE=-
1><B>GLOBIGNORE
</B>,
2844 it is removed from the list of matches.
2845 <DT><B>HISTCONTROL
</B>
2848 A colon-separated list of values controlling how commands are saved on
2850 If the list of values includes
2853 lines which begin with a
2856 character are not saved in the history list.
2860 causes lines matching the previous history entry to not be saved.
2864 is shorthand for
<I>ignorespace
</I> and
<I>ignoredups
</I>.
2868 causes all previous lines matching the current line to be removed from
2869 the history list before that line is saved.
2870 Any value not in the above list is ignored.
2872 <FONT SIZE=-
1><B>HISTCONTROL
</B>
2875 is unset, or does not include a valid value,
2876 all lines read by the shell parser are saved on the history list,
2877 subject to the value of
2878 <FONT SIZE=-
1><B>HISTIGNORE
</B>.
2881 The second and subsequent lines of a multi-line compound command are
2882 not tested, and are added to the history regardless of the value of
2883 <FONT SIZE=-
1><B>HISTCONTROL
</B>.
2889 The name of the file in which command history is saved (see
2890 <FONT SIZE=-
1><B>HISTORY
</B>
2893 below). The default value is
<A HREF=
"file:~/.bash_history"><I>~/.bash_history
</I></A>. If unset, the
2894 command history is not saved when a shell exits.
2895 <DT><B>HISTFILESIZE
</B>
2898 The maximum number of lines contained in the history file. When this
2899 variable is assigned a value, the history file is truncated, if
2901 to contain no more than that number of lines by removing the oldest entries.
2902 The history file is also truncated to this size after
2903 writing it when a shell exits.
2904 If the value is
0, the history file is truncated to zero size.
2905 Non-numeric values and numeric values less than zero inhibit truncation.
2906 The shell sets the default value to the value of
<B>HISTSIZE
</B>
2907 after reading any startup files.
2908 <DT><B>HISTIGNORE
</B>
2911 A colon-separated list of patterns used to decide which command lines
2912 should be saved on the history list. Each pattern is anchored at the
2913 beginning of the line and must match the complete line (no implicit
2914 `
<B>*
</B>' is appended). Each pattern is tested against the line
2915 after the checks specified by
2916 <FONT SIZE=-
1><B>HISTCONTROL
</B>
2920 In addition to the normal shell pattern matching characters, `
<B>&</B>'
2921 matches the previous history line. `
<B>&</B>' may be escaped using a
2922 backslash; the backslash is removed before attempting a match.
2923 The second and subsequent lines of a multi-line compound command are
2924 not tested, and are added to the history regardless of the value of
2925 <FONT SIZE=-
1><B>HISTIGNORE
</B>.
2928 The pattern matching honors the setting of the
<B>extglob
</B> shell
2933 The number of commands to remember in the command history (see
2934 <FONT SIZE=-
1><B>HISTORY
</B>
2938 If the value is
0, commands are not saved in the history list.
2939 Numeric values less than zero result in every command being saved
2940 on the history list (there is no limit).
2941 The shell sets the default value to
500 after reading any startup files.
2942 <DT><B>HISTTIMEFORMAT
</B>
2945 If this variable is set and not null, its value is used as a format string
2946 for
<I>strftime
</I>(
3) to print the time stamp associated with each history
2947 entry displayed by the
<B>history
</B> builtin.
2948 If this variable is set, time stamps are written to the history file so
2949 they may be preserved across shell sessions.
2950 This uses the history comment character to distinguish timestamps from
2951 other history lines.
2955 The home directory of the current user; the default argument for the
2956 <B>cd
</B> builtin command.
2957 The value of this variable is also used when performing tilde expansion.
2961 Contains the name of a file in the same format as
2965 that should be read when the shell needs to complete a
2967 The list of possible hostname completions may be changed while the
2969 the next time hostname completion is attempted after the
2973 adds the contents of the new file to the existing list.
2975 <FONT SIZE=-
1><B>HOSTFILE
</B>
2978 is set, but has no value, or does not name a readable file,
2979 <B>bash
</B> attempts to read
2983 to obtain the list of possible hostname completions.
2985 <FONT SIZE=-
1><B>HOSTFILE
</B>
2988 is unset, the hostname list is cleared.
2993 <I>Internal Field Separator
</I>
2996 for word splitting after expansion and to
2997 split lines into words with the
3000 builtin command. The default value is
3001 ``
<space
><tab
><newline
>''.
3002 <DT><B>IGNOREEOF
</B>
3006 action of an interactive shell on receipt of an
3007 <FONT SIZE=-
1><B>EOF
</B>
3010 character as the sole input. If set, the value is the number of
3012 <FONT SIZE=-
1><B>EOF
</B>
3015 characters which must be
3016 typed as the first characters on an input line before
3019 exits. If the variable exists but does not have a numeric value, or
3020 has no value, the default value is
10. If it does not exist,
3021 <FONT SIZE=-
1><B>EOF
</B>
3024 signifies the end of input to the shell.
3028 The filename for the
3031 startup file, overriding the default of
3033 <A HREF=
"file:~/.inputrc"><I>~/.inputrc
</I></A>
3036 <FONT SIZE=-
1><B>READLINE
</B>
3040 <DT><B>INSIDE_EMACS
</B>
3043 If this variable appears in the environment when the shell starts,
3044 <B>bash
</B> assumes that it is running inside an Emacs shell buffer
3045 and may disable line editing, depending on the value of
<B>TERM
</B>.
3049 Used to determine the locale category for any category not specifically
3050 selected with a variable starting with
<B>LC_
</B>.
3054 This variable overrides the value of
3055 <FONT SIZE=-
1><B>LANG
</B>
3059 <B>LC_
</B> variable specifying a locale category.
3060 <DT><B>LC_COLLATE
</B>
3063 This variable determines the collation order used when sorting the
3064 results of pathname expansion, and determines the behavior of range
3065 expressions, equivalence classes, and collating sequences within
3066 pathname expansion and pattern matching.
3070 This variable determines the interpretation of characters and the
3071 behavior of character classes within pathname expansion and pattern
3073 <DT><B>LC_MESSAGES
</B>
3076 This variable determines the locale used to translate double-quoted
3077 strings preceded by a
<B>$
</B>.
3078 <DT><B>LC_NUMERIC
</B>
3081 This variable determines the locale category used for number formatting.
3085 This variable determines the locale category used for data and time
3090 Used by the
<B>select
</B> compound command to determine the column length
3091 for printing selection lists.
3092 Automatically set if the
3095 option is enabled or in an interactive shell upon receipt of a
3096 <FONT SIZE=-
1><B>SIGWINCH
</B>.
3102 If this parameter is set to a file or directory name and the
3103 <FONT SIZE=-
1><B>MAILPATH
</B>
3106 variable is not set,
3109 informs the user of the arrival of mail in the specified file or
3110 Maildir-format directory.
3111 <DT><B>MAILCHECK
</B>
3118 checks for mail. The default is
60 seconds. When it is time to check
3119 for mail, the shell does so before displaying the primary prompt.
3120 If this variable is unset, or set to a value that is not a number
3121 greater than or equal to zero, the shell disables mail checking.
3125 A colon-separated list of filenames to be checked for mail.
3126 The message to be printed when mail arrives in a particular file
3127 may be specified by separating the filename from the message with a `?'.
3128 When used in the text of the message,
<B>$_
</B> expands to the name of
3129 the current mailfile.
3131 <DL COMPACT
><DT><DD>
3134 <B>MAILPATH
</B>=aq/var/mail/bfox?
"You have mail
":~/shell-mail?
"$_ has mail!
"aq
3139 can be configured to supply
3140 a default value for this variable (there is no value by default),
3141 but the location of the user
3142 mail files that it uses is system dependent (e.g., /var/mail/
<B>$USER
</B>).
3148 If set to the value
1,
3151 displays error messages generated by the
3154 builtin command (see
3155 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
3159 <FONT SIZE=-
1><B>OPTERR
</B>
3162 is initialized to
1 each time the shell is invoked or a shell
3167 The search path for commands. It
3168 is a colon-separated list of directories in which
3169 the shell looks for commands (see
3170 <FONT SIZE=-
1><B>COMMAND EXECUTION
</B>
3174 A zero-length (null) directory name in the value of
3175 <FONT SIZE=-
1><B>PATH
</B>
3178 indicates the current directory.
3179 A null directory name may appear as two adjacent colons, or as an initial
3181 The default path is system-dependent,
3182 and is set by the administrator who installs
3187 <TT>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
</TT>.
3190 <DT><B>POSIXLY_CORRECT
</B>
3193 If this variable is in the environment when
<B>bash
</B> starts, the shell
3194 enters
<I>posix mode
</I> before reading the startup files, as if the
3197 invocation option had been supplied. If it is set while the shell is
3198 running,
<B>bash
</B> enables
<I>posix mode
</I>, as if the command
3199 <TT>set -o posix
</TT>
3202 When the shell enters
<I>posix mode
</I>, it sets this variable if it was
3204 <DT><B>PROMPT_COMMAND
</B>
3207 If this variable is set, and is an array,
3208 the value of each set element is executed as a command
3209 prior to issuing each primary prompt.
3210 If this is set but not an array variable,
3211 its value is used as a command to execute instead.
3212 <DT><B>PROMPT_DIRTRIM
</B>
3215 If set to a number greater than zero, the value is used as the number of
3216 trailing directory components to retain when expanding the
<B>\w
</B> and
3217 <B>\W
</B> prompt string escapes (see
3218 <FONT SIZE=-
1><B>PROMPTING
</B>
3221 below). Characters removed are replaced with an ellipsis.
3225 The value of this parameter is expanded (see
3226 <FONT SIZE=-
1><B>PROMPTING
</B>
3229 below) and displayed by interactive shells after reading a command
3230 and before the command is executed.
3234 The value of this parameter is expanded (see
3235 <FONT SIZE=-
1><B>PROMPTING
</B>
3238 below) and used as the primary prompt string. The default value is
3239 ``
<B>\s-\v\$
</B>''.
3243 The value of this parameter is expanded as with
3244 <FONT SIZE=-
1><B>PS1
</B>
3247 and used as the secondary prompt string. The default is
3252 The value of this parameter is used as the prompt for the
3256 <FONT SIZE=-
1><B>SHELL GRAMMAR
</B>
3263 The value of this parameter is expanded as with
3264 <FONT SIZE=-
1><B>PS1
</B>
3267 and the value is printed before each command
3270 displays during an execution trace. The first character of
3271 the expanded value of
3272 <FONT SIZE=-
1><B>PS4
</B>
3275 is replicated multiple times, as necessary, to indicate multiple
3276 levels of indirection. The default is ``
<B>+
</B>''.
3280 This variable expands to the full pathname to the shell.
3281 If it is not set when the shell starts,
3284 assigns to it the full pathname of the current user's login shell.
3285 <DT><B>TIMEFORMAT
</B>
3288 The value of this parameter is used as a format string specifying
3289 how the timing information for pipelines prefixed with the
3292 reserved word should be displayed.
3293 The
<B>%
</B> character introduces an escape sequence that is
3294 expanded to a time value or other information.
3295 The escape sequences and their meanings are as follows; the
3296 braces denote optional portions.
3298 <DL COMPACT
><DT><DD>
3305 <DT><B>%[
</B><I>p
</I>][l]R
3308 The elapsed time in seconds.
3309 <DT><B>%[
</B><I>p
</I>][l]U
3312 The number of CPU seconds spent in user mode.
3313 <DT><B>%[
</B><I>p
</I>][l]S
3316 The number of CPU seconds spent in system mode.
3320 The CPU percentage, computed as (%U + %S) / %R.
3325 The optional
<I>p
</I> is a digit specifying the
<I>precision
</I>,
3326 the number of fractional digits after a decimal point.
3327 A value of
0 causes no decimal point or fraction to be output.
3328 At most three places after the decimal point may be specified;
3329 values of
<I>p
</I> greater than
3 are changed to
3.
3330 If
<I>p
</I> is not specified, the value
3 is used.
3332 The optional
<B>l
</B> specifies a longer format, including
3333 minutes, of the form
<I>MM
</I>m
<I>SS
</I>.
<I>FF
</I>s.
3334 The value of
<I>p
</I> determines whether or not the fraction is
3337 If this variable is not set,
<B>bash
</B> acts as if it had the
3338 value
<B>$aq\nreal\t%
3lR\nuser\t%
3lU\nsys\t%
3lSaq
</B>.
3339 If the value is null, no timing information is displayed.
3340 A trailing newline is added when the format string is displayed.
3345 If set to a value greater than zero,
3346 <FONT SIZE=-
1><B>TMOUT
</B>
3350 default timeout for the
<B>read
</B> builtin.
3351 The
<B>select
</B> command terminates if input does not arrive
3353 <FONT SIZE=-
1><B>TMOUT
</B>
3356 seconds when input is coming from a terminal.
3357 In an interactive shell, the value is interpreted as the
3358 number of seconds to wait for a line of input after issuing the
3362 terminates after waiting for that number of seconds if a complete
3363 line of input does not arrive.
3367 If set,
<B>bash
</B> uses its value as the name of a directory in which
3368 <B>bash
</B> creates temporary files for the shell's use.
3369 <DT><B>auto_resume
</B>
3372 This variable controls how the shell interacts with the user and
3373 job control. If this variable is set, single word simple
3374 commands without redirections are treated as candidates for resumption
3375 of an existing stopped job. There is no ambiguity allowed; if there is
3376 more than one job beginning with the string typed, the job most recently
3377 accessed is selected. The
3380 of a stopped job, in this context, is the command line used to
3385 the string supplied must match the name of a stopped job exactly;
3389 the string supplied needs to match a substring of the name of a
3393 value provides functionality analogous to the
3397 <FONT SIZE=-
1><B>JOB CONTROL
</B>
3400 below). If set to any other value, the supplied string must
3401 be a prefix of a stopped job's name; this provides functionality
3402 analogous to the
<B>%
</B><I>string
</I> job identifier.
3403 <DT><B>histchars
</B>
3406 The two or three characters which control history expansion
3407 and tokenization (see
3408 <FONT SIZE=-
1><B>HISTORY EXPANSION
</B>
3411 below). The first character is the
<I>history expansion
</I> character,
3412 the character which signals the start of a history
3413 expansion, normally `
<B>!
</B>'.
3414 The second character is the
<I>quick substitution
</I>
3415 character, which is used as shorthand for re-running the previous
3416 command entered, substituting one string for another in the command.
3417 The default is `
<B>^
</B>'.
3418 The optional third character is the character
3419 which indicates that the remainder of the line is a comment when found
3420 as the first character of a word, normally `
<B>#
</B>'. The history
3421 comment character causes history substitution to be skipped for the
3422 remaining words on the line. It does not necessarily cause the shell
3423 parser to treat the rest of the line as a comment.
3426 <A NAME=
"lbAX"> </A>
3431 provides one-dimensional indexed and associative array variables.
3432 Any variable may be used as an indexed array; the
3435 builtin will explicitly declare an array.
3437 limit on the size of an array, nor any requirement that members
3438 be indexed or assigned contiguously.
3439 Indexed arrays are referenced using integers (including arithmetic
3440 expressions) and are zero-based; associative arrays are referenced
3441 using arbitrary strings.
3442 Unless otherwise noted, indexed array indices must be non-negative integers.
3445 An indexed array is created automatically if any variable is assigned to
3446 using the syntax
<I>name
</I>[
<I>subscript
</I>]=
<I>value
</I>. The
3449 is treated as an arithmetic expression that must evaluate to a number.
3450 To explicitly declare an indexed array, use
3451 <B>declare -a
</B><I>name
</I>
3454 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
3458 <B>declare -a
</B><I>name
</I>[
<I>subscript
</I>]
3460 is also accepted; the
<I>subscript
</I> is ignored.
3463 Associative arrays are created using
3464 <B>declare -A
</B><I>name
</I>.
3469 specified for an array variable using the
3475 builtins. Each attribute applies to all members of an array.
3478 Arrays are assigned to using compound assignments of the form
3479 <I>name
</I>=
<B>(
</B>value
<I>1</I> ... value
<I>n
</I><B>)
</B>, where each
3480 <I>value
</I> may be of the form [
<I>subscript
</I>]=
<I>string
</I>.
3481 Indexed array assignments do not require anything but
<I>string
</I>.
3482 Each
<I>value
</I> in the list is expanded using all the shell expansions
3483 described below under
3484 <FONT SIZE=-
1><B>EXPANSION
</B>.
3487 When assigning to indexed arrays, if the optional brackets and subscript
3488 are supplied, that index is assigned to;
3489 otherwise the index of the element assigned is the last index assigned
3490 to by the statement plus one. Indexing starts at zero.
3493 When assigning to an associative array, the words in a compound assignment
3494 may be either assignment statements, for which the subscript is required,
3495 or a list of words that is interpreted as a sequence of alternating keys
3497 <I>name
</I>=
<B>(
</B><I>key1 value1 key2 value2
</I> ...
<B>)
</B>.
3498 These are treated identically to
3499 <I>name
</I>=
<B>(
</B> [
<I>key1
</I>]=
<I>value1
</I> [
<I>key2
</I>]=
<I>value2
</I> ...
<B>)
</B>.
3500 The first word in the list determines how the remaining words
3501 are interpreted; all assignments in a list must be of the same type.
3502 When using key/value pairs, the keys may not be missing or empty;
3503 a final missing value is treated like the empty string.
3506 This syntax is also accepted by the
3509 builtin. Individual array elements may be assigned to using the
3510 <I>name
</I>[
<I>subscript
</I>]=
<I>value
</I> syntax introduced above.
3511 When assigning to an indexed array, if
3514 is subscripted by a negative number, that number is
3515 interpreted as relative to one greater than the maximum index of
3516 <I>name
</I>, so negative indices count back from the end of the
3517 array, and an index of -
1 references the last element.
3520 The += operator will append to an array variable when assigning
3521 using the compound assignment syntax; see
3522 <FONT SIZE=-
1><B>PARAMETERS
</B>
3528 Any element of an array may be referenced using
3529 ${
<I>name
</I>[
<I>subscript
</I>]}. The braces are required to avoid
3530 conflicts with pathname expansion. If
3531 <I>subscript
</I> is
<B>@
</B> or
<B>*
</B>, the word expands to
3532 all members of
<I>name
</I>. These subscripts differ only when the
3533 word appears within double quotes. If the word is double-quoted,
3534 ${
<I>name
</I>[*]} expands to a single
3535 word with the value of each array member separated by the first
3537 <FONT SIZE=-
1><B>IFS
</B>
3540 special variable, and ${
<I>name
</I>[@]} expands each element of
3541 <I>name
</I> to a separate word. When there are no array members,
3542 ${
<I>name
</I>[@]} expands to nothing.
3543 If the double-quoted expansion occurs within a word, the expansion of
3544 the first parameter is joined with the beginning part of the original
3545 word, and the expansion of the last parameter is joined with the last
3546 part of the original word.
3547 This is analogous to the expansion
3548 of the special parameters
<B>*
</B> and
<B>@
</B> (see
3549 <B>Special Parameters
</B>
3551 above). ${#
<I>name
</I>[
<I>subscript
</I>]} expands to the length of
3552 ${
<I>name
</I>[
<I>subscript
</I>]}. If
<I>subscript
</I> is
<B>*
</B> or
3553 <B>@
</B>, the expansion is the number of elements in the array.
3557 used to reference an element of an indexed array
3558 evaluates to a number less than zero, it is
3559 interpreted as relative to one greater than the maximum index of the array,
3560 so negative indices count back from the end of the
3561 array, and an index of -
1 references the last element.
3564 Referencing an array variable without a subscript is equivalent to
3565 referencing the array with a subscript of
0.
3566 Any reference to a variable using a valid subscript is legal, and
3569 will create an array if necessary.
3572 An array variable is considered set if a subscript has been assigned a
3573 value. The null string is a valid value.
3576 It is possible to obtain the keys (indices) of an array as well as the values.
3577 ${
<B>!
</B><I>name
</I>[
<I>@
</I>]} and ${
<B>!
</B><I>name
</I>[
<I>*
</I>]}
3578 expand to the indices assigned in array variable
<I>name
</I>.
3579 The treatment when in double quotes is similar to the expansion of the
3580 special parameters
<I>@
</I> and
<I>*
</I> within double quotes.
3586 builtin is used to destroy arrays.
<B>unset
</B> <I>name
</I>[
<I>subscript
</I>]
3587 destroys the array element at index
<I>subscript
</I>,
3588 for both indexed and associative arrays.
3589 Negative subscripts to indexed arrays are interpreted as described above.
3590 Unsetting the last element of an array variable does not unset the variable.
3591 <B>unset
</B> <I>name
</I>, where
<I>name
</I> is an array,
3592 removes the entire array.
3593 <B>unset
</B> <I>name
</I>[
<I>subscript
</I>], where
3594 <I>subscript
</I> is
<B>*
</B> or
<B>@
</B>, behaves differently depending on
3595 whether
<I>name
</I> is an indexed or associative array.
3596 If
<I>name
</I> is an associative array, this unsets the element with
3597 subscript
<B>*
</B> or
<B>@
</B>.
3598 If
<I>name
</I> is an indexed array, unset removes all of the elements but
3599 does not remove the array itself.
3602 When using a variable name with a subscript as an argument to a command,
3603 such as with
<B>unset
</B>, without using the word expansion syntax
3604 described above, the argument is subject to pathname expansion.
3605 If pathname expansion is not desired, the argument should be quoted.
3616 builtins each accept a
3619 option to specify an indexed array and a
3622 option to specify an associative array.
3623 If both options are supplied,
3633 option to assign a list of words read from the standard input
3640 builtins display array values in a way that allows them to be
3641 reused as assignments.
3642 <A NAME=
"lbAY"> </A>
3645 Expansion is performed on the command line after it has been split into
3646 words. There are seven kinds of expansion performed:
3647 <I>brace expansion
</I>,
3649 <I>tilde expansion
</I>,
3651 <I>parameter and variable expansion
</I>,
3653 <I>command substitution
</I>,
3655 <I>arithmetic expansion
</I>,
3657 <I>word splitting
</I>,
3660 <I>pathname expansion
</I>.
3664 The order of expansions is:
3666 tilde expansion, parameter and variable expansion, arithmetic expansion,
3667 and command substitution (done in a left-to-right fashion);
3669 and pathname expansion.
3672 On systems that can support it, there is an additional expansion
3673 available:
<I>process substitution
</I>.
3674 This is performed at the
3675 same time as tilde, parameter, variable, and arithmetic expansion and
3676 command substitution.
3679 After these expansions are performed, quote characters present in the
3680 original word are removed unless they have been quoted themselves
3681 (
<I>quote removal
</I>).
3684 Only brace expansion, word splitting, and pathname expansion
3685 can increase the number of words of the expansion; other expansions
3686 expand a single word to a single word.
3687 The only exceptions to this are the expansions of
3688 "<B>$@
</B>" and
"<B>${
</B><I>name
</I><B>[@]}
</B>",
3689 and, in most cases,
<B>$*
</B> and
<B>${
</B><I>name
</I><B>[*]}
</B>
3690 as explained above (see
3691 <FONT SIZE=-
1><B>PARAMETERS
</B>).
3694 <A NAME=
"lbAZ"> </A>
3695 <H4>Brace Expansion
</H4>
3697 <I>Brace expansion
</I>
3699 is a mechanism by which arbitrary strings
3700 may be generated. This mechanism is similar to
3701 <I>pathname expansion
</I>, but the filenames generated
3702 need not exist. Patterns to be brace expanded take
3703 the form of an optional
3706 followed by either a series of comma-separated strings or
3707 a sequence expression between a pair of braces, followed by
3711 The preamble is prefixed to each string contained
3712 within the braces, and the postscript is then appended
3713 to each resulting string, expanding left to right.
3716 Brace expansions may be nested. The results of each expanded
3717 string are not sorted; left to right order is preserved.
3718 For example, a
<B>{
</B>d,c,b
<B>}
</B>e expands into `ade ace abe'.
3721 A sequence expression takes the form
3722 <B>{
</B><I>x
</I><B>..
</B><I>y
</I><B>[..
</B><I>incr
</I><B>]}
</B>,
3723 where
<I>x
</I> and
<I>y
</I> are either integers or single letters,
3724 and
<I>incr
</I>, an optional increment, is an integer.
3725 When integers are supplied, the expression expands to each number between
3726 <I>x
</I> and
<I>y
</I>, inclusive.
3727 Supplied integers may be prefixed with
<I>0</I> to force each term to have the
3729 When either
<I>x
</I> or y begins with a zero, the shell
3730 attempts to force all generated terms to contain the same number of digits,
3731 zero-padding where necessary.
3732 When letters are supplied, the expression expands to each character
3733 lexicographically between
<I>x
</I> and
<I>y
</I>, inclusive,
3734 using the default C locale.
3735 Note that both
<I>x
</I> and
<I>y
</I> must be of the same type
3736 (integer or letter).
3737 When the increment is supplied, it is used as the difference between
3738 each term. The default increment is
1 or -
1 as appropriate.
3741 Brace expansion is performed before any other expansions,
3742 and any characters special to other expansions are preserved
3743 in the result. It is strictly textual.
3746 does not apply any syntactic interpretation to the context of the
3747 expansion or the text between the braces.
3750 A correctly-formed brace expansion must contain unquoted opening
3751 and closing braces, and at least one unquoted comma or a valid
3752 sequence expression.
3753 Any incorrectly formed brace expansion is left unchanged.
3754 A
<B>{
</B> or
<B>,
</B> may be quoted with a backslash to prevent its
3755 being considered part of a brace expression.
3756 To avoid conflicts with parameter expansion, the string
<B>${
</B>
3757 is not considered eligible for brace expansion, and inhibits brace
3758 expansion until the closing
<B>}
</B>.
3761 This construct is typically used as shorthand when the common
3762 prefix of the strings to be generated is longer than in the
3764 <DL COMPACT
><DT><DD>
3767 mkdir /usr/local/src/bash/{old,new,dist,bugs}
3771 <DL COMPACT
><DT><DD>
3772 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3777 Brace expansion introduces a slight incompatibility with
3778 historical versions of
3783 does not treat opening or closing braces specially when they
3784 appear as part of a word, and preserves them in the output.
3787 removes braces from words as a consequence of brace
3788 expansion. For example, a word entered to
3792 appears identically in the output. The same word is
3799 If strict compatibility with
3808 option or disable brace expansion with the
3815 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
3819 <A NAME=
"lbBA"> </A>
3820 <H4>Tilde Expansion
</H4>
3822 If a word begins with an unquoted tilde character (`
<B>~
</B>'), all of
3823 the characters preceding the first unquoted slash (or all characters,
3824 if there is no unquoted slash) are considered a
<I>tilde-prefix
</I>.
3825 If none of the characters in the tilde-prefix are quoted, the
3826 characters in the tilde-prefix following the tilde are treated as a
3827 possible
<I>login name
</I>.
3828 If this login name is the null string, the tilde is replaced with the
3829 value of the shell parameter
3830 <FONT SIZE=-
1><B>HOME
</B>.
3834 <FONT SIZE=-
1><B>HOME
</B>
3837 is unset, the home directory of the user executing the shell is
3838 substituted instead.
3839 Otherwise, the tilde-prefix is replaced with the home directory
3840 associated with the specified login name.
3843 If the tilde-prefix is a `~+', the value of the shell variable
3844 <FONT SIZE=-
1><B>PWD
</B>
3847 replaces the tilde-prefix.
3848 If the tilde-prefix is a `~-', the value of the shell variable
3849 <FONT SIZE=-
1><B>OLDPWD
</B>,
3852 if it is set, is substituted.
3853 If the characters following the tilde in the tilde-prefix consist
3854 of a number
<I>N
</I>, optionally prefixed
3855 by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3856 element from the directory stack, as it would be displayed by the
3859 builtin invoked with the tilde-prefix as an argument.
3860 If the characters following the tilde in the tilde-prefix consist of a
3861 number without a leading `+' or `-', `+' is assumed.
3864 If the login name is invalid, or the tilde expansion fails, the word
3868 Each variable assignment is checked for unquoted tilde-prefixes immediately
3875 In these cases, tilde expansion is also performed.
3876 Consequently, one may use filenames with tildes in assignments to
3877 <FONT SIZE=-
1><B>PATH
</B>,
3880 <FONT SIZE=-
1><B>MAILPATH
</B>,
3884 <FONT SIZE=-
1><B>CDPATH
</B>,
3887 and the shell assigns the expanded value.
3890 Bash also performs tilde expansion on words satisfying the conditions of
3891 variable assignments (as described above under
3892 <FONT SIZE=-
1><B>PARAMETERS
</B>)
3895 when they appear as arguments to simple commands.
3896 Bash does not do this, except for the
<I>declaration
</I> commands listed
3897 above, when in
<I>posix mode
</I>.
3898 <A NAME=
"lbBB"> </A>
3899 <H4>Parameter Expansion
</H4>
3901 The `
<B>$
</B>' character introduces parameter expansion,
3902 command substitution, or arithmetic expansion. The parameter name
3903 or symbol to be expanded may be enclosed in braces, which
3904 are optional but serve to protect the variable to be expanded from
3905 characters immediately following it which could be
3906 interpreted as part of the name.
3909 When braces are used, the matching ending brace is the first `
<B>}
</B>'
3910 not escaped by a backslash or within a quoted string, and not within an
3911 embedded arithmetic expansion, command substitution, or parameter
3917 <DT>${
<I>parameter
</I>}
<DD>
3918 The value of
<I>parameter
</I> is substituted. The braces are required
3922 is a positional parameter with more than one digit,
3926 is followed by a character which is not to be
3927 interpreted as part of its name.
3928 The
<I>parameter
</I> is a shell parameter as described above
3929 <B>PARAMETERS
</B>) or an array reference (
<B>Arrays
</B>).
3934 If the first character of
<I>parameter
</I> is an exclamation point (
<B>!
</B>),
3935 and
<I>parameter
</I> is not a
<I>nameref
</I>,
3936 it introduces a level of indirection.
3937 <B>Bash
</B> uses the value formed by expanding the rest of
3938 <I>parameter
</I> as the new
<I>parameter
</I>; this is then
3939 expanded and that value is used in the rest of the expansion, rather
3940 than the expansion of the original
<I>parameter
</I>.
3941 This is known as
<I>indirect expansion
</I>.
3942 The value is subject to tilde expansion,
3943 parameter expansion, command substitution, and arithmetic expansion.
3944 If
<I>parameter
</I> is a nameref, this expands to the name of the
3945 parameter referenced by
<I>parameter
</I> instead of performing the
3946 complete indirect expansion.
3947 The exceptions to this are the expansions of ${
<B>!
</B><I>prefix
</I><B>*
</B>} and
3948 ${
<B>!
</B><I>name
</I>[
<I>@
</I>]} described below.
3949 The exclamation point must immediately follow the left brace in order to
3950 introduce indirection.
3953 In each of the cases below,
<I>word
</I> is subject to tilde expansion,
3954 parameter expansion, command substitution, and arithmetic expansion.
3957 When not performing substring expansion, using the forms documented below
3959 <B>bash
</B> tests for a parameter that is unset or null. Omitting the colon
3960 results in a test only for a parameter that is unset.
3965 <DT>${
<I>parameter
</I><B>:-
</B><I>word
</I>}
<DD>
3966 <B>Use Default Values
</B>. If
3969 is unset or null, the expansion of
3972 is substituted. Otherwise, the value of
3976 <DT>${
<I>parameter
</I><B>:=
</B><I>word
</I>}
<DD>
3977 <B>Assign Default Values
</B>.
3981 is unset or null, the expansion of
3990 is then substituted. Positional parameters and special parameters may
3991 not be assigned to in this way.
3992 <DT>${
<I>parameter
</I><B>:?
</B><I>word
</I>}
<DD>
3993 <B>Display Error if Null or Unset
</B>.
3997 is null or unset, the expansion of
<I>word
</I> (or a message to that effect
4001 is not present) is written to the standard error and the shell, if it
4002 is not interactive, exits. Otherwise, the value of
<I>parameter
</I> is
4004 <DT>${
<I>parameter
</I><B>:+
</B><I>word
</I>}
<DD>
4005 <B>Use Alternate Value
</B>.
4009 is null or unset, nothing is substituted, otherwise the expansion of
4013 <DT>${
<I>parameter
</I><B>:
</B><I>offset
</I>}
<DD>
4015 <DT>${
<I>parameter
</I><B>:
</B><I>offset
</I><B>:
</B><I>length
</I>}
<DD>
4017 <B>Substring Expansion
</B>.
4018 Expands to up to
<I>length
</I> characters of the value of
<I>parameter
</I>
4019 starting at the character specified by
<I>offset
</I>.
4020 If
<I>parameter
</I> is
<B>@
</B> or
<B>*
</B>, an indexed array subscripted by
4021 <B>@
</B> or
<B>*
</B>, or an associative array name, the results differ as
4023 If
<I>length
</I> is omitted, expands to the substring of the value of
4024 <I>parameter
</I> starting at the character specified by
<I>offset
</I>
4025 and extending to the end of the value.
4026 <I>length
</I> and
<I>offset
</I> are arithmetic expressions (see
4027 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>
4032 If
<I>offset
</I> evaluates to a number less than zero, the value
4033 is used as an offset in characters
4034 from the end of the value of
<I>parameter
</I>.
4035 If
<I>length
</I> evaluates to a number less than zero,
4036 it is interpreted as an offset in characters
4037 from the end of the value of
<I>parameter
</I> rather than
4038 a number of characters, and the expansion is the characters between
4039 <I>offset
</I> and that result.
4040 Note that a negative offset must be separated from the colon by at least
4041 one space to avoid being confused with the
<B>:-
</B> expansion.
4043 If
<I>parameter
</I> is
<B>@
</B> or
<B>*
</B>, the result is
<I>length
</I>
4044 positional parameters beginning at
<I>offset
</I>.
4045 A negative
<I>offset
</I> is taken relative to one greater than the greatest
4046 positional parameter, so an offset of -
1 evaluates to the last positional
4048 It is an expansion error if
<I>length
</I> evaluates to a number less than
4051 If
<I>parameter
</I> is an indexed array name subscripted by @ or *,
4052 the result is the
<I>length
</I>
4053 members of the array beginning with ${
<I>parameter
</I>[
<I>offset
</I>]}.
4054 A negative
<I>offset
</I> is taken relative to one greater than the maximum
4055 index of the specified array.
4056 It is an expansion error if
<I>length
</I> evaluates to a number less than
4059 Substring expansion applied to an associative array produces undefined
4062 Substring indexing is zero-based unless the positional parameters
4063 are used, in which case the indexing starts at
1 by default.
4064 If
<I>offset
</I> is
0, and the positional parameters are used,
<B>$
0</B> is
4065 prefixed to the list.
4066 <DT>${
<B>!
</B><I>prefix
</I><B>*
</B>}
<DD>
4068 <DT>${
<B>!
</B><I>prefix
</I><B>@
</B>}
<DD>
4070 <B>Names matching prefix
</B>.
4071 Expands to the names of variables whose names begin with
<I>prefix
</I>,
4072 separated by the first character of the
4073 <FONT SIZE=-
1><B>IFS
</B>
4077 When
<I>@
</I> is used and the expansion appears within double quotes, each
4078 variable name expands to a separate word.
4079 <DT>${
<B>!
</B><I>name
</I>[
<I>@
</I>]}
<DD>
4081 <DT>${
<B>!
</B><I>name
</I>[
<I>*
</I>]}
<DD>
4083 <B>List of array keys
</B>.
4084 If
<I>name
</I> is an array variable, expands to the list of array indices
4085 (keys) assigned in
<I>name
</I>.
4086 If
<I>name
</I> is not an array, expands to
0 if
<I>name
</I> is set and null
4088 When
<I>@
</I> is used and the expansion appears within double quotes, each
4089 key expands to a separate word.
4090 <DT>${
<B>#
</B><I>parameter
</I>}
<DD>
4091 <B>Parameter length
</B>.
4092 The length in characters of the value of
<I>parameter
</I> is substituted.
4102 the value substituted is the number of positional parameters.
4106 is an array name subscripted by
4112 the value substituted is the number of elements in the array.
4116 is an indexed array name subscripted by a negative number, that number is
4117 interpreted as relative to one greater than the maximum index of
4118 <I>parameter
</I>, so negative indices count back from the end of the
4119 array, and an index of -
1 references the last element.
4120 <DT>${
<I>parameter
</I><B>#
</B><I>word
</I>}
<DD>
4122 <DT>${
<I>parameter
</I><B>##
</B><I>word
</I>}
<DD>
4124 <B>Remove matching prefix pattern
</B>.
4128 is expanded to produce a pattern just as in pathname
4129 expansion, and matched against the expanded value of
4132 using the rules described under
4133 <B>Pattern Matching
</B>
4136 If the pattern matches the beginning of
4140 then the result of the expansion is the expanded value of
4143 with the shortest matching pattern (the ``
<B>#
</B>'' case) or the
4144 longest matching pattern (the ``
<B>##
</B>'' case) deleted.
4154 the pattern removal operation is applied to each positional
4155 parameter in turn, and the expansion is the resultant list.
4159 is an array variable subscripted with
4165 the pattern removal operation is applied to each member of the
4166 array in turn, and the expansion is the resultant list.
4167 <DT>${
<I>parameter
</I><B>%
</B><I>word
</I>}
<DD>
4169 <DT>${
<I>parameter
</I><B>%%
</B><I>word
</I>}
<DD>
4171 <B>Remove matching suffix pattern
</B>.
4172 The
<I>word
</I> is expanded to produce a pattern just as in
4173 pathname expansion, and matched against the expanded value of
4176 using the rules described under
4177 <B>Pattern Matching
</B>
4180 If the pattern matches a trailing portion of the expanded value of
4183 then the result of the expansion is the expanded value of
4186 with the shortest matching pattern (the ``
<B>%
</B>'' case) or the
4187 longest matching pattern (the ``
<B>%%
</B>'' case) deleted.
4197 the pattern removal operation is applied to each positional
4198 parameter in turn, and the expansion is the resultant list.
4202 is an array variable subscripted with
4208 the pattern removal operation is applied to each member of the
4209 array in turn, and the expansion is the resultant list.
4210 <DT>${
<I>parameter
</I><B>/
</B><I>pattern
</I><B>/
</B><I>string
</I>}
<DD>
4212 <DT>${
<I>parameter
</I><B>//
</B><I>pattern
</I><B>/
</B><I>string
</I>}
<DD>
4213 <DT>${
<I>parameter
</I><B>/#
</B><I>pattern
</I><B>/
</B><I>string
</I>}
<DD>
4214 <DT>${
<I>parameter
</I><B>/%
</B><I>pattern
</I><B>/
</B><I>string
</I>}
<DD>
4216 <B>Pattern substitution
</B>.
4217 The
<I>pattern
</I> is expanded to produce a pattern just as in
4219 <I>Parameter
</I> is expanded and the longest match of
<I>pattern
</I>
4220 against its value is replaced with
<I>string
</I>.
4221 <I>string
</I> undergoes tilde expansion, parameter and variable expansion,
4222 arithmetic expansion, command and process substitution, and quote removal.
4223 The match is performed using the rules described under
4224 <B>Pattern Matching
</B>
4227 In the first form above, only the first match is replaced.
4228 If there are two slashes separating
<I>parameter
</I> and
<I>pattern
</I>
4229 (the second form above), all matches of
<I>pattern
</I> are
4230 replaced with
<I>string
</I>.
4231 If
<I>pattern
</I> is preceded by
<B>#
</B> (the third form above),
4232 it must match at the beginning of the expanded value of
<I>parameter
</I>.
4233 If
<I>pattern
</I> is preceded by
<B>%
</B> (the fourth form above),
4234 it must match at the end of the expanded value of
<I>parameter
</I>.
4235 If the expansion of
<I>string
</I> is null,
4236 matches of
<I>pattern
</I> are deleted.
4237 If
<I>string
</I> is null,
4238 matches of
<I>pattern
</I> are deleted
4239 and the
<B>/
</B> following
<I>pattern
</I> may be omitted.
4241 If the
<B>patsub_replacement
</B> shell option is enabled using
<B>shopt
</B>,
4242 any unquoted instances of
<B>&</B> in
<I>string
</I> are replaced with the
4243 matching portion of
<I>pattern
</I>.
4245 Quoting any part of
<I>string
</I> inhibits replacement in the
4246 expansion of the quoted portion, including replacement strings stored
4248 Backslash will escape
<B>&</B> in
<I>string
</I>; the backslash is removed
4249 in order to permit a literal
<B>&</B> in the replacement string.
4250 Backslash can also be used to escape a backslash;
<B>\\
</B> results in
4251 a literal backslash in the replacement.
4252 Users should take care if
<I>string
</I> is double-quoted to avoid
4253 unwanted interactions between the backslash and double-quoting, since
4254 backslash has special meaning within double quotes.
4255 Pattern substitution performs the check for unquoted
<B>&</B> after
4256 expanding
<I>string
</I>;
4257 shell programmers should quote any occurrences of
<B>&</B>
4258 they want to be taken literally in the replacement
4259 and ensure any instances of
<B>&</B> they want to be replaced are unquoted.
4264 shell option is enabled, the match is performed without regard to the case
4265 of alphabetic characters.
4275 the substitution operation is applied to each positional
4276 parameter in turn, and the expansion is the resultant list.
4280 is an array variable subscripted with
4286 the substitution operation is applied to each member of the
4287 array in turn, and the expansion is the resultant list.
4288 <DT>${
<I>parameter
</I><B>^
</B><I>pattern
</I>}
<DD>
4290 <DT>${
<I>parameter
</I><B>^^
</B><I>pattern
</I>}
<DD>
4291 <DT>${
<I>parameter
</I><B>,
</B><I>pattern
</I>}
<DD>
4292 <DT>${
<I>parameter
</I><B>,,
</B><I>pattern
</I>}
<DD>
4294 <B>Case modification
</B>.
4295 This expansion modifies the case of alphabetic characters in
<I>parameter
</I>.
4296 The
<I>pattern
</I> is expanded to produce a pattern just as in
4298 Each character in the expanded value of
<I>parameter
</I> is tested against
4299 <I>pattern
</I>, and, if it matches the pattern, its case is converted.
4300 The pattern should not attempt to match more than one character.
4301 The
<B>^
</B> operator converts lowercase letters matching
<I>pattern
</I>
4302 to uppercase; the
<B>,
</B> operator converts matching uppercase letters
4304 The
<B>^^
</B> and
<B>,,
</B> expansions convert each matched character in the
4305 expanded value; the
<B>^
</B> and
<B>,
</B> expansions match and convert only
4306 the first character in the expanded value.
4307 If
<I>pattern
</I> is omitted, it is treated like a
<B>?
</B>, which matches
4318 the case modification operation is applied to each positional
4319 parameter in turn, and the expansion is the resultant list.
4323 is an array variable subscripted with
4329 the case modification operation is applied to each member of the
4330 array in turn, and the expansion is the resultant list.
4331 <DT>${
<I>parameter
</I><B>@
</B><I>operator
</I>}
<DD>
4332 <B>Parameter transformation
</B>.
4333 The expansion is either a transformation of the value of
<I>parameter
</I>
4334 or information about
<I>parameter
</I> itself, depending on the value of
4335 <I>operator
</I>. Each
<I>operator
</I> is a single letter:
4337 <DL COMPACT
><DT><DD>
4343 The expansion is a string that is the value of
<I>parameter
</I> with lowercase
4344 alphabetic characters converted to uppercase.
4348 The expansion is a string that is the value of
<I>parameter
</I> with the first
4349 character converted to uppercase, if it is alphabetic.
4353 The expansion is a string that is the value of
<I>parameter
</I> with uppercase
4354 alphabetic characters converted to lowercase.
4358 The expansion is a string that is the value of
<I>parameter
</I> quoted in a
4359 format that can be reused as input.
4363 The expansion is a string that is the value of
<I>parameter
</I> with backslash
4364 escape sequences expanded as with the
<B>$aq...aq
</B> quoting mechanism.
4368 The expansion is a string that is the result of expanding the value of
4369 <I>parameter
</I> as if it were a prompt string (see
<B>PROMPTING
</B> below).
4373 The expansion is a string in the form of
4374 an assignment statement or
<B>declare
</B> command that, if
4375 evaluated, will recreate
<I>parameter
</I> with its attributes and value.
4379 Produces a possibly-quoted version of the value of
<I>parameter
</I>,
4380 except that it prints the values of
4381 indexed and associative arrays as a sequence of quoted key-value pairs
4382 (see
<B>Arrays
</B> above).
4386 The expansion is a string consisting of flag values representing
4387 <I>parameter
</I>'s attributes.
4391 Like the K transformation, but expands the keys and values of
4392 indexed and associative arrays to separate words after word splitting.
4406 the operation is applied to each positional
4407 parameter in turn, and the expansion is the resultant list.
4411 is an array variable subscripted with
4417 the operation is applied to each member of the
4418 array in turn, and the expansion is the resultant list.
4420 The result of the expansion is subject to word splitting and pathname
4421 expansion as described below.
4425 <A NAME=
"lbBC"> </A>
4426 <H4>Command Substitution
</H4>
4428 <I>Command substitution
</I> allows the output of a command to replace
4429 the command name. There are two forms:
4430 <DL COMPACT
><DT><DD>
4433 <B>$(
</B><I>command
</I><B>)
</B>
4437 <DL COMPACT
><DT><DD>
4438 <B>`
</B><I>command
</I><B>`
</B>
4445 performs the expansion by executing
<I>command
</I> in a subshell environment
4446 and replacing the command substitution with the standard output of the
4447 command, with any trailing newlines deleted.
4448 Embedded newlines are not deleted, but they may be removed during
4450 The command substitution
<B>$(cat
</B><I>file
</I>) can be replaced by
4451 the equivalent but faster
<B>$(
< </B><I>file
</I>).
4454 When the old-style backquote form of substitution is used,
4455 backslash retains its literal meaning except when followed by
4463 The first backquote not preceded by a backslash terminates the
4464 command substitution.
4465 When using the $(
<I>command
</I>) form, all characters between the
4466 parentheses make up the command; none are treated specially.
4469 Command substitutions may be nested. To nest when using the backquoted form,
4470 escape the inner backquotes with backslashes.
4473 If the substitution appears within double quotes, word splitting and
4474 pathname expansion are not performed on the results.
4475 <A NAME=
"lbBD"> </A>
4476 <H4>Arithmetic Expansion
</H4>
4478 Arithmetic expansion allows the evaluation of an arithmetic expression
4479 and the substitution of the result. The format for arithmetic expansion is:
4480 <DL COMPACT
><DT><DD>
4483 <B>$((
</B><I>expression
</I><B>))
</B>
4491 undergoes the same expansions
4492 as if it were within double quotes,
4493 but double quote characters in
<I>expression
</I> are not treated specially
4495 All tokens in the expression undergo parameter and variable expansion,
4496 command substitution, and quote removal.
4497 The result is treated as the arithmetic expression to be evaluated.
4498 Arithmetic expansions may be nested.
4501 The evaluation is performed according to the rules listed below under
4502 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>.
4511 prints a message indicating failure and no substitution occurs.
4512 <A NAME=
"lbBE"> </A>
4513 <H4>Process Substitution
</H4>
4515 <I>Process substitution
</I> allows a process's input or output to be
4516 referred to using a filename.
4517 It takes the form of
4518 <B><(
</B><I>list
</I><B>)
</B>
4520 <B>>(
</B><I>list
</I><B>)
</B>.
4521 The process
<I>list
</I> is run asynchronously, and its input or output
4522 appears as a filename.
4524 passed as an argument to the current command as the result of the
4526 If the
<B>>(
</B><I>list
</I><B>)
</B> form is used, writing to
4527 the file will provide input for
<I>list
</I>. If the
4528 <B><(
</B><I>list
</I><B>)
</B> form is used, the file passed as an
4529 argument should be read to obtain the output of
<I>list
</I>.
4530 Process substitution is supported on systems that support named
4531 pipes (
<I>FIFOs
</I>) or the
<B>/dev/fd
</B> method of naming open files.
4534 When available, process substitution is performed
4535 simultaneously with parameter and variable expansion,
4536 command substitution,
4537 and arithmetic expansion.
4538 <A NAME=
"lbBF"> </A>
4539 <H4>Word Splitting
</H4>
4541 The shell scans the results of
4542 parameter expansion,
4543 command substitution,
4545 arithmetic expansion
4546 that did not occur within double quotes for
4547 <I>word splitting
</I>.
4551 The shell treats each character of
4552 <FONT SIZE=-
1><B>IFS
</B>
4555 as a delimiter, and splits the results of the other
4556 expansions into words using these characters as field terminators.
4558 <FONT SIZE=-
1><B>IFS
</B>
4563 <B><space
><tab
><newline
></B>,
4567 <B><space
></B>,
4572 <B><newline
></B>
4574 at the beginning and end of the results of the previous
4575 expansions are ignored, and
4577 <FONT SIZE=-
1><B>IFS
</B>
4580 characters not at the beginning or end serves to delimit words.
4582 <FONT SIZE=-
1><B>IFS
</B>
4585 has a value other than the default, then sequences of
4586 the whitespace characters
4594 are ignored at the beginning and end of the
4595 word, as long as the whitespace character is in the
4597 <FONT SIZE=-
1><B>IFS
</B>
4601 <FONT SIZE=-
1><B>IFS
</B>
4604 whitespace character).
4606 <FONT SIZE=-
1><B>IFS
</B>
4610 <FONT SIZE=-
1><B>IFS
</B>
4613 whitespace, along with any adjacent
4614 <FONT SIZE=-
1><B>IFS
</B>
4617 whitespace characters, delimits a field.
4619 <FONT SIZE=-
1><B>IFS
</B>
4622 whitespace characters is also treated as a delimiter.
4624 <FONT SIZE=-
1><B>IFS
</B>
4627 is null, no word splitting occurs.
4630 Explicit null arguments (
<B>""</B> or
<B>aqaq
</B>) are retained
4631 and passed to commands as empty strings.
4632 Unquoted implicit null arguments, resulting from the expansion of
4633 parameters that have no values, are removed.
4634 If a parameter with no value is expanded within double quotes, a
4635 null argument results and is retained
4636 and passed to a command as an empty string.
4637 When a quoted null argument appears as part of a word whose expansion is
4638 non-null, the null argument is removed.
4640 <TT>-daqaq
</TT> becomes
<TT>-d
</TT> after word splitting and
4641 null argument removal.
4644 Note that if no expansion occurs, no splitting
4646 <A NAME=
"lbBG"> </A>
4647 <H4>Pathname Expansion
</H4>
4649 After word splitting,
4653 option has been set,
4656 scans each word for the characters
4664 If one of these characters appears, and is not quoted, then the word is
4668 and replaced with an alphabetically sorted list of
4669 filenames matching the pattern
4671 <FONT SIZE=-
1><B>Pattern Matching
</B>
4675 If no matching filenames are found,
4676 and the shell option
4679 is not enabled, the word is left unchanged.
4683 option is set, and no matches are found,
4684 the word is removed.
4688 shell option is set, and no matches are found, an error message
4689 is printed and the command is not executed.
4693 is enabled, the match is performed without regard to the case
4694 of alphabetic characters.
4695 When a pattern is used for pathname expansion,
4699 at the start of a name or immediately following a slash
4700 must be matched explicitly, unless the shell option
4704 In order to match the filenames
4710 the pattern must begin with ``.'' (for example, ``.?''),
4718 shell option is enabled, the filenames
4724 are never matched, even if the pattern begins with a
4727 When not matching pathnames, the
4730 character is not treated specially.
4731 When matching a pathname, the slash character must always be
4732 matched explicitly by a slash in the pattern, but in other matching
4733 contexts it can be matched by a special pattern character as described
4735 <FONT SIZE=-
1><B>Pattern Matching
</B>.
4738 See the description of
4742 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
4745 for a description of the
4750 <B>globskipdots
</B>,
4761 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4764 shell variable may be used to restrict the set of file names matching a
4768 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4771 is set, each matching file name that also matches one of the patterns in
4772 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4775 is removed from the list of matches.
4776 If the
<B>nocaseglob
</B> option is set, the matching against the patterns in
4777 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4780 is performed without regard to case.
4787 are always ignored when
4788 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4791 is set and not null. However, setting
4792 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4795 to a non-null value has the effect of enabling the
4798 shell option, so all other filenames beginning with a
4802 To get the old behavior of ignoring filenames beginning with a
4808 one of the patterns in
4809 <FONT SIZE=-
1><B>GLOBIGNORE
</B>.
4815 option is disabled when
4816 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
4820 The pattern matching honors the setting of the
<B>extglob
</B> shell
4824 <B>Pattern Matching
</B>
4827 Any character that appears in a pattern, other than the special pattern
4828 characters described below, matches itself. The NUL character may not
4829 occur in a pattern. A backslash escapes the following character; the
4830 escaping backslash is discarded when matching.
4831 The special pattern characters must be quoted if
4832 they are to be matched literally.
4835 The special pattern characters have the following meanings:
4839 <DL COMPACT
><DT><DD>
4844 Matches any string, including the null string.
4845 When the
<B>globstar
</B> shell option is enabled, and
<B>*
</B> is used in
4846 a pathname expansion context, two adjacent
<B>*
</B>s used as a single
4847 pattern will match all files and zero or more directories and
4849 If followed by a
<B>/
</B>, two adjacent
<B>*
</B>s will match only directories
4854 Matches any single character.
4858 Matches any one of the enclosed characters. A pair of characters
4859 separated by a hyphen denotes a
4860 <I>range expression
</I>;
4861 any character that falls between those two characters, inclusive,
4862 using the current locale's collating sequence and character set,
4863 is matched. If the first character following the
4872 then any character not enclosed is matched.
4873 The sorting order of characters in range expressions,
4874 and the characters included in the range,
4876 the current locale and the values of the
4877 <FONT SIZE=-
1><B>LC_COLLATE
</B>
4881 <FONT SIZE=-
1><B>LC_ALL
</B>
4884 shell variables, if set.
4885 To obtain the traditional interpretation of range expressions, where
4898 <B>globasciiranges
</B>
4904 may be matched by including it as the first or last character
4909 may be matched by including it as the first character
4922 <I>character classes
</I> can be specified using the syntax
4923 <B>[:
</B><I>class
</I><B>:]
</B>, where
<I>class
</I> is one of the
4924 following classes defined in the POSIX standard:
4928 <DL COMPACT
><DT><DD>
4932 alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
4935 A character class matches any character belonging to that class.
4936 The
<B>word
</B> character class matches letters, digits, and the character _.
4948 an
<I>equivalence class
</I> can be specified using the syntax
4949 <B>[=
</B><I>c
</I><B>=]
</B>, which matches all characters with the
4950 same collation weight (as defined by the current locale) as
4951 the character
<I>c
</I>.
4963 the syntax
<B>[.
</B><I>symbol
</I><B>.]
</B> matches the collating symbol
4972 If the
<B>extglob
</B> shell option is enabled using the
<B>shopt
</B>
4973 builtin, the shell recognizes several extended pattern matching operators.
4974 In the following description, a
<I>pattern-list
</I> is a list of one
4975 or more patterns separated by a
<B>|
</B>.
4976 Composite patterns may be formed using one or more of the following
4980 <DL COMPACT
><DT><DD>
4982 <DT><B>?(
</B><I>pattern-list
</I><B>)
</B><DD>
4983 Matches zero or one occurrence of the given patterns
4984 <DT><B>*(
</B><I>pattern-list
</I><B>)
</B><DD>
4985 Matches zero or more occurrences of the given patterns
4986 <DT><B>+(
</B><I>pattern-list
</I><B>)
</B><DD>
4987 Matches one or more occurrences of the given patterns
4988 <DT><B>@(
</B><I>pattern-list
</I><B>)
</B><DD>
4989 Matches one of the given patterns
4990 <DT><B>!(
</B><I>pattern-list
</I><B>)
</B><DD>
4991 Matches anything except one of the given patterns
4997 The
<B>extglob
</B> option changes the behavior of the parser, since the
4998 parentheses are normally treated as operators with syntactic meaning.
4999 To ensure that extended matching patterns are parsed correctly, make sure
5000 that
<B>extglob
</B> is enabled before parsing constructs containing the
5001 patterns, including shell functions and command substitutions.
5004 When matching filenames, the
<B>dotglob
</B> shell option determines
5005 the set of filenames that are tested:
5006 when
<B>dotglob
</B> is enabled, the set of filenames includes all files
5007 beginning with ``.'', but ``.'' and ``..'' must be matched by a
5008 pattern or sub-pattern that begins with a dot;
5009 when it is disabled, the set does not
5010 include any filenames beginning with ``.'' unless the pattern
5011 or sub-pattern begins with a ``.''.
5012 As above, ``.'' only has a special meaning when matching filenames.
5015 Complicated extended pattern matching against long strings is slow,
5016 especially when the patterns contain alternations and the strings
5017 contain multiple matches.
5018 Using separate matches against shorter strings, or using arrays of
5019 strings instead of a single long string, may be faster.
5020 <A NAME=
"lbBH"> </A>
5021 <H4>Quote Removal
</H4>
5023 After the preceding expansions, all unquoted occurrences of the
5029 and
<B>"</B> that did not result from one of the above
5030 expansions are removed.
5031 <A NAME=
"lbBI"> </A>
5032 <H3>REDIRECTION
</H3>
5034 Before a command is executed, its input and output
5038 using a special notation interpreted by the shell.
5039 <I>Redirection
</I> allows commands' file handles to be
5040 duplicated, opened, closed,
5041 made to refer to different files,
5042 and can change the files the command reads from and writes to.
5043 Redirection may also be used to modify file handles in the
5044 current shell execution environment.
5045 The following redirection
5046 operators may precede or appear anywhere within a
5047 <I>simple command
</I>
5052 Redirections are processed in the order they appear, from
5056 Each redirection that may be preceded by a file descriptor number
5057 may instead be preceded by a word of the form {
<I>varname
</I>}.
5058 In this case, for each redirection operator except
5059 >&- and
<&-, the shell will allocate a file descriptor greater
5060 than or equal to
10 and assign it to
<I>varname
</I>.
5061 If
>&- or
<&- is preceded
5062 by {
<I>varname
</I>}, the value of
<I>varname
</I> defines the file
5063 descriptor to close.
5064 If {
<I>varname
</I>} is supplied, the redirection persists beyond
5065 the scope of the command, allowing the shell programmer to manage
5066 the file descriptor's lifetime manually.
5067 The
<B>varredir_close
</B> shell option manages this behavior.
5070 In the following descriptions, if the file descriptor number is
5071 omitted, and the first character of the redirection operator is
5074 the redirection refers to the standard input (file descriptor
5075 0). If the first character of the redirection operator is
5078 the redirection refers to the standard output (file descriptor
5082 The word following the redirection operator in the following
5083 descriptions, unless otherwise noted, is subjected to
5084 brace expansion, tilde expansion, parameter and variable expansion,
5085 command substitution, arithmetic expansion, quote removal,
5086 pathname expansion, and word splitting.
5087 If it expands to more than one word,
5093 Note that the order of redirections is significant. For example,
5095 <DL COMPACT
><DT><DD>
5098 ls
<B>></B> dirlist
2<B>>&</B>1
5103 directs both standard output and standard error to the file
5107 <DL COMPACT
><DT><DD>
5110 ls
2<B>>&</B>1 <B>></B> dirlist
5115 directs only the standard output to file
5118 because the standard error was duplicated from the standard output
5119 before the standard output was redirected to
5124 <B>Bash
</B> handles several filenames specially when they are used in
5125 redirections, as described in the following table.
5126 If the operating system on which
<B>bash
</B> is running provides these
5127 special files, bash will use them; otherwise it will emulate them
5128 internally with the behavior described below.
5129 <DL COMPACT
><DT><DD>
5134 <DT><B>/dev/fd/
</B><I>fd
</I>
5137 If
<I>fd
</I> is a valid integer, file descriptor
<I>fd
</I> is duplicated.
5138 <DT><B>/dev/stdin
</B>
5141 File descriptor
0 is duplicated.
5142 <DT><B>/dev/stdout
</B>
5145 File descriptor
1 is duplicated.
5146 <DT><B>/dev/stderr
</B>
5149 File descriptor
2 is duplicated.
5150 <DT><B>/dev/tcp/
</B><I>host
</I>/
<I>port
</I>
5153 If
<I>host
</I> is a valid hostname or Internet address, and
<I>port
</I>
5154 is an integer port number or service name,
<B>bash
</B> attempts to open
5155 the corresponding TCP socket.
5156 <DT><B>/dev/udp/
</B><I>host
</I>/
<I>port
</I>
5159 If
<I>host
</I> is a valid hostname or Internet address, and
<I>port
</I>
5160 is an integer port number or service name,
<B>bash
</B> attempts to open
5161 the corresponding UDP socket.
5167 A failure to open or create a file causes the redirection to fail.
5170 Redirections using file descriptors greater than
9 should be used with
5171 care, as they may conflict with file descriptors the shell uses
5173 <A NAME=
"lbBJ"> </A>
5174 <H4>Redirecting Input
</H4>
5176 Redirection of input causes the file whose name results from
5180 to be opened for reading on file descriptor
5183 or the standard input (file descriptor
0) if
5189 The general format for redirecting input is:
5190 <DL COMPACT
><DT><DD>
5193 [
<I>n
</I>]
<B><</B><I>word
</I>
5196 <A NAME=
"lbBK"> </A>
5197 <H4>Redirecting Output
</H4>
5199 Redirection of output causes the file whose name results from
5203 to be opened for writing on file descriptor
5206 or the standard output (file descriptor
1) if
5209 is not specified. If the file does not exist it is created;
5210 if it does exist it is truncated to zero size.
5213 The general format for redirecting output is:
5214 <DL COMPACT
><DT><DD>
5217 [
<I>n
</I>]
<B>></B><I>word
</I>
5222 If the redirection operator is
5231 builtin has been enabled, the redirection will fail if the file
5232 whose name results from the expansion of
<I>word
</I> exists and is
5234 If the redirection operator is
5237 or the redirection operator is
5246 builtin command is not enabled, the redirection is attempted even
5247 if the file named by
<I>word
</I> exists.
5248 <A NAME=
"lbBL"> </A>
5249 <H4>Appending Redirected Output
</H4>
5251 Redirection of output in this fashion
5252 causes the file whose name results from
5256 to be opened for appending on file descriptor
5259 or the standard output (file descriptor
1) if
5262 is not specified. If the file does not exist it is created.
5265 The general format for appending output is:
5266 <DL COMPACT
><DT><DD>
5269 [
<I>n
</I>]
<B>>></B><I>word
</I>
5272 <A NAME=
"lbBM"> </A>
5273 <H4>Redirecting Standard Output and Standard Error
</H4>
5275 This construct allows both the
5276 standard output (file descriptor
1) and
5277 the standard error output (file descriptor
2)
5278 to be redirected to the file whose name is the
5284 There are two formats for redirecting standard output and
5286 <DL COMPACT
><DT><DD>
5289 <B>&></B><I>word
</I>
5293 <DL COMPACT
><DT><DD>
5294 <B>>&</B><I>word
</I>
5299 Of the two forms, the first is preferred.
5300 This is semantically equivalent to
5301 <DL COMPACT
><DT><DD>
5304 <B>></B><I>word
</I> 2<B>>&</B>1
5309 When using the second form,
<I>word
</I> may not expand to a number or
5310 <B>-
</B>. If it does, other redirection operators apply
5311 (see
<B>Duplicating File Descriptors
</B> below) for compatibility
5313 <A NAME=
"lbBN"> </A>
5314 <H4>Appending Standard Output and Standard Error
</H4>
5316 This construct allows both the
5317 standard output (file descriptor
1) and
5318 the standard error output (file descriptor
2)
5319 to be appended to the file whose name is the
5325 The format for appending standard output and standard error is:
5326 <DL COMPACT
><DT><DD>
5329 <B>&>></B><I>word
</I>
5334 This is semantically equivalent to
5335 <DL COMPACT
><DT><DD>
5338 <B>>></B><I>word
</I> 2<B>>&</B>1
5343 (see
<B>Duplicating File Descriptors
</B> below).
5344 <A NAME=
"lbBO"> </A>
5345 <H4>Here Documents
</H4>
5347 This type of redirection instructs the shell to read input from the
5348 current source until a line containing only
5351 (with no trailing blanks)
5353 the lines read up to that point are then used as the standard
5354 input (or file descriptor
<I>n
</I> if
<I>n
</I> is specified) for a command.
5357 The format of here-documents is:
5358 <DL COMPACT
><DT><DD>
5362 [
<I>n
</I>]
<B><<</B>[
<B>-
</B>]
<I>word
</I>
5363 <I>here-document
</I>
5371 No parameter and variable expansion, command substitution,
5372 arithmetic expansion, or pathname expansion is performed on
5381 is the result of quote removal on
5384 and the lines in the here-document are not expanded.
5385 If
<I>word
</I> is unquoted,
5386 all lines of the here-document are subjected to
5387 parameter expansion, command substitution, and arithmetic expansion,
5388 the character sequence
5389 <B>\
<newline
></B>
5394 must be used to quote the characters
5404 If the redirection operator is
5407 then all leading tab characters are stripped from input lines and the
5412 here-documents within shell scripts to be indented in a
5414 <A NAME=
"lbBP"> </A>
5415 <H4>Here Strings
</H4>
5417 A variant of here documents, the format is:
5418 <DL COMPACT
><DT><DD>
5422 [
<I>n
</I>]
<B><<<</B><I>word
</I>
5429 The
<I>word
</I> undergoes
5430 tilde expansion, parameter and variable expansion,
5431 command substitution, arithmetic expansion, and quote removal.
5432 Pathname expansion and word splitting are not performed.
5433 The result is supplied as a single string, with a newline appended,
5434 to the command on its
5435 standard input (or file descriptor
<I>n
</I> if
<I>n
</I> is specified).
5436 <A NAME=
"lbBQ"> </A>
5437 <H4>Duplicating File Descriptors
</H4>
5439 The redirection operator
5440 <DL COMPACT
><DT><DD>
5443 [
<I>n
</I>]
<B><&</B><I>word
</I>
5448 is used to duplicate input file descriptors.
5452 expands to one or more digits, the file descriptor denoted by
5455 is made to be a copy of that file descriptor.
5459 do not specify a file descriptor open for input, a redirection error occurs.
5472 is not specified, the standard input (file descriptor
0) is used.
5476 <DL COMPACT
><DT><DD>
5479 [
<I>n
</I>]
<B>>&</B><I>word
</I>
5484 is used similarly to duplicate output file descriptors. If
5487 is not specified, the standard output (file descriptor
1) is used.
5491 do not specify a file descriptor open for output, a redirection error occurs.
5502 As a special case, if
<I>n
</I> is omitted, and
<I>word
</I> does not
5503 expand to one or more digits or
<B>-
</B>, the standard output and standard
5504 error are redirected as described previously.
5505 <A NAME=
"lbBR"> </A>
5506 <H4>Moving File Descriptors
</H4>
5508 The redirection operator
5509 <DL COMPACT
><DT><DD>
5512 [
<I>n
</I>]
<B><&</B><I>digit
</I><B>-
</B>
5517 moves the file descriptor
<I>digit
</I> to file descriptor
5520 or the standard input (file descriptor
0) if
<I>n
</I> is not specified.
5521 <I>digit
</I> is closed after being duplicated to
<I>n
</I>.
5524 Similarly, the redirection operator
5525 <DL COMPACT
><DT><DD>
5528 [
<I>n
</I>]
<B>>&</B><I>digit
</I><B>-
</B>
5533 moves the file descriptor
<I>digit
</I> to file descriptor
5536 or the standard output (file descriptor
1) if
<I>n
</I> is not specified.
5537 <A NAME=
"lbBS"> </A>
5538 <H4>Opening File Descriptors for Reading and Writing
</H4>
5540 The redirection operator
5541 <DL COMPACT
><DT><DD>
5544 [
<I>n
</I>]
<B><></B><I>word
</I>
5549 causes the file whose name is the expansion of
5552 to be opened for both reading and writing on file descriptor
5555 or on file descriptor
0 if
5558 is not specified. If the file does not exist, it is created.
5559 <A NAME=
"lbBT"> </A>
5562 <I>Aliases
</I> allow a string to be substituted for a word when it is used
5563 as the first word of a simple command.
5564 The shell maintains a list of aliases that may be set and unset with the
5570 builtin commands (see
5571 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
5575 The first word of each simple command, if unquoted,
5576 is checked to see if it has an
5577 alias. If so, that word is replaced by the text of the alias.
5578 The characters
<B>/
</B>,
<B>$
</B>,
<B>`
</B>, and
<B>=
</B> and
5579 any of the shell
<I>metacharacters
</I> or quoting characters
5580 listed above may not appear in an alias name.
5581 The replacement text may contain any valid shell input,
5582 including shell metacharacters.
5583 The first word of the replacement text is tested
5584 for aliases, but a word that is identical to an alias being expanded
5585 is not expanded a second time.
5586 This means that one may alias
5595 does not try to recursively expand the replacement text.
5596 If the last character of the alias value is a
5599 then the next command
5600 word following the alias is also checked for alias expansion.
5603 Aliases are created and listed with the
5606 command, and removed with the
5612 There is no mechanism for using arguments in the replacement text.
5613 If arguments are needed, use a shell function (see
5614 <FONT SIZE=-
1><B>FUNCTIONS
</B>
5620 Aliases are not expanded when the shell is not interactive, unless
5622 <B>expand_aliases
</B>
5624 shell option is set using
5627 (see the description of
5631 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B></FONT>
5635 The rules concerning the definition and use of aliases are
5639 always reads at least one complete line of input,
5640 and all lines that make up a compound command,
5641 before executing any of the commands on that line or the compound command.
5642 Aliases are expanded when a
5643 command is read, not when it is executed. Therefore, an
5644 alias definition appearing on the same line as another
5645 command does not take effect until the next line of input is read.
5646 The commands following the alias definition
5647 on that line are not affected by the new alias.
5648 This behavior is also an issue when functions are executed.
5649 Aliases are expanded when a function definition is read,
5650 not when the function is executed, because a function definition
5651 is itself a command. As a consequence, aliases
5652 defined in a function are not available until after that
5653 function is executed. To be safe, always put
5654 alias definitions on a separate line, and do not use
5657 in compound commands.
5660 For almost every purpose, aliases are superseded by
5662 <A NAME=
"lbBU"> </A>
5665 A shell function, defined as described above under
5666 <FONT SIZE=-
1><B>SHELL GRAMMAR
</B>,
5669 stores a series of commands for later execution.
5670 When the name of a shell function is used as a simple command name,
5671 the list of commands associated with that function name is executed.
5672 Functions are executed in the context of the
5673 current shell; no new process is created to interpret
5674 them (contrast this with the execution of a shell script).
5675 When a function is executed, the arguments to the
5676 function become the positional parameters
5677 during its execution.
5678 The special parameter
5681 is updated to reflect the change. Special parameter
<B>0</B>
5683 The first element of the
5684 <FONT SIZE=-
1><B>FUNCNAME
</B>
5687 variable is set to the name of the function while the function
5691 All other aspects of the shell execution
5692 environment are identical between a function and its caller
5693 with these exceptions: the
5694 <FONT SIZE=-
1><B>DEBUG
</B>
5700 traps (see the description of the
5704 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
5707 below) are not inherited unless the function has been given the
5708 <B>trace
</B> attribute (see the description of the
5709 <FONT SIZE=-
1><B>declare
</B>
5712 builtin below) or the
5713 <B>-o functrace
</B> shell option has been enabled with
5714 the
<B>set
</B> builtin
5715 (in which case all functions inherit the
<B>DEBUG
</B> and
<B>RETURN
</B> traps),
5717 <FONT SIZE=-
1><B>ERR
</B>
5720 trap is not inherited unless the
<B>-o errtrace
</B> shell option has
5724 Variables local to the function may be declared with the
5727 builtin command (
<I>local variables
</I>).
5728 Ordinarily, variables and their values
5729 are shared between the function and its caller.
5730 If a variable is declared
<B>local
</B>, the variable's visible scope
5731 is restricted to that function and its children (including the functions
5735 In the following description, the
<I>current scope
</I> is a currently-
5737 Previous scopes consist of that function's caller and so on,
5738 back to the
"global
" scope, where the shell is not executing
5740 Consequently, a local variable at the current scope is a variable
5741 declared using the
<B>local
</B> or
<B>declare
</B> builtins in the
5742 function that is currently executing.
5745 Local variables
"shadow
" variables with the same name declared at
5747 For instance, a local variable declared in a function
5748 hides a global variable of the same name: references and assignments
5749 refer to the local variable, leaving the global variable unmodified.
5750 When the function returns, the global variable is once again visible.
5753 The shell uses
<I>dynamic scoping
</I> to control a variable's visibility
5755 With dynamic scoping, visible variables and their values
5756 are a result of the sequence of function calls that caused execution
5757 to reach the current function.
5758 The value of a variable that a function sees depends
5759 on its value within its caller, if any, whether that caller is
5760 the
"global
" scope or another shell function.
5761 This is also the value that a local variable
5762 declaration
"shadows
", and the value that is restored when the function
5766 For example, if a variable
<I>var
</I> is declared as local in function
5767 <I>func1
</I>, and
<I>func1
</I> calls another function
<I>func2
</I>,
5768 references to
<I>var
</I> made from within
<I>func2
</I> will resolve to the
5769 local variable
<I>var
</I> from
<I>func1
</I>, shadowing any global variable
5773 The
<B>unset
</B> builtin also acts using the same dynamic scope: if a
5774 variable is local to the current scope,
<B>unset
</B> will unset it;
5775 otherwise the unset will refer to the variable found in any calling scope
5777 If a variable at the current local scope is unset, it will remain so
5778 (appearing as unset)
5779 until it is reset in that scope or until the function returns.
5780 Once the function returns, any instance of the variable at a previous
5781 scope will become visible.
5782 If the unset acts on a variable at a previous scope, any instance of a
5783 variable with that name that had been shadowed will become visible
5784 (see below how the
<B>localvar_unset
</B> shell option changes this behavior).
5787 The
<B>FUNCNEST
</B> variable, if set to a numeric value greater
5788 than
0, defines a maximum function nesting level. Function
5789 invocations that exceed the limit cause the entire command to
5793 If the builtin command
5796 is executed in a function, the function completes and
5797 execution resumes with the next command after the function
5799 Any command associated with the
<B>RETURN
</B> trap is executed
5800 before execution resumes.
5801 When a function completes, the values of the
5802 positional parameters and the special parameter
5805 are restored to the values they had prior to the function's
5809 Function names and definitions may be listed with the
5818 builtin commands. The
5827 will list the function names only
5828 (and optionally the source file and line number, if the
<B>extdebug
</B>
5829 shell option is enabled).
5830 Functions may be exported so that child shell processes
5831 (those created when executing a separate shell invocation)
5832 automatically have them defined with the
5839 A function definition may be deleted using the
<B>-f
</B> option to
5846 Functions may be recursive.
5847 The
<B>FUNCNEST
</B> variable may be used to limit the depth of the
5848 function call stack and restrict the number of function invocations.
5849 By default, no limit is imposed on the number of recursive calls.
5850 <A NAME=
"lbBV"> </A>
5851 <H3>ARITHMETIC EVALUATION
</H3>
5853 The shell allows arithmetic expressions to be evaluated, under
5854 certain circumstances (see the
<B>let
</B> and
<B>declare
</B> builtin
5855 commands, the
<B>((
</B> compound command, and
<B>Arithmetic Expansion
</B>).
5856 Evaluation is done in fixed-width integers with no check for overflow,
5857 though division by
0 is trapped and flagged as an error.
5858 The operators and their precedence, associativity, and values
5859 are the same as in the C language.
5860 The following list of operators is grouped into levels of
5861 equal-precedence operators.
5862 The levels are listed in order of decreasing precedence.
5867 <DT><B></B><I>id
</I>++
<I>id
</I>--
5870 variable post-increment and post-decrement
5874 unary minus and plus
5875 <DT><B>++
</B><I>id
</I> --
<I>id
</I>
5878 variable pre-increment and pre-decrement
5882 logical and bitwise negation
5890 multiplication, division, remainder
5894 addition, subtraction
5895 <DT><B><< >></B>
5898 left and right bitwise shifts
5899 <DT><B><=
>=
< ></B>
5906 equality and inequality
5914 bitwise exclusive OR
5919 <DT><B>&&</B>
5927 <DT><B></B><I>expr
</I>?
<I>expr
</I>:
<I>expr
</I>
5930 conditional operator
5931 <DT><B>= *= /= %= += -=
<<=
>>=
&= ^= |=
</B>
5935 <DT><B></B><I>expr1
</I> ,
<I>expr2
</I>
5943 Shell variables are allowed as operands; parameter expansion is
5944 performed before the expression is evaluated.
5945 Within an expression, shell variables may also be referenced by name
5946 without using the parameter expansion syntax.
5947 A shell variable that is null or unset evaluates to
0 when referenced
5948 by name without using the parameter expansion syntax.
5949 The value of a variable is evaluated as an arithmetic expression
5950 when it is referenced, or when a variable which has been given the
5951 <I>integer
</I> attribute using
<B>declare -i
</B> is assigned a value.
5952 A null value evaluates to
0.
5953 A shell variable need not have its
<I>integer
</I> attribute
5954 turned on to be used in an expression.
5957 Integer constants follow the C language definition, without suffixes or
5958 character constants.
5959 Constants with a leading
0 are interpreted as octal numbers.
5960 A leading
0x or
0X denotes hexadecimal.
5961 Otherwise, numbers take the form [
<I>base#
</I>]n, where the optional
<I>base
</I>
5962 is a decimal number between
2 and
64 representing the arithmetic
5963 base, and
<I>n
</I> is a number in that base.
5964 If
<I>base#
</I> is omitted, then base
10 is used.
5965 When specifying
<I>n
</I>,
5966 if a non-digit is required,
5967 the digits greater than
9 are represented by the lowercase letters,
5968 the uppercase letters, @, and _, in that order.
5969 If
<I>base
</I> is less than or equal to
36, lowercase and uppercase
5970 letters may be used interchangeably to represent numbers between
10
5974 Operators are evaluated in order of precedence. Sub-expressions in
5975 parentheses are evaluated first and may override the precedence
5977 <A NAME=
"lbBW"> </A>
5978 <H3>CONDITIONAL EXPRESSIONS
</H3>
5980 Conditional expressions are used by the
<B>[[
</B> compound command and
5981 the
<B>test
</B> and
<B>[
</B> builtin commands to test file attributes
5982 and perform string and arithmetic comparisons.
5983 The
<B>test
</B> and
<B>[
</B> commands determine their behavior based on
5984 the number of arguments; see the descriptions of those commands for any
5985 other command-specific actions.
5988 Expressions are formed from the following unary or binary primaries.
5989 <B>Bash
</B> handles several filenames specially when they are used in
5991 If the operating system on which
<B>bash
</B> is running provides these
5992 special files, bash will use them; otherwise it will emulate them
5993 internally with this behavior:
5994 If any
<I>file
</I> argument to one of the primaries is of the form
5995 <I>/dev/fd/n
</I>, then file descriptor
<I>n
</I> is checked.
5996 If the
<I>file
</I> argument to one of the primaries is one of
5997 <I>/dev/stdin
</I>,
<I>/dev/stdout
</I>, or
<I>/dev/stderr
</I>, file
5998 descriptor
0,
1, or
2, respectively, is checked.
6001 Unless otherwise specified, primaries that operate on files follow symbolic
6002 links and operate on the target of the link, rather than the link itself.
6006 When used with
<B>[[
</B>, the
<B><</B> and
<B>></B> operators sort
6007 lexicographically using the current locale.
6008 The
<B>test
</B> command sorts using ASCII ordering.
6012 <DT><B>-a
</B><I>file
</I>
6015 True if
<I>file
</I> exists.
6016 <DT><B>-b
</B><I>file
</I>
6019 True if
<I>file
</I> exists and is a block special file.
6020 <DT><B>-c
</B><I>file
</I>
6023 True if
<I>file
</I> exists and is a character special file.
6024 <DT><B>-d
</B><I>file
</I>
6027 True if
<I>file
</I> exists and is a directory.
6028 <DT><B>-e
</B><I>file
</I>
6031 True if
<I>file
</I> exists.
6032 <DT><B>-f
</B><I>file
</I>
6035 True if
<I>file
</I> exists and is a regular file.
6036 <DT><B>-g
</B><I>file
</I>
6039 True if
<I>file
</I> exists and is set-group-id.
6040 <DT><B>-h
</B><I>file
</I>
6043 True if
<I>file
</I> exists and is a symbolic link.
6044 <DT><B>-k
</B><I>file
</I>
6047 True if
<I>file
</I> exists and its ``sticky'' bit is set.
6048 <DT><B>-p
</B><I>file
</I>
6051 True if
<I>file
</I> exists and is a named pipe (FIFO).
6052 <DT><B>-r
</B><I>file
</I>
6055 True if
<I>file
</I> exists and is readable.
6056 <DT><B>-s
</B><I>file
</I>
6059 True if
<I>file
</I> exists and has a size greater than zero.
6060 <DT><B>-t
</B><I>fd
</I>
6063 True if file descriptor
6066 is open and refers to a terminal.
6067 <DT><B>-u
</B><I>file
</I>
6070 True if
<I>file
</I> exists and its set-user-id bit is set.
6071 <DT><B>-w
</B><I>file
</I>
6074 True if
<I>file
</I> exists and is writable.
6075 <DT><B>-x
</B><I>file
</I>
6078 True if
<I>file
</I> exists and is executable.
6079 <DT><B>-G
</B><I>file
</I>
6082 True if
<I>file
</I> exists and is owned by the effective group id.
6083 <DT><B>-L
</B><I>file
</I>
6086 True if
<I>file
</I> exists and is a symbolic link.
6087 <DT><B>-N
</B><I>file
</I>
6090 True if
<I>file
</I> exists and has been modified since it was last read.
6091 <DT><B>-O
</B><I>file
</I>
6094 True if
<I>file
</I> exists and is owned by the effective user id.
6095 <DT><B>-S
</B><I>file
</I>
6098 True if
<I>file
</I> exists and is a socket.
6099 <DT><I>file1
</I> <B>-ef
</B> <I>file2
</I><DD>
6100 True if
<I>file1
</I> and
<I>file2
</I> refer to the same device and
6102 <DT><I>file1
</I> -
<B>nt
</B> <I>file2
</I><DD>
6103 True if
<I>file1
</I> is newer (according to modification date) than
<I>file2
</I>,
6104 or if
<I>file1
</I> exists and file2 does not.
6105 <DT><I>file1
</I> -
<B>ot
</B> <I>file2
</I><DD>
6106 True if
<I>file1
</I> is older than
<I>file2
</I>, or if
<I>file2
</I> exists
6107 and
<I>file1
</I> does not.
6108 <DT><B>-o
</B><I>optname
</I>
6111 True if the shell option
6115 See the list of options under the description of the
6122 <DT><B>-v
</B><I>varname
</I>
6125 True if the shell variable
6128 is set (has been assigned a value).
6129 <DT><B>-R
</B><I>varname
</I>
6132 True if the shell variable
6135 is set and is a name reference.
6136 <DT><B>-z
</B><I>string
</I>
6139 True if the length of
<I>string
</I> is zero.
6140 <DT><I>string
</I><DD>
6142 <DT><B>-n
</B><I>string
</I>
6146 True if the length of
6150 <DT><I>string1
</I> <B>==
</B> <I>string2
</I><DD>
6152 <DT><I>string1
</I> <B>=
</B> <I>string2
</I><DD>
6154 True if the strings are equal.
<B>=
</B> should be used
6155 with the
<B>test
</B> command for POSIX conformance.
6156 When used with the
<B>[[
</B> command, this performs pattern matching as
6157 described above (
<B>Compound Commands
</B>).
6158 <DT><I>string1
</I> <B>!=
</B> <I>string2
</I><DD>
6159 True if the strings are not equal.
6160 <DT><I>string1
</I> <B><</B> <I>string2
</I><DD>
6161 True if
<I>string1
</I> sorts before
<I>string2
</I> lexicographically.
6162 <DT><I>string1
</I> <B>></B> <I>string2
</I><DD>
6163 True if
<I>string1
</I> sorts after
<I>string2
</I> lexicographically.
6164 <DT><I>arg1
</I> <B>OP
</B> <I>arg2
</I>
6167 <FONT SIZE=-
1><B>OP
</B>
6184 These arithmetic binary operators return true if
<I>arg1
</I>
6185 is equal to, not equal to, less than, less than or equal to,
6186 greater than, or greater than or equal to
<I>arg2
</I>, respectively.
6192 may be positive or negative integers.
6193 When used with the
<B>[[
</B> command,
6199 are evaluated as arithmetic expressions (see
6200 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>
6206 <A NAME=
"lbBX"> </A>
6207 <H3>SIMPLE COMMAND EXPANSION
</H3>
6209 When a simple command is executed, the shell performs the following
6210 expansions, assignments, and redirections, from left to right, in
6211 the following order.
6214 The words that the parser has marked as variable assignments (those
6215 preceding the command name) and redirections are saved for later
6218 The words that are not variable assignments or redirections are
6219 expanded. If any words remain after expansion, the first word
6220 is taken to be the name of the command and the remaining words are
6223 Redirections are performed as described above under
6224 <FONT SIZE=-
1><B>REDIRECTION
</B>.
6228 The text after the
<B>=
</B> in each variable assignment undergoes tilde
6229 expansion, parameter expansion, command substitution, arithmetic expansion,
6230 and quote removal before being assigned to the variable.
6234 If no command name results, the variable assignments affect the current
6236 In the case of such a command (one that consists only of assignment
6237 statements and redirections), assignment statements are performed before
6239 Otherwise, the variables are added to the environment
6240 of the executed command and do not affect the current shell environment.
6241 If any of the assignments attempts to assign a value to a readonly variable,
6242 an error occurs, and the command exits with a non-zero status.
6245 If no command name results, redirections are performed, but do not
6246 affect the current shell environment. A redirection error causes the
6247 command to exit with a non-zero status.
6250 If there is a command name left after expansion, execution proceeds as
6251 described below. Otherwise, the command exits. If one of the expansions
6252 contained a command substitution, the exit status of the command is
6253 the exit status of the last command substitution performed. If there
6254 were no command substitutions, the command exits with a status of zero.
6255 <A NAME=
"lbBY"> </A>
6256 <H3>COMMAND EXECUTION
</H3>
6258 After a command has been split into words, if it results in a
6259 simple command and an optional list of arguments, the following
6263 If the command name contains no slashes, the shell attempts to
6264 locate it. If there exists a shell function by that name, that
6265 function is invoked as described above in
6266 <FONT SIZE=-
1><B>FUNCTIONS
</B>.
6269 If the name does not match a function, the shell searches for
6270 it in the list of shell builtins. If a match is found, that
6274 If the name is neither a shell function nor a builtin,
6275 and contains no slashes,
6278 searches each element of the
6279 <FONT SIZE=-
1><B>PATH
</B>
6282 for a directory containing an executable file by that name.
6285 uses a hash table to remember the full pathnames of executable
6290 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
6294 A full search of the directories in
6295 <FONT SIZE=-
1><B>PATH
</B>
6298 is performed only if the command is not found in the hash table.
6299 If the search is unsuccessful, the shell searches for a defined shell
6300 function named
<B>command_not_found_handle
</B>.
6301 If that function exists, it is invoked in a separate execution environment
6302 with the original command and
6303 the original command's arguments as its arguments, and the function's
6304 exit status becomes the exit status of that subshell.
6305 If that function is not defined, the shell prints an error
6306 message and returns an exit status of
127.
6309 If the search is successful, or if the command name contains
6310 one or more slashes, the shell executes the named program in a
6311 separate execution environment.
6312 Argument
0 is set to the name given, and the remaining arguments
6313 to the command are set to the arguments given, if any.
6316 If this execution fails because the file is not in executable
6317 format, and the file is not a directory, it is assumed to be
6318 a
<I>shell script
</I>, a file
6319 containing shell commands, and the shell creates a
6320 new instance of itself
6322 This subshell reinitializes itself, so
6323 that the effect is as if a new shell had been invoked
6324 to handle the script, with the exception that the locations of
6325 commands remembered by the parent (see
6329 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>)
</FONT>
6330 are retained by the child.
6333 If the program is a file beginning with
6336 the remainder of the first line specifies an interpreter
6337 for the program. The shell executes the
6338 specified interpreter on operating systems that do not
6339 handle this executable format themselves. The arguments to the
6340 interpreter consist of a single optional argument following the
6341 interpreter name on the first line of the program, followed
6342 by the name of the program, followed by the command
6344 <A NAME=
"lbBZ"> </A>
6345 <H3>COMMAND EXECUTION ENVIRONMENT
</H3>
6347 The shell has an
<I>execution environment
</I>, which consists of the
6351 open files inherited by the shell at invocation, as modified by
6352 redirections supplied to the
<B>exec
</B> builtin
6354 the current working directory as set by
<B>cd
</B>,
<B>pushd
</B>, or
6355 <B>popd
</B>, or inherited by the shell at invocation
6357 the file creation mode mask as set by
<B>umask
</B> or inherited from
6360 current traps set by
<B>trap
</B>
6362 shell parameters that are set by variable assignment or with
<B>set
</B>
6363 or inherited from the shell's parent in the environment
6365 shell functions defined during execution or inherited from the shell's
6366 parent in the environment
6368 options enabled at invocation (either by default or with command-line
6369 arguments) or by
<B>set
</B>
6371 options enabled by
<B>shopt
</B>
6373 shell aliases defined with
<B>alias
</B>
6375 various process IDs, including those of background jobs, the value
6376 of
<B>$$
</B>, and the value of
6377 <FONT SIZE=-
1><B>PPID
</B>
6383 When a simple command other than a builtin or shell function
6384 is to be executed, it
6385 is invoked in a separate execution environment that consists of
6387 Unless otherwise noted, the values are inherited from the shell.
6391 the shell's open files, plus any modifications and additions specified
6392 by redirections to the command
6394 the current working directory
6396 the file creation mode mask
6398 shell variables and functions marked for export, along with variables
6399 exported for the command, passed in the environment
6401 traps caught by the shell are reset to the values inherited from the
6402 shell's parent, and traps ignored by the shell are ignored
6406 A command invoked in this separate environment cannot affect the
6407 shell's execution environment.
6410 A
<I>subshell
</I> is a copy of the shell process.
6413 Command substitution, commands grouped with parentheses,
6414 and asynchronous commands are invoked in a
6415 subshell environment that is a duplicate of the shell environment,
6416 except that traps caught by the shell are reset to the values
6417 that the shell inherited from its parent at invocation. Builtin
6418 commands that are invoked as part of a pipeline are also executed in a
6419 subshell environment. Changes made to the subshell environment
6420 cannot affect the shell's execution environment.
6423 Subshells spawned to execute command substitutions inherit the value of
6424 the
<B>-e
</B> option from the parent shell. When not in
<I>posix mode
</I>,
6425 <B>bash
</B> clears the
<B>-e
</B> option in such subshells.
6428 If a command is followed by a
<B>&</B> and job control is not active, the
6429 default standard input for the command is the empty file
<I>/dev/null
</I>.
6430 Otherwise, the invoked command inherits the file descriptors of the calling
6431 shell as modified by redirections.
6432 <A NAME=
"lbCA"> </A>
6433 <H3>ENVIRONMENT
</H3>
6435 When a program is invoked it is given an array of strings
6440 <I>name
</I>-
<I>value
</I> pairs, of the form
6445 The shell provides several ways to manipulate the environment.
6446 On invocation, the shell scans its own environment and
6447 creates a parameter for each name found, automatically marking
6451 to child processes. Executed commands inherit the environment.
6458 commands allow parameters and functions to be added to and
6459 deleted from the environment. If the value of a parameter
6460 in the environment is modified, the new value becomes part
6461 of the environment, replacing the old. The environment
6462 inherited by any executed command consists of the shell's
6463 initial environment, whose values may be modified in the shell,
6464 less any pairs removed by the
6467 command, plus any additions via the
6476 The environment for any
6477 <I>simple command
</I>
6479 or function may be augmented temporarily by prefixing it with
6480 parameter assignments, as described above in
6481 <FONT SIZE=-
1><B>PARAMETERS
</B>.
6484 These assignment statements affect only the environment seen
6491 option is set (see the
6494 builtin command below), then
6497 parameter assignments are placed in the environment for a command,
6498 not just those that precede the command name.
6504 invokes an external command, the variable
6507 is set to the full filename of the command and passed to that
6508 command in its environment.
6509 <A NAME=
"lbCB"> </A>
6510 <H3>EXIT STATUS
</H3>
6512 The exit status of an executed command is the value returned by the
6513 <I>waitpid
</I> system call or equivalent function. Exit statuses
6514 fall between
0 and
255, though, as explained below, the shell may
6515 use values above
125 specially. Exit statuses from shell builtins and
6516 compound commands are also limited to this range. Under certain
6517 circumstances, the shell will use special values to indicate specific
6521 For the shell's purposes, a command which exits with a
6522 zero exit status has succeeded. An exit status of zero
6523 indicates success. A non-zero exit status indicates failure.
6524 When a command terminates on a fatal signal
<I>N
</I>,
<B>bash
</B> uses
6525 the value of
128+
<I>N
</I> as the exit status.
6528 If a command is not found, the child process created to
6529 execute it returns a status of
127. If a command is found
6530 but is not executable, the return status is
126.
6533 If a command fails because of an error during expansion or redirection,
6534 the exit status is greater than zero.
6537 Shell builtin commands return a status of
0 (
<I>true
</I>) if
6538 successful, and non-zero (
<I>false
</I>) if an error occurs
6540 All builtins return an exit status of
2 to indicate incorrect usage,
6541 generally invalid options or missing arguments.
6544 The exit status of the last command is available in the special
6548 <B>Bash
</B> itself returns the exit status of the last command
6549 executed, unless a syntax error occurs, in which case it exits
6550 with a non-zero value. See also the
<B>exit
</B> builtin
6552 <A NAME=
"lbCC"> </A>
6555 When
<B>bash
</B> is interactive, in the absence of any traps, it ignores
6556 <FONT SIZE=-
1><B>SIGTERM
</B>
6559 (so that
<B>kill
0</B> does not kill an interactive shell),
6561 <FONT SIZE=-
1><B>SIGINT
</B>
6564 is caught and handled (so that the
<B>wait
</B> builtin is interruptible).
6565 In all cases,
<B>bash
</B> ignores
6566 <FONT SIZE=-
1><B>SIGQUIT
</B>.
6569 If job control is in effect,
6573 <FONT SIZE=-
1><B>SIGTTIN
</B>,
6576 <FONT SIZE=-
1><B>SIGTTOU
</B>,
6580 <FONT SIZE=-
1><B>SIGTSTP
</B>.
6585 Non-builtin commands run by
<B>bash
</B> have signal handlers
6586 set to the values inherited by the shell from its parent.
6587 When job control is not in effect, asynchronous commands
6589 <FONT SIZE=-
1><B>SIGINT
</B>
6593 <FONT SIZE=-
1><B>SIGQUIT
</B>
6596 in addition to these inherited handlers.
6597 Commands run as a result of command substitution ignore the
6598 keyboard-generated job control signals
6599 <FONT SIZE=-
1><B>SIGTTIN
</B>,
6602 <FONT SIZE=-
1><B>SIGTTOU
</B>,
6606 <FONT SIZE=-
1><B>SIGTSTP
</B>.
6611 The shell exits by default upon receipt of a
6612 <FONT SIZE=-
1><B>SIGHUP
</B>.
6615 Before exiting, an interactive shell resends the
6616 <FONT SIZE=-
1><B>SIGHUP
</B>
6619 to all jobs, running or stopped.
6620 Stopped jobs are sent
6621 <FONT SIZE=-
1><B>SIGCONT
</B>
6624 to ensure that they receive the
6625 <FONT SIZE=-
1><B>SIGHUP
</B>.
6628 To prevent the shell from
6629 sending the signal to a particular job, it should be removed from the
6634 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
6639 <FONT SIZE=-
1><B>SIGHUP
</B>
6650 shell option has been set with
6656 <FONT SIZE=-
1><B>SIGHUP
</B>
6659 to all jobs when an interactive login shell exits.
6662 If
<B>bash
</B> is waiting for a command to complete and receives a signal
6663 for which a trap has been set, the trap will not be executed until
6664 the command completes.
6665 When
<B>bash
</B> is waiting for an asynchronous command via the
<B>wait
</B>
6666 builtin, the reception of a signal for which a trap has been set will
6667 cause the
<B>wait
</B> builtin to return immediately with an exit status
6668 greater than
128, immediately after which the trap is executed.
6671 When job control is not enabled, and
<B>bash
</B> is waiting for a foreground
6672 command to complete, the shell receives keyboard-generated signals
6674 <FONT SIZE=-
1><B>SIGINT
</B>
6677 (usually generated by
<B>^C
</B>) that users commonly intend to send
6679 This happens because the shell and the command are in the
6680 same process group as the terminal, and
<B>^C
</B> sends
6681 <FONT SIZE=-
1><B>SIGINT
</B>
6684 to all processes in that process group.
6687 When
<B>bash
</B> is running without job control enabled and receives
6688 <FONT SIZE=-
1><B>SIGINT
</B>
6691 while waiting for a foreground command, it waits until that foreground
6692 command terminates and then decides what to do about the
6693 <FONT SIZE=-
1><B>SIGINT
</B>:
6698 If the command terminates due to the
6699 <FONT SIZE=-
1><B>SIGINT
</B>,
6702 <B>bash
</B> concludes
6703 that the user meant to end the entire script, and acts on the
6704 <FONT SIZE=-
1><B>SIGINT
</B>
6708 <FONT SIZE=-
1><B>SIGINT
</B>
6711 trap or exiting itself);
6713 If the command does not terminate due to
6714 <FONT SIZE=-
1><B>SIGINT
</B>,
6717 the program handled the
6718 <FONT SIZE=-
1><B>SIGINT
</B>
6721 itself and did not treat it as a fatal signal.
6722 In that case,
<B>bash
</B> does not treat
6723 <FONT SIZE=-
1><B>SIGINT
</B>
6726 as a fatal signal, either, instead assuming that the
6727 <FONT SIZE=-
1><B>SIGINT
</B>
6730 was used as part of the program's normal operation
6731 (e.g., emacs uses it to abort editing
6732 commands) or deliberately discarded.
6733 However,
<B>bash
</B> will run any
6735 <FONT SIZE=-
1><B>SIGINT
</B>,
6738 as it does with any other trapped signal it
6739 receives while it is waiting for the foreground command to
6740 complete, for compatibility.
6742 <A NAME=
"lbCD"> </A>
6743 <H3>JOB CONTROL
</H3>
6747 refers to the ability to selectively stop (
<I>suspend
</I>)
6748 the execution of processes and continue (
<I>resume
</I>)
6749 their execution at a later point. A user typically employs
6750 this facility via an interactive interface supplied jointly
6751 by the operating system kernel's terminal driver and
6756 The shell associates a
6759 with each pipeline. It keeps a table of currently executing
6760 jobs, which may be listed with the
6766 starts a job asynchronously (in the
6769 it prints a line that looks like:
6770 <DL COMPACT
><DT><DD>
6778 indicating that this job is job number
1 and that the process ID
6779 of the last process in the pipeline associated with this job is
25647.
6780 All of the processes in a single pipeline are members of the same job.
6786 abstraction as the basis for job control.
6789 To facilitate the implementation of the user interface to job
6790 control, the operating system maintains the notion of a
<I>current terminal
6791 process group ID
</I>. Members of this process group (processes whose
6792 process group ID is equal to the current terminal process group ID)
6793 receive keyboard-generated signals such as
6794 <FONT SIZE=-
1><B>SIGINT
</B>.
6797 These processes are said to be in the
6802 processes are those whose process group ID differs from the terminal's;
6803 such processes are immune to keyboard-generated signals.
6804 Only foreground processes are allowed to read from or, if the
6805 user so specifies with
<TT>stty tostop
</TT>, write to the
6807 Background processes which attempt to read from (write to when
6808 <TT>stty tostop
</TT> is in effect) the
6810 <FONT SIZE=-
1><B>SIGTTIN (SIGTTOU)
</B>
6813 signal by the kernel's terminal driver,
6814 which, unless caught, suspends the process.
6817 If the operating system on which
6824 contains facilities to use it.
6828 character (typically
6831 Control-Z) while a process is running
6832 causes that process to be stopped and returns control to
6836 <I>delayed suspend
</I>
6838 character (typically
6841 Control-Y) causes the process to be stopped when it
6842 attempts to read input from the terminal, and control to
6846 The user may then manipulate the state of this job, using the
6849 command to continue it in the background, the
6852 command to continue it in the foreground, or
6856 command to kill it. A
<B>^Z
</B> takes effect immediately,
6857 and has the additional side effect of causing pending output
6858 and typeahead to be discarded.
6861 There are a number of ways to refer to a job in the shell.
6865 introduces a job specification (
<I>jobspec
</I>). Job number
6868 may be referred to as
6871 A job may also be referred to using a prefix of the name used to
6872 start it, or using a substring that appears in its command line.
6877 job whose command name begins with
6880 If a prefix matches more than one job,
6883 reports an error. Using
6886 on the other hand, refers to any job containing the string
6889 in its command line. If the substring matches more than one job,
6892 reports an error. The symbols
6898 refer to the shell's notion of the
6901 which is the last job stopped while it was in
6902 the foreground or started in the background.
6906 may be referenced using
6909 If there is only a single job,
<B>%+
</B> and
<B>%-
</B> can both be used
6910 to refer to that job.
6911 In output pertaining to jobs (e.g., the output of the
6914 command), the current job is always flagged with a
6917 and the previous job with a
6920 A single % (with no accompanying job specification) also refers to the
6924 Simply naming a job can be used to bring it into the
6930 bringing job
1 from the background into the foreground.
6934 resumes job
1 in the background, equivalent to
6938 The shell learns immediately whenever a job changes state.
6942 waits until it is about to print a prompt before reporting
6943 changes in a job's status so as to not interrupt
6944 any other output. If the
6954 reports such changes immediately.
6956 <FONT SIZE=-
1><B>SIGCHLD
</B>
6959 is executed for each child that exits.
6962 If an attempt to exit
6965 is made while jobs are stopped (or, if the
<B>checkjobs
</B> shell option has
6966 been enabled using the
<B>shopt
</B> builtin, running), the shell prints a
6967 warning message, and, if the
<B>checkjobs
</B> option is enabled, lists the
6968 jobs and their statuses.
6972 command may then be used to inspect their status.
6973 If a second attempt to exit is made without an intervening command,
6974 the shell does not print another warning, and any stopped
6975 jobs are terminated.
6978 When the shell is waiting for a job or process using the
<B>wait
</B>
6979 builtin, and job control is enabled,
<B>wait
</B> will return when the
6980 job changes state. The
<B>-f
</B> option causes
<B>wait
</B> to wait
6981 until the job or process terminates before returning.
6982 <A NAME=
"lbCE"> </A>
6985 When executing interactively,
6988 displays the primary prompt
6989 <FONT SIZE=-
1><B>PS1
</B>
6992 when it is ready to read a command, and the secondary prompt
6993 <FONT SIZE=-
1><B>PS2
</B>
6996 when it needs more input to complete a command.
7000 <FONT SIZE=-
1><B>PS0
</B>
7003 after it reads a command but before executing it.
7007 <FONT SIZE=-
1><B>PS4
</B>
7011 before tracing each command when the
<B>-x
</B> option is enabled.
7014 allows these prompt strings to be customized by inserting a number of
7015 backslash-escaped special characters that are decoded as follows:
7016 <DL COMPACT
><DT><DD>
7022 an ASCII bell character (
07)
7026 the date in
"Weekday Month Date
" format (e.g.,
"Tue May
26")
7027 <DT><B>\D{
</B><I>format
</I>}
7030 the
<I>format
</I> is passed to
<I>strftime
</I>(
3) and the result is inserted
7031 into the prompt string; an empty
<I>format
</I> results in a locale-specific
7032 time representation. The braces are required
7036 an ASCII escape character (
033)
7040 the hostname up to the first `.'
7048 the number of jobs currently managed by the shell
7052 the basename of the shell's terminal device name
7064 the name of the shell, the basename of
7067 (the portion following the final slash)
7071 the current time in
24-hour HH:MM:SS format
7075 the current time in
12-hour HH:MM:SS format
7079 the current time in
12-hour am/pm format
7083 the current time in
24-hour HH:MM format
7087 the username of the current user
7091 the version of
<B>bash
</B> (e.g.,
2.00)
7095 the release of
<B>bash
</B>, version + patch level (e.g.,
2.00.0)
7099 the value of the
<B>PWD
</B> shell variable (
<B>$PWD
</B>),
7101 <FONT SIZE=-
1><B>$HOME
</B>
7104 abbreviated with a tilde
7105 (uses the value of the
7106 <FONT SIZE=-
1><B>PROMPT_DIRTRIM
</B>
7113 the basename of
<B>$PWD
</B>,
7115 <FONT SIZE=-
1><B>$HOME
</B>
7118 abbreviated with a tilde
7122 the history number of this command
7126 the command number of this command
7130 if the effective UID is
0, a
7136 <DT><B>\
</B><I>nnn
</I>
7139 the character corresponding to the octal number
<I>nnn
</I>
7147 begin a sequence of non-printing characters, which could be used to
7148 embed a terminal control sequence into the prompt
7152 end a sequence of non-printing characters
7158 The command number and the history number are usually different:
7159 the history number of a command is its position in the history
7160 list, which may include commands restored from the history file
7162 <FONT SIZE=-
1><B>HISTORY
</B>
7165 below), while the command number is the position in the sequence
7166 of commands executed during the current shell session.
7167 After the string is decoded, it is expanded via
7168 parameter expansion, command substitution, arithmetic
7169 expansion, and quote removal, subject to the value of the
7172 shell option (see the description of the
7176 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
7180 This can have unwanted side effects if escaped portions of the string
7181 appear within command substitution or contain characters special to
7183 <A NAME=
"lbCF"> </A>
7186 This is the library that handles reading input when using an interactive
7190 option is given at shell invocation.
7191 Line editing is also used when using the
<B>-e
</B> option to the
7192 <B>read
</B> builtin.
7193 By default, the line editing commands are similar to those of Emacs.
7194 A vi-style line editing interface is also available.
7195 Line editing can be enabled at any time using the
7205 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
7209 To turn off line editing after the shell is running, use the
7219 <A NAME=
"lbCG"> </A>
7220 <H4>Readline Notation
</H4>
7222 In this section, the Emacs-style notation is used to denote
7223 keystrokes. Control keys are denoted by C-
<I>key
</I>, e.g., C-n
7224 means Control-N. Similarly,
7227 keys are denoted by M-
<I>key
</I>, so M-x means Meta-X. (On keyboards
7231 key, M-
<I>x
</I> means ESC
<I>x
</I>, i.e., press the Escape key
7235 key. This makes ESC the
<I>meta prefix
</I>.
7236 The combination M-C-
<I>x
</I> means ESC-Control-
<I>x
</I>,
7237 or press the Escape key
7238 then hold the Control key while pressing the
7244 Readline commands may be given numeric
7247 which normally act as a repeat count.
7248 Sometimes, however, it is the sign of the argument that is significant.
7249 Passing a negative argument to a command that acts in the forward
7250 direction (e.g.,
<B>kill-line
</B>) causes that command to act in a
7252 Commands whose behavior with arguments deviates from this are noted
7256 When a command is described as
<I>killing
</I> text, the text
7257 deleted is saved for possible future retrieval
7258 (
<I>yanking
</I>). The killed text is saved in a
7259 <I>kill ring
</I>. Consecutive kills cause the text to be
7260 accumulated into one unit, which can be yanked all at once.
7261 Commands which do not kill text separate the chunks of text
7263 <A NAME=
"lbCH"> </A>
7264 <H4>Readline Initialization
</H4>
7266 Readline is customized by putting commands in an initialization
7267 file (the
<I>inputrc
</I> file).
7268 The name of this file is taken from the value of the
7269 <FONT SIZE=-
1><B>INPUTRC
</B>
7272 variable. If that variable is unset, the default is
7273 <A HREF=
"file:~/.inputrc"><I>~/.inputrc
</I></A>.
7275 If that file does not exist or cannot be read, the ultimate default is
7276 <A HREF=
"file:/etc/inputrc"><I>/etc/inputrc
</I></A>.
7278 When a program which uses the readline library starts up, the
7279 initialization file is read, and the key bindings and variables
7281 There are only a few basic constructs allowed in the
7282 readline initialization file.
7283 Blank lines are ignored.
7284 Lines beginning with a
<B>#
</B> are comments.
7285 Lines beginning with a
<B>$
</B> indicate conditional constructs.
7286 Other lines denote key bindings and variable settings.
7289 The default key-bindings may be changed with an
7293 Other programs that use this library may add their own commands
7297 For example, placing
7298 <DL COMPACT
><DT><DD>
7301 M-Control-u: universal-argument
7305 <DL COMPACT
><DT><DD>
7306 C-Meta-u: universal-argument
7312 would make M-C-u execute the readline command
7313 <I>universal-argument
</I>.
7317 The following symbolic character names are recognized:
7341 In addition to command names, readline allows keys to be bound
7342 to a string that is inserted when the key is pressed (a
<I>macro
</I>).
7343 <A NAME=
"lbCI"> </A>
7344 <H4>Readline Key Bindings
</H4>
7346 The syntax for controlling key bindings in the
7349 file is simple. All that is required is the name of the
7350 command or the text of a macro and a key sequence to which
7351 it should be bound. The name may be specified in one of two ways:
7352 as a symbolic key name, possibly with
<I>Meta-
</I> or
<I>Control-
</I>
7353 prefixes, or as a key sequence.
7356 When using the form
<B>keyname
</B>:
<I>function-name
</I> or
<I>macro
</I>,
7359 is the name of a key spelled out in English. For example:
7361 <DL COMPACT
><DT><DD>
7362 Control-u: universal-argument
7365 Meta-Rubout: backward-kill-word
7368 Control-o:
"> output
"
7373 In the above example,
7376 is bound to the function
7377 <B>universal-argument
</B>,
7381 is bound to the function
7382 <B>backward-kill-word
</B>,
7387 is bound to run the macro
7388 expressed on the right hand side (that is, to insert the text
7389 <TT>> output
</TT>
7394 In the second form,
<B>"keyseq
"</B>:
<I>function-name
</I> or
<I>macro
</I>,
7400 above in that strings denoting
7401 an entire key sequence may be specified by placing the sequence
7402 within double quotes. Some GNU Emacs style key escapes can be
7403 used, as in the following example, but the symbolic character names
7406 <DL COMPACT
><DT><DD>
7407 "\C-u
": universal-argument
7410 "\C-x\C-r
": re-read-init-file
7413 "\e[
11~
":
"Function Key
1"
7421 is again bound to the function
7422 <B>universal-argument
</B>.
7426 is bound to the function
7427 <B>re-read-init-file
</B>,
7432 is bound to insert the text
7433 <TT>Function Key
1</TT>.
7437 The full set of GNU Emacs style escape sequences is
7438 <DL COMPACT
><DT><DD>
7470 In addition to the GNU Emacs style escape sequences, a second
7471 set of backslash escapes is available:
7472 <DL COMPACT
><DT><DD>
7507 <DT><B>\
</B><I>nnn
</I>
7510 the eight-bit character whose value is the octal value
<I>nnn
</I>
7511 (one to three digits)
7512 <DT><B>\x
</B><I>HH
</I>
7515 the eight-bit character whose value is the hexadecimal value
<I>HH
</I>
7516 (one or two hex digits)
7522 When entering the text of a macro, single or double quotes must
7523 be used to indicate a macro definition.
7524 Unquoted text is assumed to be a function name.
7525 In the macro body, the backslash escapes described above are expanded.
7526 Backslash will quote any other character in the macro text,
7527 including
" and aq.
7532 allows the current readline key bindings to be displayed or modified
7536 builtin command. The editing mode may be switched during interactive
7543 builtin command (see
7544 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
7548 <A NAME=
"lbCJ"> </A>
7549 <H4>Readline Variables
</H4>
7551 Readline has variables that can be used to further customize its
7552 behavior. A variable may be set in the
7555 file with a statement of the form
7556 <DL COMPACT
><DT><DD>
7559 <B>set
</B> <I>variable-name
</I> <I>value
</I>
7562 or using the
<B>bind
</B> builtin command (see
7563 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
7569 Except where noted, readline variables can take the values
7575 (without regard to case).
7576 Unrecognized variable names are ignored.
7577 When a variable value is read, empty or null values,
"on
" (case-insensitive),
7578 and
"1" are equivalent to
<B>On
</B>. All other values are equivalent to
7580 The variables and their default values are:
7585 <DT><B>active-region-start-color
</B>
7588 A string variable that controls the text color and background when displaying
7589 the text in the active region (see the description of
7590 <B>enable-active-region
</B> below).
7591 This string must not take up any physical character positions on the display,
7592 so it should consist only of terminal escape sequences.
7593 It is output to the terminal before displaying the text in the active region.
7594 This variable is reset to the default value whenever the terminal type changes.
7595 The default value is the string that puts the terminal in standout mode,
7596 as obtained from the terminal's terminfo description.
7597 A sample value might be
<TT>"\e[
01;
33m
"</TT>.
7598 <DT><B>active-region-end-color
</B>
7601 A string variable that
"undoes
" the effects of
<B>active-region-start-color
</B>
7602 and restores
"normal
" terminal display appearance after displaying text
7603 in the active region.
7604 This string must not take up any physical character positions on the display,
7605 so it should consist only of terminal escape sequences.
7606 It is output to the terminal after displaying the text in the active region.
7607 This variable is reset to the default value whenever the terminal type changes.
7608 The default value is the string that restores the terminal from standout mode,
7609 as obtained from the terminal's terminfo description.
7610 A sample value might be
<TT>"\e[
0m
"</TT>.
7611 <DT><B>bell-style (audible)
</B>
7614 Controls what happens when readline wants to ring the terminal bell.
7615 If set to
<B>none
</B>, readline never rings the bell. If set to
7616 <B>visible
</B>, readline uses a visible bell if one is available.
7617 If set to
<B>audible
</B>, readline attempts to ring the terminal's bell.
7618 <DT><B>bind-tty-special-chars (On)
</B>
7621 If set to
<B>On
</B>, readline attempts to bind the control characters
7622 treated specially by the kernel's terminal driver to their readline
7624 <DT><B>blink-matching-paren (Off)
</B>
7627 If set to
<B>On
</B>, readline attempts to briefly move the cursor to an
7628 opening parenthesis when a closing parenthesis is inserted.
7629 <DT><B>colored-completion-prefix (Off)
</B>
7632 If set to
<B>On
</B>, when listing completions, readline displays the
7633 common prefix of the set of possible completions using a different color.
7634 The color definitions are taken from the value of the
<B>LS_COLORS
</B>
7635 environment variable.
7636 If there is a color definition in
<B>$LS_COLORS
</B> for the custom suffix
7637 "readline-colored-completion-prefix
", readline uses this color for
7638 the common prefix instead of its default.
7639 <DT><B>colored-stats (Off)
</B>
7642 If set to
<B>On
</B>, readline displays possible completions using different
7643 colors to indicate their file type.
7644 The color definitions are taken from the value of the
<B>LS_COLORS
</B>
7645 environment variable.
7646 <DT><B>comment-begin (``#'')
</B>
7649 The string that is inserted when the readline
7650 <B>insert-comment
</B>
7652 command is executed.
7653 This command is bound to
7656 in emacs mode and to
7660 <DT><B>completion-display-width (-
1)
</B>
7663 The number of screen columns used to display possible matches
7664 when performing completion.
7665 The value is ignored if it is less than
0 or greater than the terminal
7667 A value of
0 will cause matches to be displayed one per line.
7668 The default value is -
1.
7669 <DT><B>completion-ignore-case (Off)
</B>
7672 If set to
<B>On
</B>, readline performs filename matching and completion
7673 in a case-insensitive fashion.
7674 <DT><B>completion-map-case (Off)
</B>
7677 If set to
<B>On
</B>, and
<B>completion-ignore-case
</B> is enabled, readline
7678 treats hyphens (
<I>-
</I>) and underscores (
<I>_
</I>) as equivalent when
7679 performing case-insensitive filename matching and completion.
7680 <DT><B>completion-prefix-display-length (
0)
</B>
7683 The length in characters of the common prefix of a list of possible
7684 completions that is displayed without modification. When set to a
7685 value greater than zero, common prefixes longer than this value are
7686 replaced with an ellipsis when displaying possible completions.
7687 <DT><B>completion-query-items (
100)
</B>
7690 This determines when the user is queried about viewing
7691 the number of possible completions
7692 generated by the
<B>possible-completions
</B> command.
7693 It may be set to any integer value greater than or equal to zero.
7694 If the number of possible completions is greater than
7695 or equal to the value of this variable,
7696 readline will ask whether or not the user wishes to view them;
7697 otherwise they are simply listed on the terminal.
7698 A zero value means readline should never ask; negative values are
7700 <DT><B>convert-meta (On)
</B>
7703 If set to
<B>On
</B>, readline will convert characters with the
7704 eighth bit set to an ASCII key sequence
7705 by stripping the eighth bit and prefixing an
7706 escape character (in effect, using escape as the
<I>meta prefix
</I>).
7707 The default is
<I>On
</I>, but readline will set it to
<I>Off
</I> if the
7708 locale contains eight-bit characters.
7709 This variable is dependent on the
<B>LC_CTYPE
</B> locale category, and
7710 may change if the locale is changed.
7711 <DT><B>disable-completion (Off)
</B>
7714 If set to
<B>On
</B>, readline will inhibit word completion. Completion
7715 characters will be inserted into the line as if they had been
7716 mapped to
<B>self-insert
</B>.
7717 <DT><B>echo-control-characters (On)
</B>
7720 When set to
<B>On
</B>, on operating systems that indicate they support it,
7721 readline echoes a character corresponding to a signal generated from the
7723 <DT><B>editing-mode (emacs)
</B>
7726 Controls whether readline begins with a set of key bindings similar
7727 to
<I>Emacs
</I> or
<I>vi
</I>.
7730 can be set to either
7736 <DT><B>emacs-mode-string (@)
</B>
7739 If the
<I>show-mode-in-prompt
</I> variable is enabled,
7740 this string is displayed immediately before the last line of the primary
7741 prompt when emacs editing mode is active. The value is expanded like a
7742 key binding, so the standard set of meta- and control prefixes and
7743 backslash escape sequences is available.
7744 Use the \
1 and \
2 escapes to begin and end sequences of
7745 non-printing characters, which can be used to embed a terminal control
7746 sequence into the mode string.
7747 <DT><B>enable-active-region (On)
</B>
7750 The
<I>point
</I> is the current cursor position, and
<I>mark
</I> refers
7751 to a saved cursor position.
7752 The text between the point and mark is referred to as the
<I>region
</I>.
7753 When this variable is set to
<I>On
</I>, readline allows certain commands
7754 to designate the region as
<I>active
</I>.
7755 When the region is active, readline highlights the text in the region using
7756 the value of the
<B>active-region-start-color
</B>, which defaults to the
7758 the terminal's standout mode.
7759 The active region shows the text inserted by bracketed-paste and any
7760 matching text found by incremental and non-incremental history searches.
7761 <DT><B>enable-bracketed-paste (On)
</B>
7764 When set to
<B>On
</B>, readline configures the terminal to insert each
7765 paste into the editing buffer as a single string of characters, instead
7766 of treating each character as if it had been read from the keyboard.
7767 This prevents readline from executing any editing commands bound to key
7768 sequences appearing in the pasted text.
7769 <DT><B>enable-keypad (Off)
</B>
7772 When set to
<B>On
</B>, readline will try to enable the application
7773 keypad when it is called. Some systems need this to enable the
7775 <DT><B>enable-meta-key (On)
</B>
7778 When set to
<B>On
</B>, readline will try to enable any meta modifier
7779 key the terminal claims to support when it is called. On many terminals,
7780 the meta key is used to send eight-bit characters.
7781 <DT><B>expand-tilde (Off)
</B>
7784 If set to
<B>On
</B>, tilde expansion is performed when readline
7785 attempts word completion.
7786 <DT><B>history-preserve-point (Off)
</B>
7789 If set to
<B>On
</B>, the history code attempts to place point at the
7790 same location on each history line retrieved with
<B>previous-history
</B>
7791 or
<B>next-history
</B>.
7792 <DT><B>history-size (unset)
</B>
7795 Set the maximum number of history entries saved in the history list.
7796 If set to zero, any existing history entries are deleted and no new entries
7798 If set to a value less than zero, the number of history entries is not
7800 By default, the number of history entries is set to the value of the
7801 <B>HISTSIZE
</B> shell variable.
7802 If an attempt is made to set
<I>history-size
</I> to a non-numeric value,
7803 the maximum number of history entries will be set to
500.
7804 <DT><B>horizontal-scroll-mode (Off)
</B>
7807 When set to
<B>On
</B>, makes readline use a single line for display,
7808 scrolling the input horizontally on a single screen line when it
7809 becomes longer than the screen width rather than wrapping to a new line.
7810 This setting is automatically enabled for terminals of height
1.
7811 <DT><B>input-meta (Off)
</B>
7814 If set to
<B>On
</B>, readline will enable eight-bit input (that is,
7815 it will not strip the eighth bit from the characters it reads),
7816 regardless of what the terminal claims it can support. The name
7819 is a synonym for this variable.
7820 The default is
<I>Off
</I>, but readline will set it to
<I>On
</I> if the
7821 locale contains eight-bit characters.
7822 This variable is dependent on the
<B>LC_CTYPE
</B> locale category, and
7823 may change if the locale is changed.
7824 <DT><B>isearch-terminators (``C-[C-J'')
</B>
7827 The string of characters that should terminate an incremental
7828 search without subsequently executing the character as a command.
7829 If this variable has not been given a value, the characters
7830 <I>ESC
</I> and
<I>C-J
</I> will terminate an incremental search.
7831 <DT><B>keymap (emacs)
</B>
7834 Set the current readline keymap. The set of valid keymap names is
7835 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
7839 <I>vi
</I> is equivalent to
<I>vi-command
</I>;
<I>emacs
</I> is
7840 equivalent to
<I>emacs-standard
</I>. The default value is
7846 also affects the default keymap.
7847 <DT><B>keyseq-timeout (
500)
</B>
7850 Specifies the duration
<I>readline
</I> will wait for a character when reading an
7851 ambiguous key sequence (one that can form a complete key sequence using
7852 the input read so far, or can take additional input to complete a longer
7854 If no input is received within the timeout,
<I>readline
</I> will use the shorter
7855 but complete key sequence.
7856 The value is specified in milliseconds, so a value of
1000 means that
7857 <I>readline
</I> will wait one second for additional input.
7858 If this variable is set to a value less than or equal to zero, or to a
7859 non-numeric value,
<I>readline
</I> will wait until another key is pressed to
7860 decide which key sequence to complete.
7861 <DT><B>mark-directories (On)
</B>
7864 If set to
<B>On
</B>, completed directory names have a slash
7866 <DT><B>mark-modified-lines (Off)
</B>
7869 If set to
<B>On
</B>, history lines that have been modified are displayed
7870 with a preceding asterisk (
<B>*
</B>).
7871 <DT><B>mark-symlinked-directories (Off)
</B>
7874 If set to
<B>On
</B>, completed names which are symbolic links to directories
7875 have a slash appended (subject to the value of
7876 <B>mark-directories
</B>).
7877 <DT><B>match-hidden-files (On)
</B>
7880 This variable, when set to
<B>On
</B>, causes readline to match files whose
7881 names begin with a `.' (hidden files) when performing filename
7883 If set to
<B>Off
</B>, the leading `.' must be
7884 supplied by the user in the filename to be completed.
7885 <DT><B>menu-complete-display-prefix (Off)
</B>
7888 If set to
<B>On
</B>, menu completion displays the common prefix of the
7889 list of possible completions (which may be empty) before cycling through
7891 <DT><B>output-meta (Off)
</B>
7894 If set to
<B>On
</B>, readline will display characters with the
7895 eighth bit set directly rather than as a meta-prefixed escape
7897 The default is
<I>Off
</I>, but readline will set it to
<I>On
</I> if the
7898 locale contains eight-bit characters.
7899 This variable is dependent on the
<B>LC_CTYPE
</B> locale category, and
7900 may change if the locale is changed.
7901 <DT><B>page-completions (On)
</B>
7904 If set to
<B>On
</B>, readline uses an internal
<I>more
</I>-like pager
7905 to display a screenful of possible completions at a time.
7906 <DT><B>print-completions-horizontally (Off)
</B>
7909 If set to
<B>On
</B>, readline will display completions with matches
7910 sorted horizontally in alphabetical order, rather than down the screen.
7911 <DT><B>revert-all-at-newline (Off)
</B>
7914 If set to
<B>On
</B>, readline will undo all changes to history lines
7915 before returning when
<B>accept-line
</B> is executed. By default,
7916 history lines may be modified and retain individual undo lists across
7917 calls to
<B>readline
</B>.
7918 <DT><B>show-all-if-ambiguous (Off)
</B>
7921 This alters the default behavior of the completion functions. If
7925 words which have more than one possible completion cause the
7926 matches to be listed immediately instead of ringing the bell.
7927 <DT><B>show-all-if-unmodified (Off)
</B>
7930 This alters the default behavior of the completion functions in
7931 a fashion similar to
<B>show-all-if-ambiguous
</B>.
7935 words which have more than one possible completion without any
7936 possible partial completion (the possible completions don't share
7937 a common prefix) cause the matches to be listed immediately instead
7938 of ringing the bell.
7939 <DT><B>show-mode-in-prompt (Off)
</B>
7942 If set to
<B>On
</B>, add a string to the beginning of the prompt
7943 indicating the editing mode: emacs, vi command, or vi insertion.
7944 The mode strings are user-settable (e.g.,
<I>emacs-mode-string
</I>).
7945 <DT><B>skip-completed-text (Off)
</B>
7948 If set to
<B>On
</B>, this alters the default completion behavior when
7949 inserting a single match into the line. It's only active when
7950 performing completion in the middle of a word. If enabled, readline
7951 does not insert characters from the completion that match characters
7952 after point in the word being completed, so portions of the word
7953 following the cursor are not duplicated.
7954 <DT><B>vi-cmd-mode-string ((cmd))
</B>
7957 If the
<I>show-mode-in-prompt
</I> variable is enabled,
7958 this string is displayed immediately before the last line of the primary
7959 prompt when vi editing mode is active and in command mode.
7960 The value is expanded like a
7961 key binding, so the standard set of meta- and control prefixes and
7962 backslash escape sequences is available.
7963 Use the \
1 and \
2 escapes to begin and end sequences of
7964 non-printing characters, which can be used to embed a terminal control
7965 sequence into the mode string.
7966 <DT><B>vi-ins-mode-string ((ins))
</B>
7969 If the
<I>show-mode-in-prompt
</I> variable is enabled,
7970 this string is displayed immediately before the last line of the primary
7971 prompt when vi editing mode is active and in insertion mode.
7972 The value is expanded like a
7973 key binding, so the standard set of meta- and control prefixes and
7974 backslash escape sequences is available.
7975 Use the \
1 and \
2 escapes to begin and end sequences of
7976 non-printing characters, which can be used to embed a terminal control
7977 sequence into the mode string.
7978 <DT><B>visible-stats (Off)
</B>
7981 If set to
<B>On
</B>, a character denoting a file's type as reported
7982 by
<I>stat
</I>(
2) is appended to the filename when listing possible
7986 <A NAME=
"lbCK"> </A>
7987 <H4>Readline Conditional Constructs
</H4>
7989 Readline implements a facility similar in spirit to the conditional
7990 compilation features of the C preprocessor which allows key
7991 bindings and variable settings to be performed as the result
7992 of tests. There are four parser directives used.
7998 construct allows bindings to be made based on the
7999 editing mode, the terminal being used, or the application using
8000 readline. The text of the test, after any comparison operator,
8001 <BR> extends
to
the
end
of
the
line;
8002 unless otherwise noted, no characters are required to isolate it.
8003 <DL COMPACT
><DT><DD>
8006 The
<B>mode=
</B> form of the
<B>$if
</B> directive is used to test
8007 whether readline is in emacs or vi mode.
8008 This may be used in conjunction
8009 with the
<B>set keymap
</B> command, for instance, to set bindings in
8010 the
<I>emacs-standard
</I> and
<I>emacs-ctlx
</I> keymaps only if
8011 readline is starting out in emacs mode.
8013 The
<B>term=
</B> form may be used to include terminal-specific
8014 key bindings, perhaps to bind the key sequences output by the
8015 terminal's function keys. The word on the right side of the
8018 is tested against both the full name of the terminal and the portion
8019 of the terminal name before the first
<B>-
</B>. This allows
8029 <DT><B>version
</B><DD>
8030 The
<B>version
</B> test may be used to perform comparisons against
8031 specific readline versions.
8032 The
<B>version
</B> expands to the current readline version.
8033 The set of comparison operators includes
8050 The version number supplied on the right side of the operator consists
8051 of a major version number, an optional decimal point, and an optional
8052 minor version (e.g.,
<B>7.1</B>). If the minor version is omitted, it
8053 is assumed to be
<B>0</B>.
8054 The operator may be separated from the string
<B>version
</B>
8055 and from the version number argument by whitespace.
8056 <DT><B>application
</B><DD>
8057 The
<B>application
</B> construct is used to include
8058 application-specific settings. Each program using the readline
8059 library sets the
<I>application name
</I>, and an initialization
8060 file can test for a particular value.
8061 This could be used to bind key sequences to functions useful for
8062 a specific program. For instance, the following command adds a
8063 key sequence that quotes the current or previous word in
<B>bash
</B>:
8065 <DL COMPACT
><DT><DD>
8068 # Quote the current or previous word
8069 "\C-xq
":
"\eb\
"\ef\
""
8075 <DT><I>variable
</I><DD>
8076 The
<I>variable
</I> construct provides simple equality tests for readline
8077 variables and values.
8078 The permitted comparison operators are
<I>=
</I>,
<I>==
</I>, and
<I>!=
</I>.
8079 The variable name must be separated from the comparison operator by
8080 whitespace; the operator may be separated from the value on the right hand
8082 Both string and boolean variables may be tested. Boolean variables must be
8083 tested against the values
<I>on
</I> and
<I>off
</I>.
8086 <DT><B>$endif
</B><DD>
8087 This command, as seen in the previous example, terminates an
8089 <DT><B>$else
</B><DD>
8090 Commands in this branch of the
<B>$if
</B> directive are executed if
8092 <DT><B>$include
</B><DD>
8093 This directive takes a single filename as an argument and reads commands
8094 and bindings from that file. For example, the following directive
8095 would read
<A HREF=
"file:/etc/inputrc"><I>/etc/inputrc
</I></A>:
8097 <DL COMPACT
><DT><DD>
8099 <B>$include
</B> <A HREF=
"file:/etc/inputrc"><I>/etc/inputrc
</I></A>
8105 <A NAME=
"lbCL"> </A>
8108 Readline provides commands for searching through the command history
8110 <FONT SIZE=-
1><B>HISTORY
</B>
8113 below) for lines containing a specified string.
8114 There are two search modes:
8118 <I>non-incremental
</I>.
8122 Incremental searches begin before the user has finished typing the
8124 As each character of the search string is typed, readline displays
8125 the next entry from the history matching the string typed so far.
8126 An incremental search requires only as many characters as needed to
8127 find the desired history entry.
8128 The characters present in the value of the
<B>isearch-terminators
</B>
8129 variable are used to terminate an incremental search.
8130 If that variable has not been assigned a value the Escape and
8131 Control-J characters will terminate an incremental search.
8132 Control-G will abort an incremental search and restore the original
8134 When the search is terminated, the history entry containing the
8135 search string becomes the current line.
8138 To find other matching entries in the history list, type Control-S or
8139 Control-R as appropriate.
8140 This will search backward or forward in the history for the next
8141 entry matching the search string typed so far.
8142 Any other key sequence bound to a readline command will terminate
8143 the search and execute that command.
8144 For instance, a
<I>newline
</I> will terminate the search and accept
8145 the line, thereby executing the command from the history list.
8148 Readline remembers the last incremental search string. If two
8149 Control-Rs are typed without any intervening characters defining a
8150 new search string, any remembered search string is used.
8153 Non-incremental searches read the entire search string before starting
8154 to search for matching history lines. The search string may be
8155 typed by the user or be part of the contents of the current line.
8156 <A NAME=
"lbCM"> </A>
8157 <H4>Readline Command Names
</H4>
8159 The following is a list of the names of the commands and the default
8160 key sequences to which they are bound.
8161 Command names without an accompanying key sequence are unbound by default.
8162 In the following descriptions,
<I>point
</I> refers to the current cursor
8163 position, and
<I>mark
</I> refers to a cursor position saved by the
8164 <B>set-mark
</B> command.
8165 The text between the point and mark is referred to as the
<I>region
</I>.
8166 <A NAME=
"lbCN"> </A>
8167 <H4>Commands for Moving
</H4>
8171 <DT><B>beginning-of-line (C-a)
</B>
8174 Move to the start of the current line.
8175 <DT><B>end-of-line (C-e)
</B>
8178 Move to the end of the line.
8179 <DT><B>forward-char (C-f)
</B>
8182 Move forward a character.
8183 <DT><B>backward-char (C-b)
</B>
8186 Move back a character.
8187 <DT><B>forward-word (M-f)
</B>
8190 Move forward to the end of the next word. Words are composed of
8191 alphanumeric characters (letters and digits).
8192 <DT><B>backward-word (M-b)
</B>
8195 Move back to the start of the current or previous word.
8196 Words are composed of alphanumeric characters (letters and digits).
8197 <DT><B>shell-forward-word
</B>
8200 Move forward to the end of the next word.
8201 Words are delimited by non-quoted shell metacharacters.
8202 <DT><B>shell-backward-word
</B>
8205 Move back to the start of the current or previous word.
8206 Words are delimited by non-quoted shell metacharacters.
8207 <DT><B>previous-screen-line
</B>
8210 Attempt to move point to the same physical screen column on the previous
8211 physical screen line. This will not have the desired effect if the current
8212 readline line does not take up more than one physical line or if point is not
8213 greater than the length of the prompt plus the screen width.
8214 <DT><B>next-screen-line
</B>
8217 Attempt to move point to the same physical screen column on the next
8218 physical screen line. This will not have the desired effect if the current
8219 readline line does not take up more than one physical line or if the length
8220 of the current readline line is not greater than the length of the prompt
8221 plus the screen width.
8222 <DT><B>clear-display (M-C-l)
</B>
8225 Clear the screen and, if possible, the terminal's scrollback buffer,
8226 then redraw the current line,
8227 leaving the current line at the top of the screen.
8228 <DT><B>clear-screen (C-l)
</B>
8232 then redraw the current line,
8233 leaving the current line at the top of the screen.
8234 With an argument, refresh the current line without clearing the
8236 <DT><B>redraw-current-line
</B>
8239 Refresh the current line.
8242 <A NAME=
"lbCO"> </A>
8243 <H4>Commands for Manipulating the History
</H4>
8247 <DT><B>accept-line (Newline, Return)
</B>
8250 Accept the line regardless of where the cursor is. If this line is
8251 non-empty, add it to the history list according to the state of the
8252 <FONT SIZE=-
1><B>HISTCONTROL
</B>
8255 variable. If the line is a modified history
8256 line, then restore the history line to its original state.
8257 <DT><B>previous-history (C-p)
</B>
8260 Fetch the previous command from the history list, moving back in
8262 <DT><B>next-history (C-n)
</B>
8265 Fetch the next command from the history list, moving forward in the
8267 <DT><B>beginning-of-history (M-
<)
</B>
8270 Move to the first line in the history.
8271 <DT><B>end-of-history (M-
>)
</B>
8274 Move to the end of the input history, i.e., the line currently being
8276 <DT><B>operate-and-get-next (C-o)
</B>
8279 Accept the current line for execution and fetch the next line
8280 relative to the current line from the history for editing.
8281 A numeric argument, if supplied, specifies the history entry to use instead
8282 of the current line.
8283 <DT><B>fetch-history
</B>
8286 With a numeric argument, fetch that entry from the history list
8287 and make it the current line.
8288 Without an argument, move back to the first entry in the history list.
8289 <DT><B>reverse-search-history (C-r)
</B>
8292 Search backward starting at the current line and moving `up' through
8293 the history as necessary. This is an incremental search.
8294 <DT><B>forward-search-history (C-s)
</B>
8297 Search forward starting at the current line and moving `down' through
8298 the history as necessary. This is an incremental search.
8299 <DT><B>non-incremental-reverse-search-history (M-p)
</B>
8302 Search backward through the history starting at the current line
8303 using a non-incremental search for a string supplied by the user.
8304 <DT><B>non-incremental-forward-search-history (M-n)
</B>
8307 Search forward through the history using a non-incremental search for
8308 a string supplied by the user.
8309 <DT><B>history-search-forward
</B>
8312 Search forward through the history for the string of characters
8313 between the start of the current line and the point.
8314 This is a non-incremental search.
8315 <DT><B>history-search-backward
</B>
8318 Search backward through the history for the string of characters
8319 between the start of the current line and the point.
8320 This is a non-incremental search.
8321 <DT><B>history-substring-search-backward
</B>
8324 Search backward through the history for the string of characters
8325 between the start of the current line and the current cursor
8326 position (the
<I>point
</I>).
8327 The search string may match anywhere in a history line.
8328 This is a non-incremental search.
8329 <DT><B>history-substring-search-forward
</B>
8332 Search forward through the history for the string of characters
8333 between the start of the current line and the point.
8334 The search string may match anywhere in a history line.
8335 This is a non-incremental search.
8336 <DT><B>yank-nth-arg (M-C-y)
</B>
8339 Insert the first argument to the previous command (usually
8340 the second word on the previous line) at point.
8344 insert the
<I>n
</I>th word from the previous command (the words
8345 in the previous command begin with word
0). A negative argument
8346 inserts the
<I>n
</I>th word from the end of the previous command.
8347 Once the argument
<I>n
</I> is computed, the argument is extracted
8348 as if the
"!
<I>n
</I>" history expansion had been specified.
8349 <DT><B>yank-last-arg (M-., M-_)
</B>
8352 Insert the last argument to the previous command (the last word of
8353 the previous history entry).
8354 With a numeric argument, behave exactly like
<B>yank-nth-arg
</B>.
8355 Successive calls to
<B>yank-last-arg
</B> move back through the history
8356 list, inserting the last word (or the word specified by the argument to
8357 the first call) of each line in turn.
8358 Any numeric argument supplied to these successive calls determines
8359 the direction to move through the history. A negative argument switches
8360 the direction through the history (back or forward).
8361 The history expansion facilities are used to extract the last word,
8362 as if the
"!$
" history expansion had been specified.
8363 <DT><B>shell-expand-line (M-C-e)
</B>
8366 Expand the line as the shell does. This
8367 performs alias and history expansion as well as all of the shell
8368 word expansions. See
8369 <FONT SIZE=-
1><B>HISTORY EXPANSION
</B>
8372 below for a description of history expansion.
8373 <DT><B>history-expand-line (M-^)
</B>
8376 Perform history expansion on the current line.
8378 <FONT SIZE=-
1><B>HISTORY EXPANSION
</B>
8381 below for a description of history expansion.
8382 <DT><B>magic-space
</B>
8385 Perform history expansion on the current line and insert a space.
8387 <FONT SIZE=-
1><B>HISTORY EXPANSION
</B>
8390 below for a description of history expansion.
8391 <DT><B>alias-expand-line
</B>
8394 Perform alias expansion on the current line.
8396 <FONT SIZE=-
1><B>ALIASES
</B>
8399 above for a description of alias expansion.
8400 <DT><B>history-and-alias-expand-line
</B>
8403 Perform history and alias expansion on the current line.
8404 <DT><B>insert-last-argument (M-., M-_)
</B>
8407 A synonym for
<B>yank-last-arg
</B>.
8408 <DT><B>edit-and-execute-command (C-x C-e)
</B>
8411 Invoke an editor on the current command line, and execute the result as shell
8413 <B>Bash
</B> attempts to invoke
8414 <FONT SIZE=-
1><B>$VISUAL
</B>,
8417 <FONT SIZE=-
1><B>$EDITOR
</B>,
8420 and
<I>emacs
</I> as the editor, in that order.
8423 <A NAME=
"lbCP"> </A>
8424 <H4>Commands for Changing Text
</H4>
8428 <DT><B></B><I>end-of-file
</I> (usually C-d)
8431 The character indicating end-of-file as set, for example, by
8434 If this character is read when there are no characters
8435 on the line, and point is at the beginning of the line, readline
8436 interprets it as the end of input and returns
8437 <FONT SIZE=-
1><B>EOF
</B>.
8440 <DT><B>delete-char (C-d)
</B>
8443 Delete the character at point.
8444 If this function is bound to the
8445 same character as the tty
<B>EOF
</B> character, as
<B>C-d
</B>
8446 commonly is, see above for the effects.
8447 <DT><B>backward-delete-char (Rubout)
</B>
8450 Delete the character behind the cursor. When given a numeric argument,
8451 save the deleted text on the kill ring.
8452 <DT><B>forward-backward-delete-char
</B>
8455 Delete the character under the cursor, unless the cursor is at the
8456 end of the line, in which case the character behind the cursor is
8458 <DT><B>quoted-insert (C-q, C-v)
</B>
8461 Add the next character typed to the line verbatim. This is
8462 how to insert characters like
<B>C-q
</B>, for example.
8463 <DT><B>tab-insert (C-v TAB)
</B>
8466 Insert a tab character.
8467 <DT><B>self-insert (a,
b,
A,
1,
!,
...)
</B>
8470 Insert the character typed.
8471 <DT><B>transpose-chars (C-t)
</B>
8474 Drag the character before point forward over the character at point,
8475 moving point forward as well.
8476 If point is at the end of the line, then this transposes
8477 the two characters before point.
8478 Negative arguments have no effect.
8479 <DT><B>transpose-words (M-t)
</B>
8482 Drag the word before point past the word after point,
8483 moving point over that word as well.
8484 If point is at the end of the line, this transposes
8485 the last two words on the line.
8486 <DT><B>upcase-word (M-u)
</B>
8489 Uppercase the current (or following) word. With a negative argument,
8490 uppercase the previous word, but do not move point.
8491 <DT><B>downcase-word (M-l)
</B>
8494 Lowercase the current (or following) word. With a negative argument,
8495 lowercase the previous word, but do not move point.
8496 <DT><B>capitalize-word (M-c)
</B>
8499 Capitalize the current (or following) word. With a negative argument,
8500 capitalize the previous word, but do not move point.
8501 <DT><B>overwrite-mode
</B>
8504 Toggle overwrite mode. With an explicit positive numeric argument,
8505 switches to overwrite mode. With an explicit non-positive numeric
8506 argument, switches to insert mode. This command affects only
8507 <B>emacs
</B> mode;
<B>vi
</B> mode does overwrite differently.
8508 Each call to
<I>readline()
</I> starts in insert mode.
8509 In overwrite mode, characters bound to
<B>self-insert
</B> replace
8510 the text at point rather than pushing the text to the right.
8511 Characters bound to
<B>backward-delete-char
</B> replace the character
8512 before point with a space. By default, this command is unbound.
8515 <A NAME=
"lbCQ"> </A>
8516 <H4>Killing and Yanking
</H4>
8520 <DT><B>kill-line (C-k)
</B>
8523 Kill the text from point to the end of the line.
8524 <DT><B>backward-kill-line (C-x Rubout)
</B>
8527 Kill backward to the beginning of the line.
8528 <DT><B>unix-line-discard (C-u)
</B>
8531 Kill backward from point to the beginning of the line.
8532 The killed text is saved on the kill-ring.
8534 <DT><B>kill-whole-line
</B>
8537 Kill all characters on the current line, no matter where point is.
8538 <DT><B>kill-word (M-d)
</B>
8541 Kill from point to the end of the current word, or if between
8542 words, to the end of the next word.
8543 Word boundaries are the same as those used by
<B>forward-word
</B>.
8544 <DT><B>backward-kill-word (M-Rubout)
</B>
8547 Kill the word behind point.
8548 Word boundaries are the same as those used by
<B>backward-word
</B>.
8549 <DT><B>shell-kill-word
</B>
8552 Kill from point to the end of the current word, or if between
8553 words, to the end of the next word.
8554 Word boundaries are the same as those used by
<B>shell-forward-word
</B>.
8555 <DT><B>shell-backward-kill-word
</B>
8558 Kill the word behind point.
8559 Word boundaries are the same as those used by
<B>shell-backward-word
</B>.
8560 <DT><B>unix-word-rubout (C-w)
</B>
8563 Kill the word behind point, using white space as a word boundary.
8564 The killed text is saved on the kill-ring.
8565 <DT><B>unix-filename-rubout
</B>
8568 Kill the word behind point, using white space and the slash character
8569 as the word boundaries.
8570 The killed text is saved on the kill-ring.
8571 <DT><B>delete-horizontal-space (M-\)
</B>
8574 Delete all spaces and tabs around point.
8575 <DT><B>kill-region
</B>
8578 Kill the text in the current region.
8579 <DT><B>copy-region-as-kill
</B>
8582 Copy the text in the region to the kill buffer.
8583 <DT><B>copy-backward-word
</B>
8586 Copy the word before point to the kill buffer.
8587 The word boundaries are the same as
<B>backward-word
</B>.
8588 <DT><B>copy-forward-word
</B>
8591 Copy the word following point to the kill buffer.
8592 The word boundaries are the same as
<B>forward-word
</B>.
8593 <DT><B>yank (C-y)
</B>
8596 Yank the top of the kill ring into the buffer at point.
8597 <DT><B>yank-pop (M-y)
</B>
8600 Rotate the kill ring, and yank the new top. Only works following
8608 <A NAME=
"lbCR"> </A>
8609 <H4>Numeric Arguments
</H4>
8613 <DT><B>digit-argument (M-
0, M-
1, ..., M--)
</B>
8616 Add this digit to the argument already accumulating, or start a new
8617 argument. M-- starts a negative argument.
8618 <DT><B>universal-argument
</B>
8621 This is another way to specify an argument.
8622 If this command is followed by one or more digits, optionally with a
8623 leading minus sign, those digits define the argument.
8624 If the command is followed by digits, executing
8625 <B>universal-argument
</B>
8627 again ends the numeric argument, but is otherwise ignored.
8628 As a special case, if this command is immediately followed by a
8629 character that is neither a digit nor minus sign, the argument count
8630 for the next command is multiplied by four.
8631 The argument count is initially one, so executing this function the
8632 first time makes the argument count four, a second time makes the
8633 argument count sixteen, and so on.
8636 <A NAME=
"lbCS"> </A>
8641 <DT><B>complete (TAB)
</B>
8644 Attempt to perform completion on the text before point.
8647 attempts completion treating the text as a variable (if the
8648 text begins with
<B>$
</B>), username (if the text begins with
8649 <B>~
</B>), hostname (if the text begins with
<B>@
</B>), or
8650 command (including aliases and functions) in turn. If none
8651 of these produces a match, filename completion is attempted.
8652 <DT><B>possible-completions (M-?)
</B>
8655 List the possible completions of the text before point.
8656 <DT><B>insert-completions (M-*)
</B>
8659 Insert all completions of the text before point
8660 that would have been generated by
8661 <B>possible-completions
</B>.
8662 <DT><B>menu-complete
</B>
8665 Similar to
<B>complete
</B>, but replaces the word to be completed
8666 with a single match from the list of possible completions.
8667 Repeated execution of
<B>menu-complete
</B> steps through the list
8668 of possible completions, inserting each match in turn.
8669 At the end of the list of completions, the bell is rung
8670 (subject to the setting of
<B>bell-style
</B>)
8671 and the original text is restored.
8672 An argument of
<I>n
</I> moves
<I>n
</I> positions forward in the list
8673 of matches; a negative argument may be used to move backward
8675 This command is intended to be bound to
<B>TAB
</B>, but is unbound
8677 <DT><B>menu-complete-backward
</B>
8680 Identical to
<B>menu-complete
</B>, but moves backward through the list
8681 of possible completions, as if
<B>menu-complete
</B> had been given a
8682 negative argument. This command is unbound by default.
8683 <DT><B>delete-char-or-list
</B>
8686 Deletes the character under the cursor if not at the beginning or
8687 end of the line (like
<B>delete-char
</B>).
8688 If at the end of the line, behaves identically to
8689 <B>possible-completions
</B>.
8690 This command is unbound by default.
8691 <DT><B>complete-filename (M-/)
</B>
8694 Attempt filename completion on the text before point.
8695 <DT><B>possible-filename-completions (C-x /)
</B>
8698 List the possible completions of the text before point,
8699 treating it as a filename.
8700 <DT><B>complete-username (M-~)
</B>
8703 Attempt completion on the text before point, treating
8705 <DT><B>possible-username-completions (C-x ~)
</B>
8708 List the possible completions of the text before point,
8709 treating it as a username.
8710 <DT><B>complete-variable (M-$)
</B>
8713 Attempt completion on the text before point, treating
8714 it as a shell variable.
8715 <DT><B>possible-variable-completions (C-x $)
</B>
8718 List the possible completions of the text before point,
8719 treating it as a shell variable.
8720 <DT><B>complete-hostname (M-@)
</B>
8723 Attempt completion on the text before point, treating
8725 <DT><B>possible-hostname-completions (C-x @)
</B>
8728 List the possible completions of the text before point,
8729 treating it as a hostname.
8730 <DT><B>complete-command (M-!)
</B>
8733 Attempt completion on the text before point, treating
8734 it as a command name. Command completion attempts to
8735 match the text against aliases, reserved words, shell
8736 functions, shell builtins, and finally executable filenames,
8738 <DT><B>possible-command-completions (C-x !)
</B>
8741 List the possible completions of the text before point,
8742 treating it as a command name.
8743 <DT><B>dynamic-complete-history (M-TAB)
</B>
8746 Attempt completion on the text before point, comparing
8747 the text against lines from the history list for possible
8749 <DT><B>dabbrev-expand
</B>
8752 Attempt menu completion on the text before point, comparing
8753 the text against lines from the history list for possible
8755 <DT><B>complete-into-braces (M-{)
</B>
8758 Perform filename completion and insert the list of possible completions
8759 enclosed within braces so the list is available to the shell (see
8760 <B>Brace Expansion
</B>
8765 <A NAME=
"lbCT"> </A>
8766 <H4>Keyboard Macros
</H4>
8770 <DT><B>start-kbd-macro (C-x ()
</B>
8773 Begin saving the characters typed into the current keyboard macro.
8774 <DT><B>end-kbd-macro (C-x ))
</B>
8777 Stop saving the characters typed into the current keyboard macro
8778 and store the definition.
8779 <DT><B>call-last-kbd-macro (C-x e)
</B>
8782 Re-execute the last keyboard macro defined, by making the characters
8783 in the macro appear as if typed at the keyboard.
8784 <DT><B>print-last-kbd-macro ()
</B>
8787 Print the last keyboard macro defined in a format suitable for the
8788 <I>inputrc
</I> file.
8791 <A NAME=
"lbCU"> </A>
8792 <H4>Miscellaneous
</H4>
8796 <DT><B>re-read-init-file (C-x C-r)
</B>
8799 Read in the contents of the
<I>inputrc
</I> file, and incorporate
8800 any bindings or variable assignments found there.
8801 <DT><B>abort (C-g)
</B>
8804 Abort the current editing command and
8805 ring the terminal's bell (subject to the setting of
8808 <DT><B>do-lowercase-version (M-A, M-B, M-
</B><I>x
</I>, ...)
8811 If the metafied character
<I>x
</I> is uppercase, run the command
8812 that is bound to the corresponding metafied lowercase character.
8813 The behavior is undefined if
<I>x
</I> is already lowercase.
8814 <DT><B>prefix-meta (ESC)
</B>
8817 Metafy the next character typed.
8818 <FONT SIZE=-
1><B>ESC
</B>
8826 <DT><B>undo (C-_, C-x C-u)
</B>
8829 Incremental undo, separately remembered for each line.
8830 <DT><B>revert-line (M-r)
</B>
8833 Undo all changes made to this line. This is like executing the
8836 command enough times to return the line to its initial state.
8837 <DT><B>tilde-expand (M-
&)
</B>
8840 Perform tilde expansion on the current word.
8841 <DT><B>set-mark (C-@, M-
<space
>)
</B>
8844 Set the mark to the point. If a
8845 numeric argument is supplied, the mark is set to that position.
8846 <DT><B>exchange-point-and-mark (C-x C-x)
</B>
8849 Swap the point with the mark. The current cursor position is set to
8850 the saved position, and the old cursor position is saved as the mark.
8851 <DT><B>character-search (C-])
</B>
8854 A character is read and point is moved to the next occurrence of that
8855 character. A negative argument searches for previous occurrences.
8856 <DT><B>character-search-backward (M-C-])
</B>
8859 A character is read and point is moved to the previous occurrence of that
8860 character. A negative argument searches for subsequent occurrences.
8861 <DT><B>skip-csi-sequence
</B>
8864 Read enough characters to consume a multi-key sequence such as those
8865 defined for keys like Home and End. Such sequences begin with a
8866 Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
8867 bound to
"\[
", keys producing such sequences will have no effect
8868 unless explicitly bound to a readline command, instead of inserting
8869 stray characters into the editing buffer. This is unbound by default,
8870 but usually bound to ESC-[.
8871 <DT><B>insert-comment (M-#)
</B>
8874 Without a numeric argument, the value of the readline
8875 <B>comment-begin
</B>
8877 variable is inserted at the beginning of the current line.
8878 If a numeric argument is supplied, this command acts as a toggle: if
8879 the characters at the beginning of the line do not match the value
8880 of
<B>comment-begin
</B>, the value is inserted, otherwise
8881 the characters in
<B>comment-begin
</B> are deleted from the beginning of
8883 In either case, the line is accepted as if a newline had been typed.
8884 The default value of
8885 <B>comment-begin
</B> causes this command to make the current line
8887 If a numeric argument causes the comment character to be removed, the line
8888 will be executed by the shell.
8889 <DT><B>spell-correct-word (C-x s)
</B>
8892 Perform spelling correction on the current word, treating it as a directory
8893 or filename, in the same way as the
<B>cdspell
</B> shell option.
8894 Word boundaries are the same as those used by
<B>shell-forward-word
</B>.
8895 <DT><B>glob-complete-word (M-g)
</B>
8898 The word before point is treated as a pattern for pathname expansion,
8899 with an asterisk implicitly appended. This pattern is used to
8900 generate a list of matching filenames for possible completions.
8901 <DT><B>glob-expand-word (C-x *)
</B>
8904 The word before point is treated as a pattern for pathname expansion,
8905 and the list of matching filenames is inserted, replacing the word.
8906 If a numeric argument is supplied, an asterisk is appended before
8908 <DT><B>glob-list-expansions (C-x g)
</B>
8911 The list of expansions that would have been generated by
8912 <B>glob-expand-word
</B>
8914 is displayed, and the line is redrawn.
8915 If a numeric argument is supplied, an asterisk is appended before
8917 <DT><B>dump-functions
</B>
8920 Print all of the functions and their key bindings to the
8921 readline output stream. If a numeric argument is supplied,
8922 the output is formatted in such a way that it can be made part
8923 of an
<I>inputrc
</I> file.
8924 <DT><B>dump-variables
</B>
8927 Print all of the settable readline variables and their values to the
8928 readline output stream. If a numeric argument is supplied,
8929 the output is formatted in such a way that it can be made part
8930 of an
<I>inputrc
</I> file.
8931 <DT><B>dump-macros
</B>
8934 Print all of the readline key sequences bound to macros and the
8935 strings they output. If a numeric argument is supplied,
8936 the output is formatted in such a way that it can be made part
8937 of an
<I>inputrc
</I> file.
8938 <DT><B>display-shell-version (C-x C-v)
</B>
8941 Display version information about the current instance of
8946 <A NAME=
"lbCV"> </A>
8947 <H4>Programmable Completion
</H4>
8949 When word completion is attempted for an argument to a command for
8950 which a completion specification (a
<I>compspec
</I>) has been defined
8951 using the
<B>complete
</B> builtin (see
8952 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
8955 below), the programmable completion facilities are invoked.
8958 First, the command name is identified.
8959 If the command word is the empty string (completion attempted at the
8960 beginning of an empty line), any compspec defined with
8961 the
<B>-E
</B> option to
<B>complete
</B> is used.
8962 If a compspec has been defined for that command, the
8963 compspec is used to generate the list of possible completions for the word.
8964 If the command word is a full pathname, a compspec for the full
8965 pathname is searched for first.
8966 If no compspec is found for the full pathname, an attempt is made to
8967 find a compspec for the portion following the final slash.
8968 If those searches do not result in a compspec, any compspec defined with
8969 the
<B>-D
</B> option to
<B>complete
</B> is used as the default.
8970 If there is no default compspec,
<B>bash
</B> attempts alias expansion
8971 on the command word as a final resort, and attempts to find a compspec
8972 for the command word from any successful expansion.
8975 Once a compspec has been found, it is used to generate the list of
8977 If a compspec is not found, the default
<B>bash
</B> completion as
8978 described above under
<B>Completing
</B> is performed.
8981 First, the actions specified by the compspec are used.
8982 Only matches which are prefixed by the word being completed are
8990 option is used for filename or directory name completion, the shell
8992 <FONT SIZE=-
1><B>FIGNORE
</B>
8995 is used to filter the matches.
8998 Any completions specified by a pathname expansion pattern to the
8999 <B>-G
</B> option are generated next.
9000 The words generated by the pattern need not match the word
9003 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
9006 shell variable is not used to filter the matches, but the
9007 <FONT SIZE=-
1><B>FIGNORE
</B>
9013 Next, the string specified as the argument to the
<B>-W
</B> option
9015 The string is first split using the characters in the
9016 <FONT SIZE=-
1><B>IFS
</B>
9019 special variable as delimiters.
9020 Shell quoting is honored.
9021 Each word is then expanded using
9022 brace expansion, tilde expansion, parameter and variable expansion,
9023 command substitution, and arithmetic expansion,
9024 as described above under
9025 <FONT SIZE=-
1><B>EXPANSION
</B>.
9028 The results are split using the rules described above under
9029 <B>Word Splitting
</B>.
9030 The results of the expansion are prefix-matched against the word being
9031 completed, and the matching words become the possible completions.
9034 After these matches have been generated, any shell function or command
9035 specified with the
<B>-F
</B> and
<B>-C
</B> options is invoked.
9036 When the command or function is invoked, the
9037 <FONT SIZE=-
1><B>COMP_LINE
</B>,
9040 <FONT SIZE=-
1><B>COMP_POINT
</B>,
9043 <FONT SIZE=-
1><B>COMP_KEY
</B>,
9047 <FONT SIZE=-
1><B>COMP_TYPE
</B>
9050 variables are assigned values as described above under
9051 <B>Shell Variables
</B>.
9052 If a shell function is being invoked, the
9053 <FONT SIZE=-
1><B>COMP_WORDS
</B>
9057 <FONT SIZE=-
1><B>COMP_CWORD
</B>
9060 variables are also set.
9061 When the function or command is invoked,
9062 the first argument (
<B>$
1</B>) is the name of the command whose arguments are
9064 the second argument (
<B>$
2</B>) is the word being completed,
9065 and the third argument (
<B>$
3</B>) is the word preceding the word being
9066 completed on the current command line.
9067 No filtering of the generated completions against the word being completed
9068 is performed; the function or command has complete freedom in generating
9072 Any function specified with
<B>-F
</B> is invoked first.
9073 The function may use any of the shell facilities, including the
9074 <B>compgen
</B> builtin described below, to generate the matches.
9075 It must put the possible completions in the
9076 <FONT SIZE=-
1><B>COMPREPLY
</B>
9079 array variable, one per array element.
9082 Next, any command specified with the
<B>-C
</B> option is invoked
9083 in an environment equivalent to command substitution.
9084 It should print a list of completions, one per line, to the
9086 Backslash may be used to escape a newline, if necessary.
9089 After all of the possible completions are generated, any filter
9090 specified with the
<B>-X
</B> option is applied to the list.
9091 The filter is a pattern as used for pathname expansion; a
<B>&</B>
9092 in the pattern is replaced with the text of the word being completed.
9093 A literal
<B>&</B> may be escaped with a backslash; the backslash
9094 is removed before attempting a match.
9095 Any completion that matches the pattern will be removed from the list.
9096 A leading
<B>!
</B> negates the pattern; in this case any completion
9097 not matching the pattern will be removed.
9101 shell option is enabled, the match is performed without regard to the case
9102 of alphabetic characters.
9105 Finally, any prefix and suffix specified with the
<B>-P
</B> and
<B>-S
</B>
9106 options are added to each member of the completion list, and the result is
9107 returned to the readline completion code as the list of possible
9111 If the previously-applied actions do not generate any matches, and the
9112 <B>-o dirnames
</B> option was supplied to
<B>complete
</B> when the
9113 compspec was defined, directory name completion is attempted.
9116 If the
<B>-o plusdirs
</B> option was supplied to
<B>complete
</B> when the
9117 compspec was defined, directory name completion is attempted and any
9118 matches are added to the results of the other actions.
9121 By default, if a compspec is found, whatever it generates is returned
9122 to the completion code as the full set of possible completions.
9123 The default
<B>bash
</B> completions are not attempted, and the readline
9124 default of filename completion is disabled.
9125 If the
<B>-o bashdefault
</B> option was supplied to
<B>complete
</B> when
9126 the compspec was defined, the
<B>bash
</B> default completions are attempted
9127 if the compspec generates no matches.
9128 If the
<B>-o default
</B> option was supplied to
<B>complete
</B> when the
9129 compspec was defined, readline's default completion will be performed
9130 if the compspec (and, if attempted, the default
<B>bash
</B> completions)
9131 generate no matches.
9134 When a compspec indicates that directory name completion is desired,
9135 the programmable completion functions force readline to append a slash
9136 to completed names which are symbolic links to directories, subject to
9137 the value of the
<B>mark-directories
</B> readline variable, regardless
9138 of the setting of the
<B>mark-symlinked-directories
</B> readline variable.
9141 There is some support for dynamically modifying completions. This is
9142 most useful when used in combination with a default completion specified
9143 with
<B>complete -D
</B>.
9144 It's possible for shell functions executed as completion
9145 handlers to indicate that completion should be retried by returning an
9146 exit status of
124. If a shell function returns
124, and changes
9147 the compspec associated with the command on which completion is being
9148 attempted (supplied as the first argument when the function is executed),
9149 programmable completion restarts from the beginning, with an
9150 attempt to find a new compspec for that command. This allows a set of
9151 completions to be built dynamically as completion is attempted, rather than
9152 being loaded all at once.
9155 For instance, assuming that there is a library of compspecs, each kept in a
9156 file corresponding to the name of the command, the following default
9157 completion function would load completions dynamically:
9160 <TT>_completion_loader()
9166 <TT> </TT>.
"/etc/bash_completion.d/$
1.sh
" >/dev/null
2>&1 && return
124<BR>
9172 complete -D -F _completion_loader -o bashdefault -o default
9176 <A NAME=
"lbCW"> </A>
9185 builtin is enabled, the shell provides access to the
9186 <I>command history
</I>,
9187 the list of commands previously typed.
9189 <FONT SIZE=-
1><B>HISTSIZE
</B>
9192 variable is used as the
9193 number of commands to save in a history list.
9194 The text of the last
9195 <FONT SIZE=-
1><B>HISTSIZE
</B>
9198 commands (default
500) is saved. The shell
9199 stores each command in the history list prior to parameter and
9200 variable expansion (see
9201 <FONT SIZE=-
1><B>EXPANSION
</B>
9204 above) but after history expansion is performed, subject to the
9205 values of the shell variables
9206 <FONT SIZE=-
1><B>HISTIGNORE
</B>
9210 <FONT SIZE=-
1><B>HISTCONTROL
</B>.
9215 On startup, the history is initialized from the file named by
9217 <FONT SIZE=-
1><B>HISTFILE
</B>
9220 (default
<A HREF=
"file:~/.bash_history"><I>~/.bash_history
</I></A>).
9221 The file named by the value of
9222 <FONT SIZE=-
1><B>HISTFILE
</B>
9225 is truncated, if necessary, to contain no more than
9226 the number of lines specified by the value of
9227 <FONT SIZE=-
1><B>HISTFILESIZE
</B>.
9230 If
<B>HISTFILESIZE
</B> is unset, or set to null, a non-numeric value,
9231 or a numeric value less than zero, the history file is not truncated.
9232 When the history file is read,
9233 lines beginning with the history comment character followed immediately
9234 by a digit are interpreted as timestamps for the following history line.
9235 These timestamps are optionally displayed depending on the value of the
9236 <FONT SIZE=-
1><B>HISTTIMEFORMAT
</B>
9240 When a shell with history enabled exits, the last
9241 <FONT SIZE=-
1><B>$HISTSIZE
</B>
9244 lines are copied from the history list to
9245 <FONT SIZE=-
1><B>$HISTFILE
</B>.
9251 shell option is enabled
9252 (see the description of
9256 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
9259 below), the lines are appended to the history file,
9260 otherwise the history file is overwritten.
9262 <FONT SIZE=-
1><B>HISTFILE
</B>
9265 is unset, or if the history file is unwritable, the history is
9268 <FONT SIZE=-
1><B>HISTTIMEFORMAT
</B>
9271 variable is set, time stamps are written to the history file, marked
9272 with the history comment character, so
9273 they may be preserved across shell sessions.
9274 This uses the history comment character to distinguish timestamps from
9275 other history lines.
9276 After saving the history, the history file is truncated
9277 to contain no more than
9278 <FONT SIZE=-
1><B>HISTFILESIZE
</B>
9282 <FONT SIZE=-
1><B>HISTFILESIZE
</B>
9285 is unset, or set to null, a non-numeric value,
9286 or a numeric value less than zero, the history file is not truncated.
9293 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
9296 below) may be used to list or edit and re-execute a portion of
9301 builtin may be used to display or modify the history list and
9302 manipulate the history file.
9303 When using command-line editing, search commands
9304 are available in each editing mode that provide access to the
9308 The shell allows control over which commands are saved on the history
9310 <FONT SIZE=-
1><B>HISTCONTROL
</B>
9314 <FONT SIZE=-
1><B>HISTIGNORE
</B>
9317 variables may be set to cause the shell to save only a subset of the
9322 shell option, if enabled, causes the shell to attempt to save each
9323 line of a multi-line command in the same history entry, adding
9324 semicolons where necessary to preserve syntactic correctness.
9328 shell option causes the shell to save the command with embedded newlines
9329 instead of semicolons. See the description of the
9333 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
9336 for information on setting and unsetting shell options.
9337 <A NAME=
"lbCX"> </A>
9338 <H3>HISTORY EXPANSION
</H3>
9340 The shell supports a history expansion feature that
9341 is similar to the history expansion in
9344 This section describes what syntax features are available. This
9345 feature is enabled by default for interactive shells, and can be
9352 builtin command (see
9353 <FONT SIZE=-
1><B>SHELL BUILTIN COMMANDS
</B>
9356 below). Non-interactive shells do not perform history expansion
9360 History expansions introduce words from the history list into
9361 the input stream, making it easy to repeat commands, insert the
9362 arguments to a previous command into the current input line, or
9363 fix errors in previous commands quickly.
9366 History expansion is performed immediately after a complete line
9367 is read, before the shell breaks it into words, and is performed
9368 on each line individually without taking quoting on previous lines into
9370 It takes place in two parts.
9371 The first is to determine which line from the history list
9372 to use during substitution.
9373 The second is to select portions of that line for inclusion into
9375 The line selected from the history is the
<I>event
</I>,
9376 and the portions of that line that are acted upon are
<I>words
</I>.
9377 Various
<I>modifiers
</I> are available to manipulate the selected words.
9378 The line is broken into words in the same fashion as when reading input,
9379 so that several
<I>metacharacter
</I>-separated words surrounded by
9380 quotes are considered one word.
9381 History expansions are introduced by the appearance of the
9382 history expansion character, which is
<B>!
</B> by default.
9383 Only backslash (
<B>\
</B>) and single quotes can quote
9384 the history expansion character, but the history expansion character is
9385 also treated as quoted if it immediately precedes the closing double quote
9386 in a double-quoted string.
9389 Several characters inhibit history expansion if found immediately
9390 following the history expansion character, even if it is unquoted:
9391 space, tab, newline, carriage return, and
<B>=
</B>.
9392 If the
<B>extglob
</B> shell option is enabled,
<B>(
</B> will also
9396 Several shell options settable with the
9399 builtin may be used to tailor the behavior of history expansion.
9403 shell option is enabled (see the description of the
9409 is being used, history substitutions are not immediately passed to
9411 Instead, the expanded line is reloaded into the
9414 editing buffer for further modification.
9418 is being used, and the
9421 shell option is enabled, a failed history substitution will be reloaded
9425 editing buffer for correction.
9432 builtin command may be used to see what a history expansion will
9440 builtin may be used to add commands to the end of the history list
9441 without actually executing them, so that they are available for
9445 The shell allows control of the various characters used by the
9446 history expansion mechanism (see the description of
9450 <B>Shell Variables
</B>).
9453 the history comment character to mark history timestamps when
9454 writing the history file.
9455 <A NAME=
"lbCY"> </A>
9456 <H4>Event Designators
</H4>
9458 An event designator is a reference to a command line entry in the
9460 Unless the reference is absolute, events are relative to the current
9461 position in the history list.
9469 Start a history substitution, except when followed by a
9472 newline, carriage return, =
9473 or ( (when the
<B>extglob
</B> shell option is enabled using
9474 the
<B>shopt
</B> builtin).
9475 <DT><B>!
</B><I>n
</I>
9478 Refer to command line
9481 <DT><B>!-
</B><I>n
</I>
9484 Refer to the current command minus
9490 Refer to the previous command. This is a synonym for `!-
1'.
9491 <DT><B>!
</B><I>string
</I>
9494 Refer to the most recent command preceding the current position in the
9495 history list starting with
9498 <DT><B>!?
</B><I>string
</I><B>[?]
</B>
9501 Refer to the most recent command preceding the current position in the
9502 history list containing
9505 The trailing
<B>?
</B> may be omitted if
9508 is followed immediately by a newline.
9509 If
<I>string
</I> is missing, the string from the most recent search is used;
9510 it is an error if there is no previous search string.
9511 <DT><B></B><FONT SIZE=+
2><B>^
</B></FONT><B></B><I>string1
</I><FONT SIZE=+
2>^
</FONT><I>string2
</I><FONT SIZE=+
2>^
</FONT>
9514 Quick substitution. Repeat the previous command, replacing
9521 ``!!:s
<FONT SIZE=+
2>^
</FONT><I>string1
</I><FONT SIZE=+
2>^
</FONT><I>string2
</I><FONT SIZE=+
2>^
</FONT>''
9522 (see
<B>Modifiers
</B> below).
9526 The entire command line typed so far.
9529 <A NAME=
"lbCZ"> </A>
9530 <H4>Word Designators
</H4>
9532 Word designators are used to select desired words from the event.
9536 separates the event specification from the word designator.
9537 It may be omitted if the word designator begins with a
9549 Words are numbered from the beginning of the line,
9550 with the first word being denoted by
0 (zero).
9551 Words are inserted into the current line separated by single spaces.
9559 The zeroth word. For the shell, this is the command
9564 The
<I>n
</I>th word.
9568 The first argument. That is, word
1.
9572 The last word. This is usually the last argument, but will expand to the
9573 zeroth word if there is only one word in the line.
9577 The first word matched by the most recent `?
<I>string
</I>?' search,
9578 if the search string begins with a character that is part of a word.
9579 <DT><I>x
</I><B>-
</B>y
9582 A range of words; `-
<I>y
</I>' abbreviates `
0-
<I>y
</I>'.
9586 All of the words but the zeroth. This is a synonym
9587 for `
<I>1-$
</I>'. It is not an error to use
9590 if there is just one
9591 word in the event; the empty string is returned in that case.
9595 Abbreviates
<I>x-$
</I>.
9599 Abbreviates
<I>x-$
</I> like
<B>x*
</B>, but omits the last word.
9600 If
<B>x
</B> is missing, it defaults to
0.
9605 If a word designator is supplied without an event specification, the
9606 previous command is used as the event.
9607 <A NAME=
"lbDA"> </A>
9610 After the optional word designator, there may appear a sequence of
9611 one or more of the following modifiers, each preceded by a `:'.
9612 These modify, or edit, the word or words selected from the history event.
9620 Remove a trailing filename component, leaving only the head.
9624 Remove all leading filename components, leaving the tail.
9628 Remove a trailing suffix of the form
<I>.xxx
</I>, leaving the
9633 Remove all but the trailing suffix.
9637 Print the new command but do not execute it.
9641 Quote the substituted words, escaping further substitutions.
9645 Quote the substituted words as with
9648 but break into words at
9652 The
<B>q
</B> and
<B>x
</B> modifiers are mutually exclusive; the last one
9654 <DT><B>s/
</B><I>old
</I>/
<I>new
</I>/
9660 for the first occurrence of
9664 Any character may be used as the delimiter in place of /.
9665 The final delimiter is optional if it is the last character of the
9667 The delimiter may be quoted in
9673 with a single backslash. If
& appears in
9679 A single backslash will quote the
&.
9683 is null, it is set to the last
9686 substituted, or, if no previous history substitutions took place,
9691 <B>!?
</B><I>string
</I><B>[?]
</B>
9697 is null, each matching
9704 Repeat the previous substitution.
9708 Cause changes to be applied over the entire event line. This is
9709 used in conjunction with `
<B>:s
</B>' (e.g., `
<B>:gs/
</B><I>old
</I>/
<I>new
</I>/')
9710 or `
<B>:
&</B>'. If used with
9711 `
<B>:s
</B>', any delimiter can be used
9712 in place of /, and the final delimiter is optional
9713 if it is the last character of the event line.
9714 An
<B>a
</B> may be used as a synonym for
<B>g
</B>.
9718 Apply the following `
<B>s
</B>' or `
<B>&</B>' modifier once to each word
9722 <A NAME=
"lbDB"> </A>
9723 <H3>SHELL BUILTIN COMMANDS
</H3>
9729 Unless otherwise noted, each builtin command documented in this
9730 section as accepting options preceded by
9736 to signify the end of the options.
9737 The
<B>:
</B>,
<B>true
</B>,
<B>false
</B>, and
<B>test
</B>/
<B>[
</B> builtins
9738 do not accept options and do not treat
<B>--
</B> specially.
9739 The
<B>exit
</B>,
<B>logout
</B>,
<B>return
</B>,
9740 <B>break
</B>,
<B>continue
</B>,
<B>let
</B>,
9741 and
<B>shift
</B> builtins accept and process arguments beginning with
9742 <B>-
</B> without requiring
<B>--
</B>.
9743 Other builtins that accept arguments but are not specified as accepting
9744 options interpret arguments beginning with
<B>-
</B> as invalid options and
9745 require
<B>--
</B> to prevent this interpretation.
9749 <DT><B>:
</B> [
<I>arguments
</I>]
<DD>
9751 No effect; the command does nothing beyond expanding
9754 and performing any specified
9756 The return status is zero.
9757 <DT><B> .
</B> <I>filename
</I> [
<I>arguments
</I>]
<DD>
9759 <DT><B>source
</B> <I>filename
</I> [
<I>arguments
</I>]
<DD>
9761 Read and execute commands from
9765 shell environment and return the exit status of the last command
9772 does not contain a slash, filenames in
9773 <FONT SIZE=-
1><B>PATH
</B>
9776 are used to find the directory containing
9779 but
<I>filename
</I> does not need to be executable.
9780 The file searched for in
9781 <FONT SIZE=-
1><B>PATH
</B>
9784 need not be executable.
9785 When
<B>bash
</B> is not in
<I>posix mode
</I>, it searches
9786 the current directory if no file is found in
9787 <FONT SIZE=-
1><B>PATH
</B>.
9796 builtin command is turned off, the
9797 <FONT SIZE=-
1><B>PATH
</B>
9801 If any
<I>arguments
</I> are supplied, they become the positional
9802 parameters when
<I>filename
</I> is executed. Otherwise the positional
9803 parameters are unchanged.
9804 If the
<B>-T
</B> option is enabled,
<B>.
</B> inherits any trap on
9805 <B>DEBUG
</B>; if it is not, any
<B>DEBUG
</B> trap string is saved and
9806 restored around the call to
<B>.
</B>, and
<B>.
</B> unsets the
9807 <B>DEBUG
</B> trap while it executes.
9808 If
<B>-T
</B> is not set, and the sourced file changes
9809 the
<B>DEBUG
</B> trap, the new value is retained when
<B>.
</B> completes.
9810 The return status is the status of the last command exited within
9811 the script (
0 if no commands are executed), and false if
9814 is not found or cannot be read.
9815 <DT><B>alias
</B> [
<B>-p
</B>] [
<I>name
</I>[=
<I>value
</I>] ...]
<DD>
9816 <B>Alias
</B> with no arguments or with the
9819 option prints the list of aliases in the form
9820 <B>alias
</B> <I>name
</I>=
<I>value
</I> on standard output.
9821 When arguments are supplied, an alias is defined for
9822 each
<I>name
</I> whose
<I>value
</I> is given.
9823 A trailing space in
<I>value
</I> causes the next word to be
9824 checked for alias substitution when the alias is expanded.
9825 For each
<I>name
</I> in the argument list for which no
<I>value
</I>
9826 is supplied, the name and value of the alias is printed.
9827 <B>Alias
</B> returns true unless a
<I>name
</I> is given for which
9828 no alias has been defined.
9829 <DT><B>bg
</B> [
<I>jobspec
</I> ...]
<DD>
9830 Resume each suspended job
<I>jobspec
</I> in the background, as if it
9831 had been started with
9837 is not present, the shell's notion of the
<I>current job
</I> is used.
9842 returns
0 unless run when job control is disabled or, when run with
9843 job control enabled, any specified
<I>jobspec
</I> was not found
9844 or was started without job control.
9845 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>] [
<B>-lpsvPSVX
</B>]
<DD>
9847 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>] [
<B>-q
</B> <I>function
</I>] [
<B>-u
</B> <I>function
</I>] [
<B>-r
</B> <I>keyseq
</I>]
<DD>
9848 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>]
<B>-f
</B> <I>filename
</I><DD>
9849 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>]
<B>-x
</B> <I>keyseq
</I>:
<I>shell-command
</I><DD>
9850 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>]
<I>keyseq
</I>:
<I>function-name
</I><DD>
9851 <DT><B>bind
</B> [
<B>-m
</B> <I>keymap
</I>]
<I>keyseq
</I>:
<I>readline-command
</I><DD>
9852 <DT><B>bind
</B> <I>readline-command-line
</I><DD>
9857 key and function bindings, bind a key sequence to a
9860 function or macro, or set a
9864 Each non-option argument is a command as it would appear in a
9867 initialization file such as
9870 but each binding or command must be passed as a separate argument;
9871 e.g., '
"\C-x\C-r
": re-read-init-file'.
9872 Options, if supplied, have the following meanings:
9873 <DL COMPACT
><DT><DD>
9876 <DT><B>-m
</B><I>keymap
</I>
9882 as the keymap to be affected by the subsequent bindings.
9887 <I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
9888 vi-move, vi-command
</I>, and
9891 <I>vi
</I> is equivalent to
<I>vi-command
</I> (
<I>vi-move
</I> is also
9892 a synonym);
<I>emacs
</I> is
9893 equivalent to
<I>emacs-standard
</I>.
9897 List the names of all
<B>readline
</B> functions.
9901 Display
<B>readline
</B> function names and bindings in such a way
9902 that they can be re-read.
9906 List current
<B>readline
</B> function names and bindings.
9910 Display
<B>readline
</B> key sequences bound to macros and the strings
9911 they output in such a way that they can be re-read.
9915 Display
<B>readline
</B> key sequences bound to macros and the strings
9920 Display
<B>readline
</B> variable names and values in such a way that they
9925 List current
<B>readline
</B> variable names and values.
9926 <DT><B>-f
</B><I>filename
</I>
9929 Read key bindings from
<I>filename
</I>.
9930 <DT><B>-q
</B><I>function
</I>
9933 Query about which keys invoke the named
<I>function
</I>.
9934 <DT><B>-u
</B><I>function
</I>
9937 Unbind all keys bound to the named
<I>function
</I>.
9938 <DT><B>-r
</B><I>keyseq
</I>
9941 Remove any current binding for
<I>keyseq
</I>.
9942 <DT><B>-x
</B><I>keyseq
</I>:
<I>shell-command
</I>
9945 Cause
<I>shell-command
</I> to be executed whenever
<I>keyseq
</I> is
9947 When
<I>shell-command
</I> is executed, the shell sets the
9948 <FONT SIZE=-
1><B>READLINE_LINE
</B>
9951 variable to the contents of the
<B>readline
</B> line buffer and the
9952 <FONT SIZE=-
1><B>READLINE_POINT
</B>
9956 <FONT SIZE=-
1><B>READLINE_MARK
</B>
9959 variables to the current location of the insertion point and the saved
9960 insertion point (the mark), respectively.
9961 The shell assigns any numeric argument the user supplied to the
9962 <FONT SIZE=-
1><B>READLINE_ARGUMENT
</B>
9966 If there was no argument, that variable is not set.
9967 If the executed command changes the value of any of
9968 <FONT SIZE=-
1><B>READLINE_LINE
</B>,
9971 <FONT SIZE=-
1><B>READLINE_POINT
</B>,
9975 <FONT SIZE=-
1><B>READLINE_MARK
</B>,
9978 those new values will be reflected in the editing state.
9982 List all key sequences bound to shell commands and the associated commands
9983 in a format that can be reused as input.
9988 The return value is
0 unless an unrecognized option is given or an
9992 <DT><B>break
</B> [
<I>n
</I>]
<DD>
10003 loop. If
<I>n
</I> is specified, break
<I>n
</I> levels.
10009 is greater than the number of enclosing loops, all enclosing loops
10011 The return value is
0 unless
<I>n
</I> is not greater than or equal to
1.
10012 <DT><B>builtin
</B> <I>shell-builtin
</I> [
<I>arguments
</I>]
<DD>
10013 Execute the specified shell builtin, passing it
10016 and return its exit status.
10017 This is useful when defining a
10018 function whose name is the same as a shell builtin,
10019 retaining the functionality of the builtin within the function.
10020 The
<B>cd
</B> builtin is commonly redefined this way.
10021 The return status is false if
10022 <I>shell-builtin
</I>
10024 is not a shell builtin command.
10025 <DT><B>caller
</B> [
<I>expr
</I>]
<DD>
10026 Returns the context of any active subroutine call (a shell function or
10027 a script executed with the
<B>.
</B> or
<B>source
</B> builtins).
10028 Without
<I>expr
</I>,
<B>caller
</B> displays the line number and source
10029 filename of the current subroutine call.
10030 If a non-negative integer is supplied as
<I>expr
</I>,
<B>caller
</B>
10031 displays the line number, subroutine name, and source file corresponding
10032 to that position in the current execution call stack. This extra
10033 information may be used, for example, to print a stack trace. The
10034 current frame is frame
0.
10035 The return value is
0 unless the shell is not executing a subroutine
10036 call or
<I>expr
</I> does not correspond to a valid position in the
10038 <DT><B>cd
</B> [
<B>-L
</B>|[
<B>-P
</B> [
<B>-e
</B>]] [-@]] [
<I>dir
</I>]
<DD>
10039 Change the current directory to
<I>dir
</I>.
10040 if
<I>dir
</I> is not supplied, the value of the
10041 <FONT SIZE=-
1><B>HOME
</B>
10044 shell variable is the default.
10046 <FONT SIZE=-
1><B>CDPATH
</B>
10049 defines the search path for the directory containing
10052 each directory name in
10053 <FONT SIZE=-
1><B>CDPATH
</B>
10056 is searched for
<I>dir
</I>.
10057 Alternative directory names in
10058 <FONT SIZE=-
1><B>CDPATH
</B>
10061 are separated by a colon (:). A null directory name in
10062 <FONT SIZE=-
1><B>CDPATH
</B>
10065 is the same as the current directory, i.e., ``
<B>.
</B>''. If
10068 begins with a slash (/),
10070 <FONT SIZE=-
1><B>CDPATH
</B>
10076 option causes
<B>cd
</B> to use the physical directory structure
10077 by resolving symbolic links while traversing
<I>dir
</I> and
10078 before processing instances of
<I>..
</I> in
<I>dir
</I> (see also the
10084 builtin command); the
10087 option forces symbolic links to be followed by resolving the link
10088 after processing instances of
<I>..
</I> in
<I>dir
</I>.
10089 If
<I>..
</I> appears in
<I>dir
</I>, it is processed by removing the
10090 immediately previous pathname component from
<I>dir
</I>, back to a slash
10091 or the beginning of
<I>dir
</I>.
10095 option is supplied with
10098 and the current working directory cannot be successfully determined
10099 after a successful directory change,
<B>cd
</B> will return an unsuccessful
10101 On systems that support it, the
<B>-@
</B> option presents the extended
10102 attributes associated with a file as a directory.
10107 <FONT SIZE=-
1><B>$OLDPWD
</B>
10110 before the directory change is attempted.
10111 If a non-empty directory name from
10112 <FONT SIZE=-
1><B>CDPATH
</B>
10116 <B>-
</B> is the first argument, and the directory change is
10117 successful, the absolute pathname of the new working directory is
10118 written to the standard output.
10119 If the directory change is successful,
<B>cd
</B> sets the value of the
10120 <B>PWD
</B> environment variable to the new directory name, and sets the
10121 <B>OLDPWD
</B> environment variable to the value of the current working
10122 directory before the change.
10123 The return value is true if the directory was successfully changed;
10125 <DT><B>command
</B> [
<B>-pVv
</B>]
<I>command
</I> [
<I>arg
</I> ...]
<DD>
10132 suppressing the normal shell function lookup.
10133 Only builtin commands or commands found in the
10134 <FONT SIZE=-
1><B>PATH
</B>
10137 are executed. If the
10140 option is given, the search for
10143 is performed using a default value for
10144 <FONT SIZE=-
1><B>PATH
</B>
10147 that is guaranteed to find all of the standard utilities.
10154 option is supplied, a description of
10160 option causes a single word indicating the command or filename
10164 to be displayed; the
10167 option produces a more verbose description.
10174 option is supplied, the exit status is
0 if
10177 was found, and
1 if not. If neither option is supplied and
10178 an error occurred or
10181 cannot be found, the exit status is
127. Otherwise, the exit status of the
10184 builtin is the exit status of
10187 <DT><B>compgen
</B> [
<I>option
</I>] [
<I>word
</I>]
<DD>
10188 Generate possible completion matches for
<I>word
</I> according to
10189 the
<I>option
</I>s, which may be any option accepted by the
10192 builtin with the exception of
<B>-p
</B> and
<B>-r
</B>, and write
10193 the matches to the standard output.
10194 When using the
<B>-F
</B> or
<B>-C
</B> options, the various shell variables
10195 set by the programmable completion facilities, while available, will not
10196 have useful values.
10198 The matches will be generated in the same way as if the programmable
10199 completion code had generated them directly from a completion specification
10200 with the same flags.
10201 If
<I>word
</I> is specified, only those completions matching
<I>word
</I>
10204 The return value is true unless an invalid option is supplied, or no
10205 matches were generated.
10206 <DT><B>complete
</B> [
<B>-abcdefgjksuv
</B>] [
<B>-o
</B> <I>comp-option
</I>] [
<B>-DEI
</B>] [
<B>-A
</B> <I>action
</I>] [
<B>-G
</B> <I>globpat
</I>] [
<B>-W
</B> <I>wordlist
</I>]
<DD>
10209 [
<B>-F
</B> <I>function
</I>] [
<B>-C
</B> <I>command
</I>] [
<B>-X
</B> <I>filterpat
</I>] [
<B>-P
</B> <I>prefix
</I>] [
<B>-S
</B> <I>suffix
</I>]
<I>name
</I> [
<I>name ...
</I>]
10211 <DT><B>complete
</B> <B>-pr
</B> [
<B>-DEI
</B>] [
<I>name
</I> ...]
<DD>
10213 Specify how arguments to each
<I>name
</I> should be completed.
10214 If the
<B>-p
</B> option is supplied, or if no options are supplied,
10215 existing completion specifications are printed in a way that allows
10216 them to be reused as input.
10217 The
<B>-r
</B> option removes a completion specification for
10218 each
<I>name
</I>, or, if no
<I>name
</I>s are supplied, all
10219 completion specifications.
10220 The
<B>-D
</B> option indicates that other supplied options and actions should
10221 apply to the ``default'' command completion; that is, completion attempted
10222 on a command for which no completion has previously been defined.
10223 The
<B>-E
</B> option indicates that other supplied options and actions should
10224 apply to ``empty'' command completion; that is, completion attempted on a
10226 The
<B>-I
</B> option indicates that other supplied options and actions should
10227 apply to completion on the initial non-assignment word on the line, or after
10228 a command delimiter such as
<B>;
</B> or
<B>|
</B>, which is usually command
10230 If multiple options are supplied, the
<B>-D
</B> option takes precedence
10231 over
<B>-E
</B>, and both take precedence over
<B>-I
</B>.
10232 If any of
<B>-D
</B>,
<B>-E
</B>, or
<B>-I
</B> are supplied, any other
10233 <I>name
</I> arguments are ignored; these completions only apply to the case
10234 specified by the option.
10236 The process of applying these completion specifications when word completion
10237 is attempted is described
10239 above under
<B>Programmable Completion
</B>.
10241 Other options, if specified, have the following meanings.
10242 The arguments to the
<B>-G
</B>,
<B>-W
</B>, and
<B>-X
</B> options
10243 (and, if necessary, the
<B>-P
</B> and
<B>-S
</B> options)
10244 should be quoted to protect them from expansion before the
10247 builtin is invoked.
10248 <DL COMPACT
><DT><DD>
10251 <DT><B>-o
</B> <I>comp-option
</I><DD>
10252 The
<I>comp-option
</I> controls several aspects of the compspec's behavior
10253 beyond the simple generation of completions.
10254 <I>comp-option
</I> may be one of:
10255 <DL COMPACT
><DT><DD>
10257 <DT><B>bashdefault
</B>
10260 Perform the rest of the default
<B>bash
</B> completions if the compspec
10261 generates no matches.
10265 Use readline's default filename completion if the compspec generates
10267 <DT><B>dirnames
</B>
10270 Perform directory name completion if the compspec generates no matches.
10271 <DT><B>filenames
</B>
10274 Tell readline that the compspec generates filenames, so it can perform any
10275 filename-specific processing (like adding a slash to directory names,
10276 quoting special characters, or suppressing trailing spaces).
10277 Intended to be used with shell functions.
10281 Tell readline not to quote the completed words if they are filenames
10282 (quoting filenames is the default).
10286 Tell readline not to sort the list of possible completions alphabetically.
10290 Tell readline not to append a space (the default) to words completed at
10291 the end of the line.
10292 <DT><B>plusdirs
</B>
10295 After any matches defined by the compspec are generated,
10296 directory name completion is attempted and any
10297 matches are added to the results of the other actions.
10300 <DT><B>-A
</B> <I>action
</I><DD>
10301 The
<I>action
</I> may be one of the following to generate a list of possible
10303 <DL COMPACT
><DT><DD>
10308 Alias names. May also be specified as
<B>-a
</B>.
10309 <DT><B>arrayvar
</B>
10312 Array variable names.
10316 <B>Readline
</B> key binding names.
10320 Names of shell builtin commands. May also be specified as
<B>-b
</B>.
10324 Command names. May also be specified as
<B>-c
</B>.
10325 <DT><B>directory
</B>
10328 Directory names. May also be specified as
<B>-d
</B>.
10329 <DT><B>disabled
</B>
10332 Names of disabled shell builtins.
10336 Names of enabled shell builtins.
10340 Names of exported shell variables. May also be specified as
<B>-e
</B>.
10344 File names. May also be specified as
<B>-f
</B>.
10345 <DT><B>function
</B>
10348 Names of shell functions.
10352 Group names. May also be specified as
<B>-g
</B>.
10353 <DT><B>helptopic
</B>
10356 Help topics as accepted by the
<B>help
</B> builtin.
10357 <DT><B>hostname
</B>
10360 Hostnames, as taken from the file specified by the
10361 <FONT SIZE=-
1><B>HOSTFILE
</B>
10368 Job names, if job control is active. May also be specified as
<B>-j
</B>.
10372 Shell reserved words. May also be specified as
<B>-k
</B>.
10376 Names of running jobs, if job control is active.
10380 Service names. May also be specified as
<B>-s
</B>.
10384 Valid arguments for the
<B>-o
</B> option to the
<B>set
</B> builtin.
10388 Shell option names as accepted by the
<B>shopt
</B> builtin.
10396 Names of stopped jobs, if job control is active.
10400 User names. May also be specified as
<B>-u
</B>.
10401 <DT><B>variable
</B>
10404 Names of all shell variables. May also be specified as
<B>-v
</B>.
10407 <DT><B>-C
</B> <I>command
</I><DD>
10408 <I>command
</I> is executed in a subshell environment, and its output is
10409 used as the possible completions.
10410 Arguments are passed as with the
<B>-F
</B> option.
10411 <DT><B>-F
</B> <I>function
</I><DD>
10412 The shell function
<I>function
</I> is executed in the current shell
10414 When the function is executed,
10415 the first argument (
<B>$
1</B>) is the name of the command whose arguments are
10417 the second argument (
<B>$
2</B>) is the word being completed,
10418 and the third argument (
<B>$
3</B>) is the word preceding the word being
10419 completed on the current command line.
10420 When it finishes, the possible completions are retrieved from the value
10422 <FONT SIZE=-
1><B>COMPREPLY
</B>
10426 <DT><B>-G
</B> <I>globpat
</I><DD>
10427 The pathname expansion pattern
<I>globpat
</I> is expanded to generate
10428 the possible completions.
10429 <DT><B>-P
</B> <I>prefix
</I><DD>
10430 <I>prefix
</I> is added at the beginning of each possible completion
10431 after all other options have been applied.
10432 <DT><B>-S
</B> <I>suffix
</I><DD>
10433 <I>suffix
</I> is appended to each possible completion
10434 after all other options have been applied.
10435 <DT><B>-W
</B> <I>wordlist
</I><DD>
10436 The
<I>wordlist
</I> is split using the characters in the
10437 <FONT SIZE=-
1><B>IFS
</B>
10440 special variable as delimiters, and each resultant word is expanded.
10441 Shell quoting is honored within
<I>wordlist
</I>,
10442 in order to provide a
10443 mechanism for the words to contain shell metacharacters or characters
10445 <FONT SIZE=-
1><B>IFS
</B>.
10448 The possible completions are the members of the resultant list which
10449 match the word being completed.
10450 <DT><B>-X
</B> <I>filterpat
</I><DD>
10451 <I>filterpat
</I> is a pattern as used for pathname expansion.
10452 It is applied to the list of possible completions generated by the
10453 preceding options and arguments, and each completion matching
10454 <I>filterpat
</I> is removed from the list.
10455 A leading
<B>!
</B> in
<I>filterpat
</I> negates the pattern; in this
10456 case, any completion not matching
<I>filterpat
</I> is removed.
10461 The return value is true unless an invalid option is supplied, an option
10462 other than
<B>-p
</B> or
<B>-r
</B> is supplied without a
<I>name
</I>
10463 argument, an attempt is made to remove a completion specification for
10464 a
<I>name
</I> for which no specification exists, or
10465 an error occurs adding a completion specification.
10468 <DT><B>compopt
</B> [
<B>-o
</B> <I>option
</I>] [
<B>-DEI
</B>] [
<B>+o
</B> <I>option
</I>] [
<I>name
</I>]
<DD>
10469 Modify completion options for each
<I>name
</I> according to the
10470 <I>option
</I>s, or for the
10471 currently-executing completion if no
<I>name
</I>s are supplied.
10472 If no
<I>option
</I>s are given, display the completion options for each
10473 <I>name
</I> or the current completion.
10474 The possible values of
<I>option
</I> are those valid for the
<B>complete
</B>
10475 builtin described above.
10476 The
<B>-D
</B> option indicates that other supplied options should
10477 apply to the ``default'' command completion; that is, completion attempted
10478 on a command for which no completion has previously been defined.
10479 The
<B>-E
</B> option indicates that other supplied options should
10480 apply to ``empty'' command completion; that is, completion attempted on a
10482 The
<B>-I
</B> option indicates that other supplied options should
10483 apply to completion on the initial non-assignment word on the line,
10484 or after a command delimiter such as
<B>;
</B> or
<B>|
</B>, which is usually
10485 command name completion.
10487 The return value is true unless an invalid option is supplied, an attempt
10488 is made to modify the options for a
<I>name
</I> for which no completion
10489 specification exists, or an output error occurs.
10490 <DT><B>continue
</B> [
<I>n
</I>]
<DD>
10491 Resume the next iteration of the enclosing
10505 is specified, resume at the
<I>n
</I>th enclosing loop.
10511 is greater than the number of enclosing loops, the last enclosing loop
10512 (the ``top-level'' loop) is resumed.
10513 The return value is
0 unless
<I>n
</I> is not greater than or equal to
1.
10514 <DT><B>declare
</B> [
<B>-aAfFgiIlnrtux
</B>] [
<B>-p
</B>] [
<I>name
</I>[=
<I>value
</I>] ...]
<DD>
10516 <DT><B>typeset
</B> [
<B>-aAfFgiIlnrtux
</B>] [
<B>-p
</B>] [
<I>name
</I>[=
<I>value
</I>] ...]
<DD>
10518 Declare variables and/or give them attributes.
10519 If no
<I>name
</I>s are given then display the values of variables.
10523 option will display the attributes and values of each
10529 is used with
<I>name
</I> arguments, additional options,
10530 other than
<B>-f
</B> and
<B>-F
</B>, are ignored.
10534 is supplied without
<I>name
</I> arguments, it will display the attributes
10535 and values of all variables having the attributes specified by the
10536 additional options.
10537 If no other options are supplied with
<B>-p
</B>,
<B>declare
</B> will display
10538 the attributes and values of all shell variables. The
<B>-f
</B> option
10539 will restrict the display to shell functions.
10543 option inhibits the display of function definitions; only the
10544 function name and attributes are printed.
10545 If the
<B>extdebug
</B> shell option is enabled using
<B>shopt
</B>,
10546 the source file name and line number where each
<I>name
</I>
10547 is defined are displayed as well. The
10556 option forces variables to be created or modified at the global scope,
10557 even when
<B>declare
</B> is executed in a shell function.
10558 It is ignored in all other cases.
10562 option causes local variables to inherit the attributes
10563 (except the
<I>nameref
</I> attribute)
10564 and value of any existing variable with the same
10565 <I>name
</I> at a surrounding scope.
10566 If there is no existing variable, the local variable is initially unset.
10567 The following options can
10568 be used to restrict output to variables with the specified attribute or
10569 to give variables attributes:
10570 <DL COMPACT
><DT><DD>
10576 Each
<I>name
</I> is an indexed array variable (see
10584 Each
<I>name
</I> is an associative array variable (see
10592 Use function names only.
10596 The variable is treated as an integer; arithmetic evaluation (see
10597 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>
10602 is performed when the variable is assigned a value.
10606 When the variable is assigned a value, all upper-case characters are
10607 converted to lower-case.
10608 The upper-case attribute is disabled.
10612 Give each
<I>name
</I> the
<I>nameref
</I> attribute, making
10613 it a name reference to another variable.
10614 That other variable is defined by the value of
<I>name
</I>.
10615 All references, assignments, and attribute modifications
10616 to
<I>name
</I>, except those using or changing the
10617 <B>-n
</B> attribute itself, are performed on the variable referenced by
10618 <I>name
</I>'s value.
10619 The nameref attribute cannot be applied to array variables.
10623 Make
<I>name
</I>s readonly. These names cannot then be assigned values
10624 by subsequent assignment statements or unset.
10628 Give each
<I>name
</I> the
<I>trace
</I> attribute.
10629 Traced functions inherit the
<B>DEBUG
</B> and
<B>RETURN
</B> traps from
10631 The trace attribute has no special meaning for variables.
10635 When the variable is assigned a value, all lower-case characters are
10636 converted to upper-case.
10637 The lower-case attribute is disabled.
10641 Mark
<I>name
</I>s for export to subsequent commands via the environment.
10646 Using `+' instead of `-'
10647 turns off the attribute instead,
10648 with the exceptions that
<B>+a
</B> and
<B>+A
</B>
10649 may not be used to destroy array variables and
<B>+r
</B> will not
10650 remove the readonly attribute.
10651 When used in a function,
10658 <I>name
</I> local, as with the
10662 unless the
<B>-g
</B> option is supplied.
10663 If a variable name is followed by =
<I>value
</I>, the value of
10664 the variable is set to
<I>value
</I>.
10665 When using
<B>-a
</B> or
<B>-A
</B> and the compound assignment syntax to
10666 create array variables, additional attributes do not take effect until
10667 subsequent assignments.
10668 The return value is
0 unless an invalid option is encountered,
10669 an attempt is made to define a function using
10671 <TT>-f foo=bar
</TT>,
10672 an attempt is made to assign a value to a readonly variable,
10673 an attempt is made to assign a value to an array variable without
10674 using the compound assignment syntax (see
10679 one of the
<I>names
</I> is not a valid shell variable name,
10680 an attempt is made to turn off readonly status for a readonly variable,
10681 an attempt is made to turn off array status for an array variable,
10682 or an attempt is made to display a non-existent function with
<B>-f
</B>.
10685 <DT><B>dirs [-clpv
</B>] [+
<I>n
</I>] [-
<I>n
</I>]
10688 Without options, displays the list of currently remembered directories.
10689 The default display is on a single line with directory names separated
10691 Directories are added to the list with the
10697 command removes entries from the list.
10698 The current directory is always the first directory in the stack.
10699 <DL COMPACT
><DT><DD>
10705 Clears the directory stack by deleting all of the entries.
10709 Produces a listing using full pathnames;
10710 the default listing format uses a tilde to denote the home directory.
10714 Print the directory stack with one entry per line.
10718 Print the directory stack with one entry per line,
10719 prefixing each entry with its index in the stack.
10720 <DT><B>+
</B><I>n
</I><DD>
10721 Displays the
<I>n
</I>th entry counting from the left of the list
10725 when invoked without options, starting with zero.
10726 <DT><B>-
</B><I>n
</I><DD>
10727 Displays the
<I>n
</I>th entry counting from the right of the list
10731 when invoked without options, starting with zero.
10736 The return value is
0 unless an
10737 invalid option is supplied or
<I>n
</I> indexes beyond the end
10738 of the directory stack.
10741 <DT><B>disown
</B> [
<B>-ar
</B>] [
<B>-h
</B>] [
<I>jobspec
</I> ... |
<I>pid
</I> ... ]
<DD>
10742 Without options, remove each
10745 from the table of active jobs.
10749 is not present, and neither the
<B>-a
</B> nor the
<B>-r
</B> option
10750 is supplied, the
<I>current job
</I> is used.
10751 If the
<B>-h
</B> option is given, each
10754 is not removed from the table, but is marked so that
10755 <FONT SIZE=-
1><B>SIGHUP
</B>
10758 is not sent to the job if the shell receives a
10759 <FONT SIZE=-
1><B>SIGHUP
</B>.
10768 option means to remove or mark all jobs; the
10774 argument restricts operation to running jobs.
10775 The return value is
0 unless a
10778 does not specify a valid job.
10779 <DT><B>echo
</B> [
<B>-neE
</B>] [
<I>arg
</I> ...]
<DD>
10780 Output the
<I>arg
</I>s, separated by spaces, followed by a newline.
10781 The return status is
0 unless a write error occurs.
10782 If
<B>-n
</B> is specified, the trailing newline is
10783 suppressed. If the
<B>-e
</B> option is given, interpretation of
10784 the following backslash-escaped characters is enabled. The
10787 option disables the interpretation of these escape characters,
10788 even on systems where they are interpreted by default.
10789 The
<B>xpg_echo
</B> shell option may be used to
10790 dynamically determine whether or not
<B>echo
</B> expands these
10791 escape characters by default.
10794 does not interpret
<B>--
</B> to mean the end of options.
10797 interprets the following escape sequences:
10798 <DL COMPACT
><DT><DD>
10812 suppress further output
10819 an escape character
10844 <DT><B>\
0</B><I>nnn
</I>
10847 the eight-bit character whose value is the octal value
<I>nnn
</I>
10848 (zero to three octal digits)
10849 <DT><B>\x
</B><I>HH
</I>
10852 the eight-bit character whose value is the hexadecimal value
<I>HH
</I>
10853 (one or two hex digits)
10854 <DT><B>\u
</B><I>HHHH
</I>
10857 the Unicode (ISO/IEC
10646) character whose value is the hexadecimal value
10858 <I>HHHH
</I> (one to four hex digits)
10859 <DT><B>\U
</B><I>HHHHHHHH
</I>
10862 the Unicode (ISO/IEC
10646) character whose value is the hexadecimal value
10863 <I>HHHHHHHH
</I> (one to eight hex digits)
10867 <DT><B>enable
</B> [
<B>-a
</B>] [
<B>-dnps
</B>] [
<B>-f
</B> <I>filename
</I>] [
<I>name
</I> ...]
<DD>
10868 Enable and disable builtin shell commands.
10869 Disabling a builtin allows a disk command which has the same name
10870 as a shell builtin to be executed without specifying a full pathname,
10871 even though the shell normally searches for builtins before disk commands.
10872 If
<B>-n
</B> is used, each
<I>name
</I>
10873 is disabled; otherwise,
10874 <I>names
</I> are enabled. For example, to use the
10877 binary found via the
10878 <FONT SIZE=-
1><B>PATH
</B>
10881 instead of the shell builtin version, run
10882 <TT>enable -n test
</TT>.
10887 option means to load the new builtin command
10893 on systems that support dynamic loading.
10894 Bash will use the value of the
<B>BASH_LOADABLES_PATH
</B> variable as a
10895 colon-separated list of directories in which to search for
<I>filename
</I>.
10896 The default is system-dependent.
10900 option will delete a builtin previously loaded with
10903 If no
<I>name
</I> arguments are given, or if the
10906 option is supplied, a list of shell builtins is printed.
10907 With no other option arguments, the list consists of all enabled
10909 If
<B>-n
</B> is supplied, only disabled builtins are printed.
10910 If
<B>-a
</B> is supplied, the list printed includes all builtins, with an
10911 indication of whether or not each is enabled.
10912 If
<B>-s
</B> is supplied, the output is restricted to the POSIX
10913 <I>special
</I> builtins.
10914 If no options are supplied and a
<I>name
</I> is not a shell builtin,
10915 <B>enable
</B> will attempt to load
<I>name
</I> from a shared object named
10916 <I>name
</I>, as if the command were
10917 <TT>enable -f
</TT> <I>name name
</I> .
10919 The return value is
0 unless a
10922 is not a shell builtin or there is an error loading a new builtin
10923 from a shared object.
10924 <DT><B>eval
</B> [
<I>arg
</I> ...]
<DD>
10925 The
<I>arg
</I>s are read and concatenated together into a single
10926 command. This command is then read and executed by the shell, and
10927 its exit status is returned as the value of
10933 or only null arguments,
10937 <DT><B>exec
</B> [
<B>-cl
</B>] [
<B>-a
</B> <I>name
</I>] [
<I>command
</I> [
<I>arguments
</I>]]
<DD>
10941 is specified, it replaces the shell.
10942 No new process is created. The
10945 become the arguments to
<I>command
</I>.
10949 option is supplied,
10950 the shell places a dash at the beginning of the zeroth argument passed to
10962 to be executed with an empty environment. If
10965 is supplied, the shell passes
10968 as the zeroth argument to the executed command.
10972 cannot be executed for some reason, a non-interactive shell exits,
10977 is enabled. In that case, it returns failure.
10978 An interactive shell returns failure if the file cannot be executed.
10979 A subshell exits unconditionally if
<B>exec
</B> fails.
10983 is not specified, any redirections take effect in the current shell,
10984 and the return status is
0. If there is a redirection error, the
10985 return status is
1.
10986 <DT><B>exit
</B> [
<I>n
</I>]
<DD>
10987 Cause the shell to exit
10988 with a status of
<I>n
</I>. If
10991 is omitted, the exit status
10992 is that of the last command executed.
10994 <FONT SIZE=-
1><B>EXIT
</B>
10997 is executed before the shell terminates.
10998 <DT><B>export
</B> [
<B>-fn
</B>] [
<I>name
</I>[=
<I>word
</I>]] ...
<DD>
11000 <DT><B>export -p
</B>
11007 are marked for automatic export to the environment of
11008 subsequently executed commands. If the
11011 option is given, the
11014 refer to functions.
11018 are given, or if the
11021 option is supplied, a list
11022 of names of all exported variables is printed.
11026 option causes the export property to be removed from each
11028 If a variable name is followed by =
<I>word
</I>, the value of
11029 the variable is set to
<I>word
</I>.
11032 returns an exit status of
0 unless an invalid option is
11034 one of the
<I>names
</I> is not a valid shell variable name, or
11040 that is not a function.
11041 <DT><B>fc
</B> [
<B>-e
</B> <I>ename
</I>] [
<B>-lnr
</B>] [
<I>first
</I>] [
<I>last
</I>]
<DD>
11043 <DT><B>fc
</B> <B>-s
</B> [
<I>pat
</I>=
<I>rep
</I>] [
<I>cmd
</I>]
<DD>
11045 The first form selects a range of commands from
11051 from the history list and displays or edits and re-executes them.
11057 may be specified as a string (to locate the last command beginning
11058 with that string) or as a number (an index into the history list,
11059 where a negative number is used as an offset from the current
11061 When listing, a
<I>first
</I> or
<I>last
</I> of
11062 0 is equivalent to -
1 and -
0 is equivalent to the current
11063 command (usually the
<B>fc
</B> command); otherwise
0 is equivalent to -
1
11068 is not specified, it is set to
11069 the current command for listing (so that
11072 prints the last
10 commands) and to
11079 is not specified, it is set to the previous
11080 command for editing and -
16 for listing.
11086 the command numbers when listing. The
11089 option reverses the order of
11090 the commands. If the
11094 the commands are listed on
11095 standard output. Otherwise, the editor given by
11099 on a file containing those commands. If
11104 <FONT SIZE=-
1><B>FCEDIT
</B>
11107 variable is used, and
11109 <FONT SIZE=-
1><B>EDITOR
</B>
11113 <FONT SIZE=-
1><B>FCEDIT
</B>
11116 is not set. If neither variable is set,
11120 is used. When editing is complete, the edited commands are
11121 echoed and executed.
11123 In the second form,
<I>command
</I> is re-executed after each instance
11124 of
<I>pat
</I> is replaced by
<I>rep
</I>.
11125 <I>Command
</I> is interpreted the same as
<I>first
</I> above.
11126 A useful alias to use with this is
11128 <TT>r='fc -s'
</TT>,
11132 runs the last command beginning with
11138 re-executes the last command.
11140 If the first form is used, the return value is
0 unless an invalid
11141 option is encountered or
11147 specify history lines out of range.
11151 option is supplied, the return value is the value of the last
11152 command executed or failure if an error occurs with the temporary
11153 file of commands. If the second form is used, the return status
11154 is that of the command re-executed, unless
11157 does not specify a valid history line, in which case
11161 <DT><B>fg
</B> [
<I>jobspec
</I>]
<DD>
11165 in the foreground, and make it the current job.
11169 is not present, the shell's notion of the
<I>current job
</I> is used.
11170 The return value is that of the command placed into the foreground,
11171 or failure if run when job control is disabled or, when run with
11172 job control enabled, if
11175 does not specify a valid job or
11178 specifies a job that was started without job control.
11179 <DT><B>getopts
</B> <I>optstring
</I> <I>name
</I> [
<I>arg ...
</I>]
<DD>
11182 is used by shell procedures to parse positional parameters.
11185 contains the option characters to be recognized; if a character
11186 is followed by a colon, the option is expected to have an
11187 argument, which should be separated from it by white space.
11188 The colon and question mark characters may not be used as
11190 Each time it is invoked,
11193 places the next option in the shell variable
11199 if it does not exist,
11200 and the index of the next argument to be processed into the
11202 <FONT SIZE=-
1><B>OPTIND
</B>.
11205 <FONT SIZE=-
1><B>OPTIND
</B>
11208 is initialized to
1 each time the shell or a shell script
11209 is invoked. When an option requires an argument,
11212 places that argument into the variable
11213 <FONT SIZE=-
1><B>OPTARG
</B>.
11216 The shell does not reset
11217 <FONT SIZE=-
1><B>OPTIND
</B>
11220 automatically; it must be manually reset between multiple
11224 within the same shell invocation if a new set of parameters
11227 When the end of options is encountered,
<B>getopts
</B> exits with a
11228 return value greater than zero.
11229 <FONT SIZE=-
1><B>OPTIND
</B>
11232 is set to the index of the first non-option argument,
11233 and
<I>name
</I> is set to ?.
11237 normally parses the positional parameters, but if more arguments are
11244 parses those instead.
11248 can report errors in two ways. If the first character of
11254 error reporting is used. In normal operation, diagnostic messages
11255 are printed when invalid options or missing option arguments are
11258 <FONT SIZE=-
1><B>OPTERR
</B>
11261 is set to
0, no error messages will be displayed, even if the first
11267 If an invalid option is seen,
11273 and, if not silent,
11274 prints an error message and unsets
11275 <FONT SIZE=-
1><B>OPTARG
</B>.
11282 the option character found is placed in
11283 <FONT SIZE=-
1><B>OPTARG
</B>
11286 and no diagnostic message is printed.
11288 If a required argument is not found, and
11292 a question mark (
<B>?
</B>) is placed in
11295 <FONT SIZE=-
1><B>OPTARG
</B>
11298 is unset, and a diagnostic message is printed.
11302 is silent, then a colon (
<B>:
</B>) is placed in
11306 <FONT SIZE=-
1><B>OPTARG
</B>
11309 is set to the option character found.
11313 returns true if an option, specified or unspecified, is found.
11314 It returns false if the end of options is encountered or an
11316 <DT><B>hash
</B> [
<B>-lr
</B>] [
<B>-p
</B> <I>filename
</I>] [
<B>-dt
</B>] [
<I>name
</I>]
<DD>
11317 Each time
<B>hash
</B> is invoked,
11318 the full pathname of the command
11321 is determined by searching
11325 and remembered. Any previously-remembered pathname is discarded.
11329 option is supplied, no path search is performed, and
11332 is used as the full filename of the command.
11336 option causes the shell to forget all
11337 remembered locations.
11341 option causes the shell to forget the remembered location of each
<I>name
</I>.
11345 option is supplied, the full pathname to which each
<I>name
</I> corresponds
11346 is printed. If multiple
<I>name
</I> arguments are supplied with
<B>-t
</B>,
11347 the
<I>name
</I> is printed before the hashed full pathname.
11351 option causes output to be displayed in a format that may be reused as input.
11352 If no arguments are given, or if only
<B>-l
</B> is supplied,
11353 information about remembered commands is printed.
11354 The return status is true unless a
11357 is not found or an invalid option is supplied.
11358 <DT><B>help
</B> [
<B>-dms
</B>] [
<I>pattern
</I>]
<DD>
11359 Display helpful information about builtin commands. If
11365 gives detailed help on all commands matching
11368 otherwise help for all the builtins and shell control structures
11370 <DL COMPACT
><DT><DD>
11376 Display a short description of each
<I>pattern
</I>
11380 Display the description of each
<I>pattern
</I> in a manpage-like format
11384 Display only a short usage synopsis for each
<I>pattern
</I>
11389 The return status is
0 unless no command matches
11394 <DT><B>history [
</B><I>n
</I>]
<DD>
11396 <DT><B>history
</B> <B>-c
</B><DD>
11397 <DT><B>history -d
</B> <I>offset
</I><DD>
11398 <DT><B>history -d
</B> <I>start
</I>-
<I>end
</I><DD>
11399 <DT><B>history
</B> <B>-anrw
</B> [
<I>filename
</I>]
<DD>
11400 <DT><B>history
</B> <B>-p
</B> <I>arg
</I> [
<I>arg ...
</I>]
<DD>
11401 <DT><B>history
</B> <B>-s
</B> <I>arg
</I> [
<I>arg ...
</I>]
<DD>
11403 With no options, display the command
11404 history list with line numbers. Lines listed
11408 have been modified. An argument of
11411 lists only the last
11415 If the shell variable
11416 <FONT SIZE=-
1><B>HISTTIMEFORMAT
</B>
11419 is set and not null,
11420 it is used as a format string for
<I>strftime
</I>(
3) to display
11421 the time stamp associated with each displayed history entry.
11422 No intervening blank is printed between the formatted time stamp
11423 and the history line.
11424 If
<I>filename
</I> is supplied, it is used as the
11425 name of the history file; if not, the value of
11426 <FONT SIZE=-
1><B>HISTFILE
</B>
11429 is used. Options, if supplied, have the following meanings:
11430 <DL COMPACT
><DT><DD>
11436 Clear the history list by deleting all the entries.
11437 <DT><B>-d
</B> <I>offset
</I><DD>
11438 Delete the history entry at position
<I>offset
</I>.
11439 If
<I>offset
</I> is negative, it is interpreted as relative to one greater
11440 than the last history position, so negative indices count back from the
11441 end of the history, and an index of -
1 refers to the current
11442 <B>history -d
</B> command.
11443 <DT><B>-d
</B> <I>start
</I>-
<I>end
</I><DD>
11444 Delete the range of history entries between positions
<I>start
</I> and
11445 <I>end
</I>, inclusive.
11446 Positive and negative values for
<I>start
</I> and
<I>end
</I>
11447 are interpreted as described above.
11451 Append the ``new'' history lines to the history file.
11452 These are history lines entered since the beginning of the current
11453 <B>bash
</B> session, but not already appended to the history file.
11457 Read the history lines not already read from the history
11458 file into the current history list. These are lines
11459 appended to the history file since the beginning of the
11460 current
<B>bash
</B> session.
11464 Read the contents of the history file
11465 and append them to the current history list.
11469 Write the current history list to the history file, overwriting the
11470 history file's contents.
11474 Perform history substitution on the following
<I>args
</I> and display
11475 the result on the standard output.
11476 Does not store the results in the history list.
11477 Each
<I>arg
</I> must be quoted to disable normal history expansion.
11484 in the history list as a single entry. The last command in the
11485 history list is removed before the
11494 <FONT SIZE=-
1><B>HISTTIMEFORMAT
</B>
11497 variable is set, the time stamp information
11498 associated with each history entry is written to the history file,
11499 marked with the history comment character.
11500 When the history file is read, lines beginning with the history
11501 comment character followed immediately by a digit are interpreted
11502 as timestamps for the following history entry.
11503 The return value is
0 unless an invalid option is encountered, an
11504 error occurs while reading or writing the history file, an invalid
11505 <I>offset
</I> or range is supplied as an argument to
<B>-d
</B>, or the
11506 history expansion supplied as an argument to
<B>-p
</B> fails.
11509 <DT><B>jobs
</B> [
<B>-lnprs
</B>] [
<I>jobspec
</I> ... ]
<DD>
11511 <DT><B>jobs
</B> <B>-x
</B> <I>command
</I> [
<I>args
</I> ... ]
<DD>
11513 The first form lists the active jobs. The options have the following
11515 <DL COMPACT
><DT><DD>
11522 in addition to the normal information.
11526 Display information only about jobs that have changed status since
11527 the user was last notified of their status.
11531 List only the process ID of the job's process group
11536 Display only running jobs.
11540 Display only stopped jobs.
11548 is given, output is restricted to information about that job.
11549 The return status is
0 unless an invalid option is encountered
11559 option is supplied,
11571 with the corresponding process group ID, and executes
11577 returning its exit status.
11580 <DT><B>kill
</B> [
<B>-s
</B> <I>sigspec
</I> |
<B>-n
</B> <I>signum
</I> |
<B>-
</B><I>sigspec
</I>] [
<I>pid
</I> |
<I>jobspec
</I>] ...
<DD>
11582 <DT><B>kill
</B> <B>-l
</B>|
<B>-L
</B> [
<I>sigspec
</I> |
<I>exit_status
</I>]
<DD>
11584 Send the signal named by
11590 to the processes named by
11598 is either a case-insensitive signal name such as
11599 <FONT SIZE=-
1><B>SIGKILL
</B>
11602 (with or without the
11603 <FONT SIZE=-
1><B>SIG
</B>
11606 prefix) or a signal number;
11609 is a signal number.
11613 is not present, then
11614 <FONT SIZE=-
1><B>SIGTERM
</B>
11621 lists the signal names.
11622 If any arguments are supplied when
11625 is given, the names of the signals corresponding to the arguments are
11626 listed, and the return status is
0.
11627 The
<I>exit_status
</I> argument to
11630 is a number specifying either a signal number or the exit status of
11631 a process terminated by a signal.
11635 option is equivalent to
<B>-l
</B>.
11638 returns true if at least one signal was successfully sent, or false
11639 if an error occurs or an invalid option is encountered.
11640 <DT><B>let
</B> <I>arg
</I> [
<I>arg
</I> ...]
<DD>
11644 is an arithmetic expression to be evaluated (see
11645 <FONT SIZE=-
1><B>ARITHMETIC EVALUATION
</B>
11656 returns
1;
0 is returned otherwise.
11657 <DT><B>local
</B> [
<I>option
</I>] [
<I>name
</I>[=
<I>value
</I>] ... | - ]
<DD>
11658 For each argument, a local variable named
11661 is created, and assigned
11664 The
<I>option
</I> can be any of the options accepted by
<B>declare
</B>.
11668 is used within a function, it causes the variable
11671 to have a visible scope restricted to that function and its children.
11672 If
<I>name
</I> is -, the set of shell options is made local to the function
11673 in which
<B>local
</B> is invoked: shell options changed using the
11674 <B>set
</B> builtin inside the function are restored to their original values
11675 when the function returns.
11676 The restore is effected as if a series of
<B>set
</B> commands were executed
11677 to restore the values that were in place before the function.
11681 writes a list of local variables to the standard output. It is
11685 when not within a function. The return status is
0 unless
11688 is used outside a function, an invalid
11692 <I>name
</I> is a readonly variable.
11696 Exit a login shell.
11697 <DT><B>mapfile
</B> [
<B>-d
</B> <I>delim
</I>] [
<B>-n
</B> <I>count
</I>] [
<B>-O
</B> <I>origin
</I>] [
<B>-s
</B> <I>count
</I>] [
<B>-t
</B>] [
<B>-u
</B> <I>fd
</I>] [
<B>-C
</B> <I>callback
</I>] [
<B>-c
</B> <I>quantum
</I>] [
<I>array
</I>]
<DD>
11699 <DT><B>readarray
</B> [
<B>-d
</B> <I>delim
</I>] [
<B>-n
</B> <I>count
</I>] [
<B>-O
</B> <I>origin
</I>] [
<B>-s
</B> <I>count
</I>] [
<B>-t
</B>] [
<B>-u
</B> <I>fd
</I>] [
<B>-C
</B> <I>callback
</I>] [
<B>-c
</B> <I>quantum
</I>] [
<I>array
</I>]
<DD>
11701 Read lines from the standard input into the indexed array variable
11704 or from file descriptor
11710 option is supplied.
11712 <FONT SIZE=-
1><B>MAPFILE
</B>
11715 is the default
<I>array
</I>.
11716 Options, if supplied, have the following meanings:
11717 <DL COMPACT
><DT><DD>
11723 The first character of
<I>delim
</I> is used to terminate each input line,
11724 rather than newline.
11725 If
<I>delim
</I> is the empty string,
<B>mapfile
</B> will terminate a line
11726 when it reads a NUL character.
11733 lines. If
<I>count
</I> is
0, all lines are copied.
11743 The default index is
0.
11747 Discard the first
<I>count
</I> lines read.
11751 Remove a trailing
<I>delim
</I> (default newline) from each line read.
11755 Read lines from file descriptor
<I>fd
</I> instead of the standard input.
11762 each time
<I>quantum
</I> lines are read. The
<B>-c
</B> option specifies
11768 Specify the number of lines read between each call to
11778 is specified without
11781 the default quantum is
5000.
11782 When
<I>callback
</I> is evaluated, it is supplied the index of the next
11783 array element to be assigned and the line to be assigned to that element
11784 as additional arguments.
11785 <I>callback
</I> is evaluated after the line is read but before the
11786 array element is assigned.
11789 If not supplied with an explicit origin,
<B>mapfile
</B> will clear
<I>array
</I>
11790 before assigning to it.
11793 <B>mapfile
</B> returns successfully unless an invalid option or option
11794 argument is supplied,
<I>array
</I> is invalid or unassignable, or if
11795 <I>array
</I> is not an indexed array.
11798 <DT><B>popd
</B> [-
<B>n
</B>] [+
<I>n
</I>] [-
<I>n
</I>]
<DD>
11799 Removes entries from the directory stack.
11800 The elements are numbered from
0 starting at the first directory
11801 listed by
<B>dirs
</B>.
11802 With no arguments,
<B>popd
</B>
11803 removes the top directory from the stack, and
11804 changes to the new top directory.
11805 Arguments, if supplied, have the following meanings:
11806 <DL COMPACT
><DT><DD>
11812 Suppresses the normal change of directory when removing directories
11813 from the stack, so that only the stack is manipulated.
11814 <DT><B>+
</B><I>n
</I><DD>
11815 Removes the
<I>n
</I>th entry counting from the left of the list
11819 starting with zero, from the stack.
11823 removes the first directory,
11827 <DT><B>-
</B><I>n
</I><DD>
11828 Removes the
<I>n
</I>th entry counting from the right of the list
11832 starting with zero. For example:
11835 removes the last directory,
11843 If the top element of the directory stack is modified, and
11844 the
<I>-n
</I> option was not supplied,
<B>popd
</B> uses the
<B>cd
</B>
11845 builtin to change to the directory at the top of the stack.
11846 If the
<B>cd
</B> fails,
<B>popd
</B> returns a non-zero value.
11852 returns false if an invalid option is encountered, the directory stack
11853 is empty, or a non-existent directory stack entry is specified.
11859 command is successful,
11863 to show the final contents of the directory stack,
11864 and the return status is
0.
11867 <DT><B>printf
</B> [
<B>-v
</B> <I>var
</I>]
<I>format
</I> [
<I>arguments
</I>]
<DD>
11868 Write the formatted
<I>arguments
</I> to the standard output under the
11869 control of the
<I>format
</I>.
11870 The
<B>-v
</B> option causes the output to be assigned to the variable
11871 <I>var
</I> rather than being printed to the standard output.
11873 The
<I>format
</I> is a character string which contains three types of objects:
11874 plain characters, which are simply copied to standard output, character
11875 escape sequences, which are converted and copied to the standard output, and
11876 format specifications, each of which causes printing of the next successive
11878 In addition to the standard
<I>printf
</I>(
1) format specifications,
11879 <B>printf
</B> interprets the following extensions:
11880 <DL COMPACT
><DT><DD>
11887 <B>printf
</B> to expand backslash escape sequences in the corresponding
11889 in the same way as
<B>echo -e
</B>.
11893 causes
<B>printf
</B> to output the corresponding
11894 <I>argument
</I> in a format that can be reused as shell input.
11898 like
<B>%q
</B>, but applies any supplied precision to the
<I>argument
</I>
11900 <DT><B>%(
</B><I>datefmt
</I>)T
11903 causes
<B>printf
</B> to output the date-time string resulting from using
11904 <I>datefmt
</I> as a format string for
<I>strftime
</I>(
3).
11905 The corresponding
<I>argument
</I> is an integer representing the number of
11906 seconds since the epoch.
11907 Two special argument values may be used: -
1 represents the current
11908 time, and -
2 represents the time the shell was invoked.
11909 If no argument is specified, conversion behaves as if -
1 had been given.
11910 This is an exception to the usual
<B>printf
</B> behavior.
11915 The %b, %q, and %T directives all use the field width and precision
11916 arguments from the format specification and write that many bytes from
11917 (or use that wide a field for) the expanded argument, which usually
11918 contains more characters than the original.
11921 Arguments to non-string format specifiers are treated as C constants,
11922 except that a leading plus or minus sign is allowed, and if the leading
11923 character is a single or double quote, the value is the ASCII value of
11924 the following character.
11927 The
<I>format
</I> is reused as necessary to consume all of the
<I>arguments
</I>.
11928 If the
<I>format
</I> requires more
<I>arguments
</I> than are supplied, the
11929 extra format specifications behave as if a zero value or null string, as
11930 appropriate, had been supplied.
11931 The return value is zero on success, non-zero on failure.
11934 <DT><B>pushd
</B> [
<B>-n
</B>] [+
<I>n
</I>] [-
<I>n
</I>]
<DD>
11936 <DT><B>pushd
</B> [
<B>-n
</B>] [
<I>dir
</I>]
<DD>
11938 Adds a directory to the top of the directory stack, or rotates
11939 the stack, making the new top of the stack the current working
11941 With no arguments,
<B>pushd
</B> exchanges the top two elements of
11942 the directory stack.
11943 Arguments, if supplied, have the following meanings:
11944 <DL COMPACT
><DT><DD>
11950 Suppresses the normal change of directory when rotating or
11951 adding directories to the stack, so that only the stack is manipulated.
11952 <DT><B>+
</B><I>n
</I><DD>
11953 Rotates the stack so that the
<I>n
</I>th directory
11954 (counting from the left of the list shown by
11957 starting with zero)
11959 <DT><B>-
</B><I>n
</I><DD>
11960 Rotates the stack so that the
<I>n
</I>th directory
11961 (counting from the right of the list shown by
11964 starting with zero) is at the top.
11971 to the directory stack at the top
11976 After the stack has been modified, if the
<B>-n
</B> option was not
11977 supplied,
<B>pushd
</B> uses the
<B>cd
</B> builtin to change to the
11978 directory at the top of the stack.
11979 If the
<B>cd
</B> fails,
<B>pushd
</B> returns a non-zero value.
11982 Otherwise, if no arguments are supplied,
11985 returns
0 unless the directory stack is empty.
11986 When rotating the directory stack,
11989 returns
0 unless the directory stack is empty or
11990 a non-existent directory stack element is specified.
11996 command is successful,
12000 to show the final contents of the directory stack.
12003 <DT><B>pwd
</B> [
<B>-LP
</B>]
<DD>
12004 Print the absolute pathname of the current working directory.
12005 The pathname printed contains no symbolic links if the
12008 option is supplied or the
12014 builtin command is enabled.
12018 option is used, the pathname printed may contain symbolic links.
12019 The return status is
0 unless an error occurs while
12020 reading the name of the current directory or an
12021 invalid option is supplied.
12022 <DT><B>read
</B> [
<B>-ers
</B>] [
<B>-a
</B> <I>aname
</I>] [
<B>-d
</B> <I>delim
</I>] [
<B>-i
</B> <I>text
</I>] [
<B>-n
</B> <I>nchars
</I>] [
<B>-N
</B> <I>nchars
</I>] [
<B>-p
</B> <I>prompt
</I>] [
<B>-t
</B> <I>timeout
</I>] [
<B>-u
</B> <I>fd
</I>] [
<I>name
</I> ...]
<DD>
12023 One line is read from the standard input, or from the file descriptor
12024 <I>fd
</I> supplied as an argument to the
<B>-u
</B> option,
12025 split into words as described
12028 under
<B>Word Splitting
</B>,
12030 is assigned to the first
12033 the second word to the second
12037 If there are more words than names, the remaining words and their
12038 intervening delimiters are assigned to the last
12041 If there are fewer words read from the input stream than names,
12042 the remaining names are assigned empty values.
12044 <FONT SIZE=-
1><B>IFS
</B>
12047 are used to split the line into words using the same rules the shell
12048 uses for expansion (described
12051 under
<B>Word Splitting
</B>).
12052 The backslash character (
<B>\
</B>) may be used to remove any special
12053 meaning for the next character read and for line continuation.
12054 Options, if supplied, have the following meanings:
12055 <DL COMPACT
><DT><DD>
12058 <DT><B>-a
</B><I>aname
</I>
12061 The words are assigned to sequential indices
12062 of the array variable
12068 is unset before any new values are assigned.
12069 Other
<I>name
</I> arguments are ignored.
12070 <DT><B>-d
</B><I>delim
</I>
12073 The first character of
<I>delim
</I> is used to terminate the input line,
12074 rather than newline.
12075 If
<I>delim
</I> is the empty string,
<B>read
</B> will terminate a line
12076 when it reads a NUL character.
12080 If the standard input
12081 is coming from a terminal,
12085 <FONT SIZE=-
1><B>READLINE
</B>
12090 is used to obtain the line.
12091 Readline uses the current (or default, if line editing was not previously
12092 active) editing settings, but uses readline's default filename completion.
12093 <DT><B>-i
</B><I>text
</I>
12099 is being used to read the line,
<I>text
</I> is placed into the editing
12100 buffer before editing begins.
12101 <DT><B>-n
</B><I>nchars
</I>
12104 <B>read
</B> returns after reading
<I>nchars
</I> characters rather than
12105 waiting for a complete line of input, but honors a delimiter if fewer
12106 than
<I>nchars
</I> characters are read before the delimiter.
12107 <DT><B>-N
</B><I>nchars
</I>
12110 <B>read
</B> returns after reading exactly
<I>nchars
</I> characters rather
12111 than waiting for a complete line of input, unless EOF is encountered or
12112 <B>read
</B> times out.
12113 Delimiter characters encountered in the input are
12114 not treated specially and do not cause
<B>read
</B> to return until
12115 <I>nchars
</I> characters are read.
12116 The result is not split on the characters in
<B>IFS
</B>; the intent is
12117 that the variable is assigned exactly the characters read
12118 (with the exception of backslash; see the
<B>-r
</B> option below).
12119 <DT><B>-p
</B><I>prompt
</I>
12122 Display
<I>prompt
</I> on standard error, without a
12123 trailing newline, before attempting to read any input. The prompt
12124 is displayed only if input is coming from a terminal.
12128 Backslash does not act as an escape character.
12129 The backslash is considered to be part of the line.
12130 In particular, a backslash-newline pair may not then be used as a line
12135 Silent mode. If input is coming from a terminal, characters are
12137 <DT><B>-t
</B><I>timeout
</I>
12140 Cause
<B>read
</B> to time out and return failure if a complete line of
12141 input (or a specified number of characters)
12142 is not read within
<I>timeout
</I> seconds.
12143 <I>timeout
</I> may be a decimal number with a fractional portion following
12145 This option is only effective if
<B>read
</B> is reading input from a
12146 terminal, pipe, or other special file; it has no effect when reading
12147 from regular files.
12148 If
<B>read
</B> times out,
<B>read
</B> saves any partial input read into
12149 the specified variable
<I>name
</I>.
12150 If
<I>timeout
</I> is
0,
<B>read
</B> returns immediately, without trying to
12152 The exit status is
0 if input is available on the specified file descriptor,
12153 or the read will return EOF,
12154 non-zero otherwise.
12155 The exit status is greater than
128 if the timeout is exceeded.
12156 <DT><B>-u
</B><I>fd
</I>
12159 Read input from file descriptor
<I>fd
</I>.
12167 are supplied, the line read,
12168 without the ending delimiter but otherwise unmodified,
12169 is assigned to the variable
12170 <FONT SIZE=-
1><B>REPLY
</B>.
12173 The exit status is zero, unless end-of-file is encountered,
<B>read
</B>
12174 times out (in which case the status is greater than
128),
12175 a variable assignment error (such as assigning to a readonly variable) occurs,
12176 or an invalid file descriptor is supplied as the argument to
<B>-u
</B>.
12179 <DT><B>readonly
</B> [
<B>-aAf
</B>] [
<B>-p
</B>] [
<I>name
</I>[=
<I>word
</I>] ...]
<DD>
12182 <I>names
</I> are marked readonly; the values of these
12185 may not be changed by subsequent assignment.
12189 option is supplied, the functions corresponding to the
12190 <I>names
</I> are so
12195 option restricts the variables to indexed arrays; the
12198 option restricts the variables to associative arrays.
12199 If both options are supplied,
12206 arguments are given, or if the
12209 option is supplied, a list of all readonly names is printed.
12210 The other options may be used to restrict the output to a subset of
12211 the set of readonly names.
12215 option causes output to be displayed in a format that
12216 may be reused as input.
12217 If a variable name is followed by =
<I>word
</I>, the value of
12218 the variable is set to
<I>word
</I>.
12219 The return status is
0 unless an invalid option is encountered,
12223 is not a valid shell variable name, or
12229 that is not a function.
12230 <DT><B>return
</B> [
<I>n
</I>]
<DD>
12231 Causes a function to stop executing and return the value specified by
12238 is omitted, the return status is that of the last command
12239 executed in the function body.
12240 If
<B>return
</B> is executed by a trap handler, the last command used to
12241 determine the status is the last command executed before the trap handler.
12242 If
<B>return
</B> is executed during a
<B>DEBUG
</B> trap, the last command
12243 used to determine the status is the last command executed by the trap
12244 handler before
<B>return
</B> was invoked.
12248 is used outside a function,
12249 but during execution of a script by the
12252 (
<B>source
</B>) command, it causes the shell to stop executing
12253 that script and return either
12256 or the exit status of the last command executed within the
12257 script as the exit status of the script.
12258 If
<I>n
</I> is supplied, the return value is its least significant
12260 The return status is non-zero if
12263 is supplied a non-numeric argument, or
12265 function and not during execution of a script by
<B>.
</B> or
<B>source
</B>.
12266 Any command associated with the
<B>RETURN
</B> trap is executed
12267 before execution resumes after the function or script.
12268 <DT><B>set
</B> [
<B>-abefhkmnptuvxBCEHPT
</B>] [
<B>-o
</B> <I>option-name
</I>] [
<B>--
</B>] [
<B>-
</B>] [
<I>arg
</I> ...]
<DD>
12270 <DT><B>set
</B> [
<B>+abefhkmnptuvxBCEHPT
</B>] [
<B>+o
</B> <I>option-name
</I>] [
<B>--
</B>] [
<B>-
</B>] [
<I>arg
</I> ...]
<DD>
12272 Without options, display the name and value of each shell variable
12273 in a format that can be reused as input
12274 for setting or resetting the currently-set variables.
12275 Read-only variables cannot be reset.
12276 In
<I>posix mode
</I>, only shell variables are listed.
12277 The output is sorted according to the current locale.
12278 When options are specified, they set or unset shell attributes.
12279 Any arguments remaining after option processing are treated
12280 as values for the positional parameters and are assigned, in order, to
12289 Options, if specified, have the following meanings:
12290 <DL COMPACT
><DT><DD>
12296 Each variable or function that is created or modified is given the
12297 export attribute and marked for export to the environment of
12298 subsequent commands.
12302 Report the status of terminated background jobs
12303 immediately, rather than before the next primary prompt. This is
12304 effective only when job control is enabled.
12308 Exit immediately if a
12309 <I>pipeline
</I> (which may consist of a single
<I>simple command
</I>),
12311 or a
<I>compound command
</I>
12313 <FONT SIZE=-
1><B>SHELL GRAMMAR
</B>
12318 exits with a non-zero status.
12319 The shell does not exit if the
12320 command that fails is part of the command list immediately following a
12327 part of the test following the
12333 reserved words, part of any command executed in a
12339 list except the command following the final
<B>&&</B> or
<B>||
</B>,
12340 any command in a pipeline but the last,
12341 or if the command's return value is
12342 being inverted with
12345 If a compound command other than a subshell
12346 returns a non-zero status because a command failed
12347 while
<B>-e
</B> was being ignored, the shell does not exit.
12348 A trap on
<B>ERR
</B>, if set, is executed before the shell exits.
12349 This option applies to the shell environment and each subshell environment
12351 <FONT SIZE=-
1><B>COMMAND EXECUTION ENVIRONMENT
</B>
12357 subshells to exit before executing all the commands in the subshell.
12361 If a compound command or shell function executes in a context
12362 where
<B>-e
</B> is being ignored,
12363 none of the commands executed within the compound command or function body
12364 will be affected by the
<B>-e
</B> setting, even if
<B>-e
</B> is set
12365 and a command returns a failure status.
12366 If a compound command or shell function sets
<B>-e
</B> while executing in
12367 a context where
<B>-e
</B> is ignored, that setting will not have any
12368 effect until the compound command or the command containing the function
12373 Disable pathname expansion.
12377 Remember the location of commands as they are looked up for execution.
12378 This is enabled by default.
12382 All arguments in the form of assignment statements
12383 are placed in the environment for a command, not just
12384 those that precede the command name.
12388 Monitor mode. Job control is enabled. This option is on
12389 by default for interactive shells on systems that support
12391 <FONT SIZE=-
1><B>JOB CONTROL
</B>
12396 All processes run in a separate process group.
12397 When a background job completes, the shell prints a line
12398 containing its exit status.
12402 Read commands but do not execute them.
12403 This may be used to check a shell script for syntax errors.
12404 This is ignored by interactive shells.
12405 <DT><B>-o
</B><I>option-name
</I>
12408 The
<I>option-name
</I> can be one of the following:
12409 <DL COMPACT
><DT><DD>
12411 <DT><B>allexport
</B>
12417 <DT><B>braceexpand
</B>
12426 Use an emacs-style command line editing interface. This is enabled
12427 by default when the shell is interactive, unless the shell is started
12432 This also affects the editing interface used for
<B>read -e
</B>.
12439 <DT><B>errtrace
</B>
12445 <DT><B>functrace
</B>
12457 <DT><B>histexpand
</B>
12466 Enable command history, as described
12470 <FONT SIZE=-
1><B>HISTORY
</B>.
12473 This option is on by default in interactive shells.
12474 <DT><B>ignoreeof
</B>
12477 The effect is as if the shell command
12478 <TT>IGNOREEOF=
10</TT>
12482 <B>Shell Variables
</B>
12498 <DT><B>noclobber
</B>
12538 <DT><B>physical
</B>
12544 <DT><B>pipefail
</B>
12547 If set, the return value of a pipeline is the value of the last
12548 (rightmost) command to exit with a non-zero status, or zero if all
12549 commands in the pipeline exit successfully.
12550 This option is disabled by default.
12554 Change the behavior of
12557 where the default operation differs
12558 from the POSIX standard to match the standard (
<I>posix mode
</I>).
12560 <FONT SIZE=-
1><B>SEE ALSO
</B>
12565 for a reference to a document that details how posix mode affects
12567 <DT><B>privileged
</B>
12582 Use a vi-style command line editing interface.
12583 This also affects the editing interface used for
<B>read -e
</B>.
12597 is supplied with no
<I>option-name
</I>, the values of the current options are
12602 is supplied with no
<I>option-name
</I>, a series of
12605 commands to recreate the current option settings is displayed on
12606 the standard output.
12615 mode. In this mode, the
12616 <FONT SIZE=-
1><B>$ENV
</B>
12620 <FONT SIZE=-
1><B>$BASH_ENV
</B>
12623 files are not processed, shell functions are not inherited from the
12624 environment, and the
12625 <FONT SIZE=-
1><B>SHELLOPTS
</B>,
12628 <FONT SIZE=-
1><B>BASHOPTS
</B>,
12631 <FONT SIZE=-
1><B>CDPATH
</B>,
12635 <FONT SIZE=-
1><B>GLOBIGNORE
</B>
12638 variables, if they appear in the environment, are ignored.
12639 If the shell is started with the effective user (group) id not equal to the
12640 real user (group) id, and the
<B>-p
</B> option is not supplied, these actions
12641 are taken and the effective user id is set to the real user id.
12642 If the
<B>-p
</B> option is supplied at startup, the effective user id is
12644 Turning this option off causes the effective user
12645 and group ids to be set to the real user and group ids.
12649 Enable restricted shell mode.
12650 This option cannot be unset once it has been set.
12654 Exit after reading and executing one command.
12658 Treat unset variables and parameters other than the special
12659 parameters
"@
" and
"*
",
12660 or array variables subscripted with
"@
" or
"*
",
12661 as an error when performing
12662 parameter expansion. If expansion is attempted on an
12663 unset variable or parameter, the shell prints an error message, and,
12664 if not interactive, exits with a non-zero status.
12668 Print shell input lines as they are read.
12672 After expanding each
<I>simple command
</I>,
12673 <B>for
</B> command,
<B>case
</B> command,
<B>select
</B> command, or
12674 arithmetic
<B>for
</B> command, display the expanded value of
12675 <FONT SIZE=-
1><B>PS4
</B>,
12678 followed by the command and its expanded arguments
12679 or associated word list.
12683 The shell performs brace expansion (see
12684 <B>Brace Expansion
</B>
12688 This is on by default.
12695 does not overwrite an existing file with the
12703 redirection operators. This may be overridden when
12704 creating output files by using the redirection operator
12713 If set, any trap on
<B>ERR
</B> is inherited by shell functions, command
12714 substitutions, and commands executed in a subshell environment.
12715 The
<B>ERR
</B> trap is normally not inherited in such cases.
12722 style history substitution. This option is on by
12723 default when the shell is interactive.
12727 If set, the shell does not resolve symbolic links when executing
12731 that change the current working directory. It uses the
12732 physical directory structure instead. By default,
12735 follows the logical chain of directories when performing commands
12736 which change the current directory.
12740 If set, any traps on
<B>DEBUG
</B> and
<B>RETURN
</B> are inherited by shell
12741 functions, command substitutions, and commands executed in a
12742 subshell environment.
12743 The
<B>DEBUG
</B> and
<B>RETURN
</B> traps are normally not inherited
12748 If no arguments follow this option, then the positional parameters are
12749 unset. Otherwise, the positional parameters are set to the
12750 <I>arg
</I>s, even if some of them begin with a
12756 Signal the end of options, cause all remaining
<I>arg
</I>s to be
12757 assigned to the positional parameters. The
12763 options are turned off.
12764 If there are no
<I>arg
</I>s,
12765 the positional parameters remain unchanged.
12770 The options are off by default unless otherwise noted.
12771 Using + rather than - causes these options to be turned off.
12772 The options can also be specified as arguments to an invocation of
12774 The current set of options may be found in
12777 The return status is always true unless an invalid option is encountered.
12780 <DT><B>shift
</B> [
<I>n
</I>]
<DD>
12781 The positional parameters from
<I>n
</I>+
1 ... are renamed to
12786 Parameters represented by the numbers
<B>$#
</B>
12787 down to
<B>$#
</B>-
<I>n
</I>+
1 are unset.
12790 must be a non-negative number less than or equal to
<B>$#
</B>.
12794 is
0, no parameters are changed.
12798 is not given, it is assumed to be
1.
12802 is greater than
<B>$#
</B>, the positional parameters are not changed.
12803 The return status is greater than zero if
12809 or less than zero; otherwise
0.
12810 <DT><B>shopt
</B> [
<B>-pqsu
</B>] [
<B>-o
</B>] [
<I>optname
</I> ...]
<DD>
12811 Toggle the values of settings controlling optional shell behavior.
12812 The settings can be either those listed below, or, if the
12815 option is used, those available with the
12818 option to the
<B>set
</B> builtin command.
12819 With no options, or with the
12822 option, a list of all settable options is displayed, with
12823 an indication of whether or not each is set;
12824 if
<I>optnames
</I> are supplied, the output is restricted to those options.
12825 The
<B>-p
</B> option causes output to be displayed in a form that
12826 may be reused as input.
12827 Other options have the following meanings:
12828 <DL COMPACT
><DT><DD>
12834 Enable (set) each
<I>optname
</I>.
12838 Disable (unset) each
<I>optname
</I>.
12842 Suppresses normal output (quiet mode); the return status indicates
12843 whether the
<I>optname
</I> is set or unset.
12844 If multiple
<I>optname
</I> arguments are given with
12847 the return status is zero if all
<I>optnames
</I> are enabled; non-zero
12852 Restricts the values of
<I>optname
</I> to be those defined for the
12869 is used with no
<I>optname
</I> arguments,
12872 shows only those options which are set or unset, respectively.
12873 Unless otherwise noted, the
<B>shopt
</B> options are disabled (unset)
12877 The return status when listing options is zero if all
<I>optnames
</I>
12878 are enabled, non-zero otherwise. When setting or unsetting options,
12879 the return status is zero unless an
<I>optname
</I> is not a valid shell
12883 The list of
<B>shopt
</B> options is:
12889 <DT><B>assoc_expand_once
</B>
12892 If set, the shell suppresses multiple evaluation of associative array
12893 subscripts during arithmetic expression evaluation, while executing
12894 builtins that can perform variable assignments,
12895 and while executing builtins that perform array dereferencing.
12899 If set, a command name that is the name of a directory is executed as if
12900 it were the argument to the
<B>cd
</B> command.
12901 This option is only used by interactive shells.
12902 <DT><B>cdable_vars
</B>
12905 If set, an argument to the
12908 builtin command that
12909 is not a directory is assumed to be the name of a variable whose
12910 value is the directory to change to.
12914 If set, minor errors in the spelling of a directory component in a
12917 command will be corrected.
12918 The errors checked for are transposed characters,
12919 a missing character, and one character too many.
12920 If a correction is found, the corrected filename is printed,
12921 and the command proceeds.
12922 This option is only used by interactive shells.
12923 <DT><B>checkhash
</B>
12926 If set,
<B>bash
</B> checks that a command found in the hash
12927 table exists before trying to execute it. If a hashed command no
12928 longer exists, a normal path search is performed.
12929 <DT><B>checkjobs
</B>
12932 If set,
<B>bash
</B> lists the status of any stopped and running jobs before
12933 exiting an interactive shell. If any jobs are running, this causes
12934 the exit to be deferred until a second exit is attempted without an
12935 intervening command (see
12936 <FONT SIZE=-
1><B>JOB CONTROL
</B>
12941 The shell always postpones exiting if any jobs are stopped.
12942 <DT><B>checkwinsize
</B>
12945 If set,
<B>bash
</B> checks the window size after each external (non-builtin)
12946 command and, if necessary, updates the values of
12947 <FONT SIZE=-
1><B>LINES
</B>
12951 <FONT SIZE=-
1><B>COLUMNS
</B>.
12954 This option is enabled by default.
12961 attempts to save all lines of a multiple-line
12962 command in the same history entry. This allows
12963 easy re-editing of multi-line commands.
12964 This option is enabled by default, but only has an effect if command
12965 history is enabled, as described
12969 <FONT SIZE=-
1><B>HISTORY
</B>.
12973 <DT><B>compat31
</B>
12976 <DT><B>compat32
</B>
12979 <DT><B>compat40
</B>
12982 <DT><B>compat41
</B>
12985 <DT><B>compat42
</B>
12988 <DT><B>compat43
</B>
12991 <DT><B>compat44
</B>
12994 <DT><B>compat50
</B>
12998 These control aspects of the shell's compatibility mode
13000 <FONT SIZE=-
1><B>SHELL COMPATIBILITY MODE
</B>
13005 <DT><B>complete_fullquote
</B>
13011 quotes all shell metacharacters in filenames and directory names when
13012 performing completion.
13016 removes metacharacters such as the dollar sign from the set of
13017 characters that will be quoted in completed filenames
13018 when these metacharacters appear in shell variable references in words to be
13020 This means that dollar signs in variable names that expand to directories
13021 will not be quoted;
13022 however, any dollar signs appearing in filenames will not be quoted, either.
13023 This is active only when bash is using backslashes to quote completed
13025 This variable is set by default, which is the default bash behavior in
13026 versions through
4.2.
13027 <DT><B>direxpand
</B>
13033 replaces directory names with the results of word expansion when performing
13034 filename completion. This changes the contents of the readline editing
13039 attempts to preserve what the user typed.
13040 <DT><B>dirspell
</B>
13046 attempts spelling correction on directory names during word completion
13047 if the directory name initially supplied does not exist.
13054 includes filenames beginning with a `.' in the results of pathname
13062 must always be matched explicitly, even if
13066 <DT><B>execfail
</B>
13069 If set, a non-interactive shell will not exit if
13070 it cannot execute the file specified as an argument to the
13073 builtin command. An interactive shell does not exit if
13077 <DT><B>expand_aliases
</B>
13080 If set, aliases are expanded as described
13084 <FONT SIZE=-
1><B>ALIASES
</B>.
13087 This option is enabled by default for interactive shells.
13088 <DT><B>extdebug
</B>
13091 If set at shell invocation,
13092 or in a shell startup file,
13093 arrange to execute the debugger profile
13094 before the shell starts, identical to the
<B>--debugger
</B> option.
13095 If set after invocation, behavior intended for use by debuggers is enabled:
13096 <DL COMPACT
><DT><DD>
13101 The
<B>-F
</B> option to the
<B>declare
</B> builtin displays the source
13102 file name and line number corresponding to each function name supplied
13107 If the command run by the
<B>DEBUG
</B> trap returns a non-zero value, the
13108 next command is skipped and not executed.
13112 If the command run by the
<B>DEBUG
</B> trap returns a value of
2, and the
13113 shell is executing in a subroutine (a shell function or a shell script
13114 executed by the
<B>.
</B> or
<B>source
</B> builtins), the shell simulates
13115 a call to
<B>return
</B>.
13119 <FONT SIZE=-
1><B>BASH_ARGC
</B>
13123 <FONT SIZE=-
1><B>BASH_ARGV
</B>
13126 are updated as described in their descriptions
13132 Function tracing is enabled: command substitution, shell functions, and
13133 subshells invoked with
<B>(
</B> <I>command
</I> <B>)
</B> inherit the
13134 <B>DEBUG
</B> and
<B>RETURN
</B> traps.
13138 Error tracing is enabled: command substitution, shell functions, and
13139 subshells invoked with
<B>(
</B> <I>command
</I> <B>)
</B> inherit the
13146 If set, the extended pattern matching features described
13150 <B>Pathname Expansion
</B> are enabled.
13151 <DT><B>extquote
</B>
13154 If set,
<B>$
</B>aq
<I>string
</I>aq and
<B>$
</B>"<I>string
</I>" quoting is
13155 performed within
<B>${
</B><I>parameter
</I><B>}
</B> expansions
13156 enclosed in double quotes. This option is enabled by default.
13157 <DT><B>failglob
</B>
13160 If set, patterns which fail to match filenames during pathname expansion
13161 result in an expansion error.
13162 <DT><B>force_fignore
</B>
13165 If set, the suffixes specified by the
13166 <FONT SIZE=-
1><B>FIGNORE
</B>
13170 cause words to be ignored when performing word completion even if
13171 the ignored words are the only possible completions.
13173 <FONT SIZE=-
1><B>SHELL VARIABLES
</B></FONT>
13176 for a description of
13177 <FONT SIZE=-
1><B>FIGNORE
</B>.
13180 This option is enabled by default.
13181 <DT><B>globasciiranges
</B>
13184 If set, range expressions used in pattern matching bracket expressions (see
13185 <FONT SIZE=-
1><B>Pattern Matching
</B>
13190 behave as if in the traditional C locale when performing
13191 comparisons. That is, the current locale's collating sequence
13192 is not taken into account, so
13195 will not collate between
13201 and upper-case and lower-case ASCII characters will collate together.
13202 <DT><B>globskipdots
</B>
13205 If set, pathname expansion will never match the filenames
13211 even if the pattern begins with a
13214 This option is enabled by default.
13215 <DT><B>globstar
</B>
13218 If set, the pattern
<B>**
</B> used in a pathname expansion context will
13219 match all files and zero or more directories and subdirectories.
13220 If the pattern is followed by a
<B>/
</B>, only directories and
13221 subdirectories match.
13222 <DT><B>gnu_errfmt
</B>
13225 If set, shell error messages are written in the standard GNU error
13227 <DT><B>histappend
</B>
13230 If set, the history list is appended to the file named by the value
13232 <FONT SIZE=-
1><B>HISTFILE
</B>
13235 variable when the shell exits, rather than overwriting the file.
13236 <DT><B>histreedit
</B>
13242 is being used, a user is given the opportunity to re-edit a
13243 failed history substitution.
13244 <DT><B>histverify
</B>
13250 is being used, the results of history substitution are not immediately
13251 passed to the shell parser. Instead, the resulting line is loaded into
13252 the
<B>readline
</B> editing buffer, allowing further modification.
13253 <DT><B>hostcomplete
</B>
13259 is being used,
<B>bash
</B> will attempt to perform hostname completion when a
13260 word containing a
<B>@
</B> is being completed (see
13264 <FONT SIZE=-
1><B>READLINE
</B>
13269 This is enabled by default.
13270 <DT><B>huponexit
</B>
13273 If set,
<B>bash
</B> will send
13274 <FONT SIZE=-
1><B>SIGHUP
</B>
13277 to all jobs when an interactive login shell exits.
13278 <DT><B>inherit_errexit
</B>
13281 If set, command substitution inherits the value of the
<B>errexit
</B> option,
13282 instead of unsetting it in the subshell environment.
13283 This option is enabled when
<I>posix mode
</I> is enabled.
13284 <DT><B>interactive_comments
</B>
13287 If set, allow a word beginning with
13290 to cause that word and all remaining characters on that
13291 line to be ignored in an interactive shell (see
13292 <FONT SIZE=-
1><B>COMMENTS
</B>
13297 This option is enabled by default.
13298 <DT><B>lastpipe
</B>
13301 If set, and job control is not active, the shell runs the last command of
13302 a pipeline not executed in the background in the current shell environment.
13309 option is enabled, multi-line commands are saved to the history with
13310 embedded newlines rather than using semicolon separators where possible.
13311 <DT><B>localvar_inherit
</B>
13314 If set, local variables inherit the value and attributes of a variable of
13315 the same name that exists at a previous scope before any new value is
13316 assigned. The nameref attribute is not inherited.
13317 <DT><B>localvar_unset
</B>
13320 If set, calling
<B>unset
</B> on local variables in previous function scopes
13321 marks them so subsequent lookups find them unset until that function
13322 returns. This is identical to the behavior of unsetting local variables
13323 at the current function scope.
13324 <DT><B>login_shell
</B>
13327 The shell sets this option if it is started as a login shell (see
13328 <FONT SIZE=-
1><B>INVOCATION
</B>
13333 The value may not be changed.
13334 <DT><B>mailwarn
</B>
13337 If set, and a file that
<B>bash
</B> is checking for mail has been
13338 accessed since the last time it was checked, the message ``The mail in
13339 <I>mailfile
</I> has been read'' is displayed.
13340 <DT><B>no_empty_cmd_completion
</B>
13349 will not attempt to search the
13350 <FONT SIZE=-
1><B>PATH
</B>
13353 for possible completions when
13354 completion is attempted on an empty line.
13355 <DT><B>nocaseglob
</B>
13361 matches filenames in a case-insensitive fashion when performing pathname
13363 <B>Pathname Expansion
</B>
13367 <DT><B>nocasematch
</B>
13373 matches patterns in a case-insensitive fashion when performing matching
13374 while executing
<B>case
</B> or
<B>[[
</B> conditional commands,
13375 when performing pattern substitution word expansions,
13376 or when filtering possible completions as part of programmable completion.
13377 <DT><B>noexpand_translation
</B>
13383 encloses the translated results of $
"...
" quoting in single quotes
13384 instead of double quotes.
13385 If the string is not translated, this has no effect.
13386 <DT><B>nullglob
</B>
13392 allows patterns which match no
13394 <B>Pathname Expansion
</B>
13398 to expand to a null string, rather than themselves.
13399 <DT><B>patsub_replacement
</B>
13402 If set,
<B>bash
</B>
13403 expands occurrences of
<B>&</B> in the replacement string of pattern
13404 substitution to the text matched by the pattern, as described
13405 under
<B>Parameter Expansion
</B>
13408 This option is enabled by default.
13409 <DT><B>progcomp
</B>
13412 If set, the programmable completion facilities (see
13413 <B>Programmable Completion
</B>
13417 This option is enabled by default.
13418 <DT><B>progcomp_alias
</B>
13421 If set, and programmable completion is enabled,
<B>bash
</B> treats a command
13422 name that doesn't have any completions as a possible alias and attempts
13423 alias expansion. If it has an alias,
<B>bash
</B> attempts programmable
13424 completion using the command word resulting from the expanded alias.
13425 <DT><B>promptvars
</B>
13428 If set, prompt strings undergo
13429 parameter expansion, command substitution, arithmetic
13430 expansion, and quote removal after being expanded as described in
13431 <FONT SIZE=-
1><B>PROMPTING
</B>
13436 This option is enabled by default.
13437 <DT><B>restricted_shell
</B>
13440 The shell sets this option if it is started in restricted mode
13442 <FONT SIZE=-
1><B>RESTRICTED SHELL
</B>
13447 The value may not be changed.
13448 This is not reset when the startup files are executed, allowing
13449 the startup files to discover whether or not a shell is restricted.
13450 <DT><B>shift_verbose
</B>
13456 builtin prints an error message when the shift count exceeds the
13457 number of positional parameters.
13458 <DT><B>sourcepath
</B>
13462 <B>.
</B> (
<B>source
</B>) builtin uses the value of
13463 <FONT SIZE=-
1><B>PATH
</B>
13466 to find the directory containing the file supplied as an argument.
13467 This option is enabled by default.
13468 <DT><B>varredir_close
</B>
13471 If set, the shell automatically closes file descriptors assigned using the
13472 <I>{varname}
</I> redirection syntax (see
13473 <FONT SIZE=-
1><B>REDIRECTION
</B>
13478 instead of leaving them open when the command completes.
13479 <DT><B>xpg_echo
</B>
13482 If set, the
<B>echo
</B> builtin expands backslash-escape sequences
13487 <DT><B>suspend
</B> [
<B>-f
</B>]
<DD>
13488 Suspend the execution of this shell until it receives a
13489 <FONT SIZE=-
1><B>SIGCONT
</B>
13492 signal. A login shell,
13493 or a shell without job control enabled,
13494 cannot be suspended; the
13497 option can be used to override this and force the suspension.
13498 The return status is
0 unless the shell is a login shell
13499 or job control is not enabled
13504 <DT><B>test
</B> <I>expr
</I><DD>
13506 <DT><B>[
</B> <I>expr
</I> <B>]
</B><DD>
13507 Return a status of
0 (true) or
1 (false) depending on
13508 the evaluation of the conditional expression
13511 Each operator and operand must be a separate argument.
13512 Expressions are composed of the primaries described
13516 <FONT SIZE=-
1><B>CONDITIONAL EXPRESSIONS
</B>.
13519 <B>test
</B> does not accept any options, nor does it accept and ignore
13520 an argument of
<B>--
</B> as signifying the end of options.
13524 Expressions may be combined using the following operators, listed
13525 in decreasing order of precedence.
13526 The evaluation depends on the number of arguments; see below.
13527 Operator precedence is used when there are five or more arguments.
13528 <DL COMPACT
><DT><DD>
13531 <DT><B>!
</B><I>expr
</I>
13538 <DT><B>(
</B><I>expr
</I> )
13541 Returns the value of
<I>expr
</I>.
13542 This may be used to override the normal precedence of operators.
13543 <DT><I>expr1
</I> -
<B>a
</B> <I>expr2
</I><DD>
13551 <DT><I>expr1
</I> -
<B>o
</B> <I>expr2
</I><DD>
13563 <B>test
</B> and
<B>[
</B> evaluate conditional
13564 expressions using a set of rules based on the number of arguments.
13570 <DT>0 arguments
<DD>
13571 The expression is false.
13573 The expression is true if and only if the argument is not null.
13574 <DT>2 arguments
<DD>
13575 If the first argument is
<B>!
</B>, the expression is true if and
13576 only if the second argument is null.
13577 If the first argument is one of the unary conditional operators listed
13581 <FONT SIZE=-
1><B>CONDITIONAL EXPRESSIONS
</B>,
13584 the expression is true if the unary test is true.
13585 If the first argument is not a valid unary conditional operator, the expression
13587 <DT>3 arguments
<DD>
13588 The following conditions are applied in the order listed.
13589 If the second argument is one of the binary conditional operators listed
13593 <FONT SIZE=-
1><B>CONDITIONAL EXPRESSIONS
</B>,
13596 the result of the expression is the result of the binary test using
13597 the first and third arguments as operands.
13598 The
<B>-a
</B> and
<B>-o
</B> operators are considered binary operators
13599 when there are three arguments.
13600 If the first argument is
<B>!
</B>, the value is the negation of
13601 the two-argument test using the second and third arguments.
13602 If the first argument is exactly
<B>(
</B> and the third argument is
13603 exactly
<B>)
</B>, the result is the one-argument test of the second
13605 Otherwise, the expression is false.
13606 <DT>4 arguments
<DD>
13607 The following conditions are applied in the order listed.
13608 If the first argument is
<B>!
</B>, the result is the negation of
13609 the three-argument expression composed of the remaining arguments.
13610 the two-argument test using the second and third arguments.
13611 If the first argument is exactly
<B>(
</B> and the fourth argument is
13612 exactly
<B>)
</B>, the result is the two-argument test of the second
13613 and third arguments.
13614 Otherwise, the expression is parsed and evaluated according to
13615 precedence using the rules listed above.
13616 <DT>5 or more arguments
<DD>
13617 The expression is parsed and evaluated according to precedence
13618 using the rules listed above.
13625 When used with
<B>test
</B> or
<B>[
</B>, the
<B><</B> and
<B>></B> operators
13626 sort lexicographically using ASCII ordering.
13633 Print the accumulated user and system times for the shell and
13634 for processes run from the shell. The return status is
0.
13635 <DT><B>trap
</B> [
<B>-lp
</B>] [[
<I>arg
</I>]
<I>sigspec
</I> ...]
<DD>
13639 is to be read and executed when the shell receives
13646 is absent (and there is a single
<I>sigspec
</I>) or
13649 each specified signal is
13650 reset to its original disposition (the value it had
13651 upon entrance to the shell).
13655 is the null string the signal specified by each
13658 is ignored by the shell and by the commands it invokes.
13665 has been supplied, then the trap commands associated with each
13669 If no arguments are supplied or if only
13675 prints the list of commands associated with each signal.
13679 option causes the shell to print a list of signal names and
13680 their corresponding numbers.
13685 a signal name defined in
<<I>signal.h
</I>>, or a signal number.
13686 Signal names are case insensitive and the
13687 <FONT SIZE=-
1><B>SIG
</B>
13690 prefix is optional.
13698 <FONT SIZE=-
1><B>EXIT
</B>
13704 is executed on exit from the shell.
13709 <FONT SIZE=-
1><B>DEBUG
</B>,
13715 is executed before every
<I>simple command
</I>,
<I>for
</I> command,
13716 <I>case
</I> command,
<I>select
</I> command, every arithmetic
<I>for
</I>
13717 command, and before the first command executes in a shell function (see
13718 <FONT SIZE=-
1><B>SHELL GRAMMAR
</B>
13723 Refer to the description of the
<B>extdebug
</B> option to the
13724 <B>shopt
</B> builtin for details of its effect on the
<B>DEBUG
</B> trap.
13729 <FONT SIZE=-
1><B>RETURN
</B>,
13735 is executed each time a shell function or a script executed with
13736 the
<B>.
</B> or
<B>source
</B> builtins finishes executing.
13744 <FONT SIZE=-
1><B>ERR
</B>,
13750 is executed whenever
13751 a pipeline (which may consist of a single simple
13752 command), a list, or a compound command returns a
13753 non-zero exit status,
13754 subject to the following conditions.
13756 <FONT SIZE=-
1><B>ERR
</B>
13759 trap is not executed if the failed
13760 command is part of the command list immediately following a
13767 part of the test in an
13770 statement, part of a command executed in a
13776 list except the command following the final
<B>&&</B> or
<B>||
</B>,
13777 any command in a pipeline but the last,
13778 or if the command's return value is
13779 being inverted using
13782 These are the same conditions obeyed by the
<B>errexit
</B> (
<B>-e
</B>) option.
13786 Signals ignored upon entry to the shell cannot be trapped or reset.
13787 Trapped signals that are not being ignored are reset to their original
13788 values in a subshell or subshell environment when one is created.
13789 The return status is false if any
13792 is invalid; otherwise
13796 <DT><B>type
</B> [
<B>-aftpP
</B>]
<I>name
</I> [
<I>name
</I> ...]
<DD>
13801 would be interpreted if used as a command name.
13808 prints a string which is one of
13823 is an alias, shell reserved word, function, builtin, or disk file,
13828 is not found, then nothing is printed, and an exit status of false
13836 either returns the name of the disk file
13837 that would be executed if
13840 were specified as a command name,
13842 <TT>type -t name
</TT>
13851 <FONT SIZE=-
1><B>PATH
</B>
13854 search for each
<I>name
</I>, even if
13855 <TT>type -t name
</TT>
13860 If a command is hashed,
13866 print the hashed value, which is not necessarily the file that appears
13868 <FONT SIZE=-
1><B>PATH
</B>.
13877 prints all of the places that contain
13878 an executable named
13881 This includes aliases and functions,
13885 option is not also used.
13886 The table of hashed commands is not consulted
13893 option suppresses shell function lookup, as with the
<B>command
</B> builtin.
13896 returns true if all of the arguments are found, false if
13898 <DT><B>ulimit
</B> [
<B>-HS
</B>]
<B>-a
</B><DD>
13900 <DT><B>ulimit
</B> [
<B>-HS
</B>] [
<B>-bcdefiklmnpqrstuvxPRT
</B> [
<I>limit
</I>]]
<DD>
13902 Provides control over the resources available to the shell and to
13903 processes started by it, on systems that allow such control.
13904 The
<B>-H
</B> and
<B>-S
</B> options specify that the hard or soft limit is
13905 set for the given resource.
13906 A hard limit cannot be increased by a non-root user once it is set;
13907 a soft limit may be increased up to the value of the hard limit.
13908 If neither
<B>-H
</B> nor
<B>-S
</B> is specified, both the soft and hard
13913 can be a number in the unit specified for the resource
13914 or one of the special values
13922 which stand for the current hard limit, the current soft limit, and
13923 no limit, respectively.
13927 is omitted, the current value of the soft limit of the resource is
13928 printed, unless the
<B>-H
</B> option is given. When more than one
13929 resource is specified, the limit name and unit, if appropriate,
13930 are printed before the value.
13931 Other options are interpreted as follows:
13932 <DL COMPACT
><DT><DD>
13938 All current limits are reported; no limits are set
13942 The maximum socket buffer size
13946 The maximum size of core files created
13950 The maximum size of a process's data segment
13954 The maximum scheduling priority (
"nice
")
13958 The maximum size of files written by the shell and its children
13962 The maximum number of pending signals
13966 The maximum number of kqueues that may be allocated
13970 The maximum size that may be locked into memory
13974 The maximum resident set size (many systems do not honor this limit)
13978 The maximum number of open file descriptors (most systems do not
13979 allow this value to be set)
13983 The pipe size in
512-byte blocks (this may not be set)
13987 The maximum number of bytes in POSIX message queues
13991 The maximum real-time scheduling priority
13995 The maximum stack size
13999 The maximum amount of cpu time in seconds
14003 The maximum number of processes available to a single user
14007 The maximum amount of virtual memory available to the shell and, on
14008 some systems, to its children
14012 The maximum number of file locks
14016 The maximum number of pseudoterminals
14020 The maximum time a real-time process can run before blocking, in microseconds
14024 The maximum number of threads
14035 option is not used,
14036 <I>limit
</I> is the new value of the specified resource.
14037 If no option is given, then
14040 is assumed. Values are in
1024-byte increments, except for
14043 which is in seconds;
14046 which is in microseconds;
14049 which is in units of
512-byte blocks;
14063 which are unscaled values;
14064 and, when in posix mode,
14070 which are in
512-byte increments.
14071 The return status is
0 unless an invalid option or argument is supplied,
14072 or an error occurs while setting a new limit.
14075 <DT><B>umask
</B> [
<B>-p
</B>] [
<B>-S
</B>] [
<I>mode
</I>]
<DD>
14076 The user file-creation mask is set to
14082 begins with a digit, it
14083 is interpreted as an octal number; otherwise
14084 it is interpreted as a symbolic mode mask similar
14085 to that accepted by
14091 is omitted, the current value of the mask is printed.
14095 option causes the mask to be printed in symbolic form; the
14096 default output is an octal number.
14100 option is supplied, and
14103 is omitted, the output is in a form that may be reused as input.
14104 The return status is
0 if the mode was successfully changed or if
14105 no
<I>mode
</I> argument was supplied, and false otherwise.
14106 <DT><B>unalias
</B> [-
<B>a
</B>] [
<I>name
</I> ...]
<DD>
14107 Remove each
<I>name
</I> from the list of defined aliases. If
14110 is supplied, all alias definitions are removed. The return
14111 value is true unless a supplied
14114 is not a defined alias.
14115 <DT><B>unset
</B> [-
<B>fv
</B>] [-
<B>n
</B>] [
<I>name
</I> ...]
<DD>
14119 remove the corresponding variable or function.
14123 option is given, each
14126 refers to a shell variable, and that variable is removed.
14127 Read-only variables may not be unset.
14134 refers to a shell function, and the function definition
14139 option is supplied, and
<I>name
</I> is a variable with the
<I>nameref
</I>
14140 attribute,
<I>name
</I> will be unset rather than the variable it
14142 <B>-n
</B> has no effect if the
<B>-f
</B> option is supplied.
14143 If no options are supplied, each
<I>name
</I> refers to a variable; if
14144 there is no variable by that name, a function with that name, if any, is
14146 Each unset variable or function is removed from the environment
14147 passed to subsequent commands.
14149 <FONT SIZE=-
1><B>BASH_ALIASES
</B>,
14152 <FONT SIZE=-
1><B>BASH_ARGV0
</B>,
14155 <FONT SIZE=-
1><B>BASH_CMDS
</B>,
14158 <FONT SIZE=-
1><B>BASH_COMMAND
</B>,
14161 <FONT SIZE=-
1><B>BASH_SUBSHELL
</B>,
14164 <FONT SIZE=-
1><B>BASHPID
</B>,
14167 <FONT SIZE=-
1><B>COMP_WORDBREAKS
</B>,
14170 <FONT SIZE=-
1><B>DIRSTACK
</B>,
14173 <FONT SIZE=-
1><B>EPOCHREALTIME
</B>,
14176 <FONT SIZE=-
1><B>EPOCHSECONDS
</B>,
14179 <FONT SIZE=-
1><B>FUNCNAME
</B>,
14182 <FONT SIZE=-
1><B>GROUPS
</B>,
14185 <FONT SIZE=-
1><B>HISTCMD
</B>,
14188 <FONT SIZE=-
1><B>LINENO
</B>,
14191 <FONT SIZE=-
1><B>RANDOM
</B>,
14194 <FONT SIZE=-
1><B>SECONDS
</B>,
14198 <FONT SIZE=-
1><B>SRANDOM
</B>
14201 are unset, they lose their special properties, even if they are
14202 subsequently reset. The exit status is true unless a
14205 is readonly or may not be unset.
14206 <DT><B>wait
</B> [
<B>-fn
</B>] [-p
<I>varname
</I>] [
<I>id ...
</I>]
<DD>
14207 Wait for each specified child process and return its termination status.
14212 ID or a job specification; if a job spec is given, all processes
14213 in that job's pipeline are waited for. If
14217 <B>wait
</B> waits for all running background jobs and
14218 the last-executed process substitution, if its process id is the same as
14220 and the return status is zero.
14221 If the
<B>-n
</B> option is supplied,
14222 <B>wait
</B> waits for a single job
14223 from the list of
<I>id
</I>s or, if no
<I>id
</I>s are supplied, any job,
14224 to complete and returns its exit status.
14225 If none of the supplied arguments is a child of the shell, or if no arguments
14226 are supplied and the shell has no unwaited-for children, the exit status
14228 If the
<B>-p
</B> option is supplied, the process or job identifier of the job
14229 for which the exit status is returned is assigned to the variable
14230 <I>varname
</I> named by the option argument.
14231 The variable will be unset initially, before any assignment.
14232 This is useful only when the
<B>-n
</B> option is supplied.
14233 Supplying the
<B>-f
</B> option, when job control is enabled,
14234 forces
<B>wait
</B> to wait for
<I>id
</I> to terminate before returning
14235 its status, instead of returning when it changes status.
14239 specifies a non-existent process or job, the return status is
127.
14240 If
<B>wait
</B> is interrupted by a signal, the return status will be greater
14241 than
128, as described under
14246 Otherwise, the return status is the exit status of the last
14247 process or job waited for.
14249 <A NAME=
"lbDC"> </A>
14250 <H3>SHELL COMPATIBILITY MODE
</H3>
14252 Bash-
4.0 introduced the concept of a
<I>shell compatibility level
</I>,
14253 specified as a set of options to the shopt builtin (
14263 There is only one current
14264 compatibility level -- each option is mutually exclusive.
14265 The compatibility level is intended to allow users to select behavior
14266 from previous versions that is incompatible with newer versions
14267 while they migrate scripts to use current features and
14268 behavior. It's intended to be a temporary solution.
14271 This section does not mention behavior that is standard for a particular
14272 version (e.g., setting
<B>compat32
</B> means that quoting the rhs of the regexp
14273 matching operator quotes special regexp characters in the word, which is
14274 default behavior in bash-
3.2 and subsequent versions).
14277 If a user enables, say,
<B>compat32
</B>, it may affect the behavior of other
14278 compatibility levels up to and including the current compatibility level.
14279 The idea is that each compatibility level controls behavior that changed
14280 in that version of
<B>bash
</B>,
14281 but that behavior may have been present in earlier versions.
14282 For instance, the change to use locale-based comparisons with the
<B>[[
</B>
14283 command came in bash-
4.1, and earlier versions used ASCII-based comparisons,
14284 so enabling
<B>compat32
</B> will enable ASCII-based comparisons as well.
14285 That granularity may not be sufficient for
14286 all uses, and as a result users should employ compatibility levels carefully.
14287 Read the documentation for a particular feature to find out the
14291 Bash-
4.3 introduced a new shell variable:
14292 <FONT SIZE=-
1><B>BASH_COMPAT
</B>.
14296 to this variable (a decimal version number like
4.2, or an integer
14297 corresponding to the
<B>compat
</B><I>NN
</I> option, like
42) determines the
14298 compatibility level.
14301 Starting with bash-
4.4, Bash has begun deprecating older compatibility
14303 Eventually, the options will be removed in favor of
14304 <FONT SIZE=-
1><B>BASH_COMPAT
</B>.
14309 Bash-
5.0 is the final version for which there will be an individual shopt
14310 option for the previous version. Users should use
14311 <FONT SIZE=-
1><B>BASH_COMPAT
</B>
14314 on bash-
5.0 and later versions.
14317 The following table describes the behavior changes controlled by each
14318 compatibility level setting.
14319 The
<B>compat
</B><I>NN
</I> tag is used as shorthand for setting the
14320 compatibility level
14321 to
<I>NN
</I> using one of the following mechanisms.
14322 For versions prior to bash-
5.0, the compatibility level may be set using
14323 the corresponding
<B>compat
</B><I>NN
</I> shopt option.
14324 For bash-
4.3 and later versions, the
14325 <FONT SIZE=-
1><B>BASH_COMPAT
</B>
14328 variable is preferred,
14329 and it is required for bash-
5.1 and later versions.
14331 <DT><B>compat31
</B><DD>
14333 <DL COMPACT
><DT><DD>
14336 quoting the rhs of the
<B>[[
</B> command's regexp matching operator (=~)
14337 has no special effect
14341 <DT><B>compat32
</B><DD>
14343 <DL COMPACT
><DT><DD>
14346 interrupting a command list such as
"a ; b ; c
" causes the execution
14347 of the next command in the list (in bash-
4.0 and later versions,
14348 the shell acts as if it received the interrupt, so
14349 interrupting one command in a list aborts the execution of the
14354 <DT><B>compat40
</B><DD>
14356 <DL COMPACT
><DT><DD>
14359 the
<B><</B> and
<B>></B> operators to the
<B>[[
</B> command do not
14360 consider the current locale when comparing strings; they use ASCII
14362 Bash versions prior to bash-
4.1 use ASCII collation and
14365 bash-
4.1 and later use the current locale's collation sequence and
14371 <DT><B>compat41
</B><DD>
14373 <DL COMPACT
><DT><DD>
14376 in
<I>posix
</I> mode,
<B>time
</B> may be followed by options and still be
14377 recognized as a reserved word (this is POSIX interpretation
267)
14379 in
<I>posix
</I> mode, the parser requires that an even number of single
14380 quotes occur in the
<I>word
</I> portion of a double-quoted
14381 parameter expansion and treats them specially, so that characters within
14382 the single quotes are considered quoted
14383 (this is POSIX interpretation
221)
14387 <DT><B>compat42
</B><DD>
14389 <DL COMPACT
><DT><DD>
14392 the replacement string in double-quoted pattern substitution does not
14393 undergo quote removal, as it does in versions after bash-
4.2
14395 in posix mode, single quotes are considered special when expanding
14396 the
<I>word
</I> portion of a double-quoted parameter expansion
14397 and can be used to quote a closing brace or other special character
14398 (this is part of POSIX interpretation
221);
14399 in later versions, single quotes
14400 are not special within double-quoted word expansions
14404 <DT><B>compat43
</B><DD>
14406 <DL COMPACT
><DT><DD>
14409 the shell does not print a warning message if an attempt is made to
14410 use a quoted compound assignment as an argument to declare
14411 (e.g., declare -a foo=aq(
1 2)aq). Later versions warn that this usage is
14414 word expansion errors are considered non-fatal errors that cause the
14415 current command to fail, even in posix mode
14416 (the default behavior is to make them fatal errors that cause the shell
14419 when executing a shell function, the loop state (while/until/etc.)
14420 is not reset, so
<B>break
</B> or
<B>continue
</B> in that function will break
14421 or continue loops in the calling context. Bash-
4.4 and later reset
14422 the loop state to prevent this
14426 <DT><B>compat44
</B><DD>
14428 <DL COMPACT
><DT><DD>
14431 the shell sets up the values used by
14432 <FONT SIZE=-
1><B>BASH_ARGV
</B>
14436 <FONT SIZE=-
1><B>BASH_ARGC
</B>
14439 so they can expand to the shell's positional parameters even if extended
14440 debugging mode is not enabled
14442 a subshell inherits loops from its parent context, so
<B>break
</B>
14443 or
<B>continue
</B> will cause the subshell to exit.
14444 Bash-
5.0 and later reset the loop state to prevent the exit
14446 variable assignments preceding builtins like
<B>export
</B> and
<B>readonly
</B>
14447 that set attributes continue to affect variables with the same
14448 name in the calling environment even if the shell is not in posix
14453 <DT><B>compat50
</B><DD>
14455 <DL COMPACT
><DT><DD>
14458 Bash-
5.1 changed the way
14459 <FONT SIZE=-
1><B>$RANDOM
</B>
14462 is generated to introduce slightly
14463 more randomness. If the shell compatibility level is set to
50 or
14464 lower, it reverts to the method from bash-
5.0 and previous versions,
14465 so seeding the random number generator by assigning a value to
14466 <FONT SIZE=-
1><B>RANDOM
</B>
14469 will produce the same sequence as in bash-
5.0
14471 If the command hash table is empty, bash versions prior to bash-
5.1
14472 printed an informational message to that effect, even when producing
14473 output that can be reused as input. Bash-
5.1 suppresses that message
14474 when the
<B>-l
</B> option is supplied.
14478 <DT><B>compat51
</B><DD>
14480 <DL COMPACT
><DT><DD>
14483 The
<B>unset
</B> builtin treats attempts to unset array subscripts
<B>@
</B>
14484 and
<B>*
</B> differently depending on whether the array is indexed or
14485 associative, and differently than in previous versions.
14492 <A NAME=
"lbDD"> </A>
14493 <H3>RESTRICTED SHELL
</H3>
14502 is started with the name
14508 option is supplied at invocation,
14509 the shell becomes restricted.
14510 A restricted shell is used to
14511 set up an environment more controlled than the standard shell.
14512 It behaves identically to
14515 with the exception that the following are disallowed or not performed:
14518 changing directories with
<B>cd
</B>
14520 setting or unsetting the values of
14521 <FONT SIZE=-
1><B>SHELL
</B>,
14524 <FONT SIZE=-
1><B>PATH
</B>,
14527 <FONT SIZE=-
1><B>HISTFILE
</B>,
14530 <FONT SIZE=-
1><B>ENV
</B>,
14534 <FONT SIZE=-
1><B>BASH_ENV
</B>
14538 specifying command names containing
14542 specifying a filename containing a
14545 as an argument to the
14550 specifying a filename containing a slash as an argument to the
14555 specifying a filename containing a slash as an argument to the
14563 importing function definitions from the shell environment at startup
14565 parsing the value of
14566 <FONT SIZE=-
1><B>SHELLOPTS
</B>
14569 from the shell environment at startup
14571 redirecting output using the
>,
>|,
<>,
>&,
&>, and
>> redirection operators
14576 builtin command to replace the shell with another command
14578 adding or deleting builtin commands with the
14589 using the
<B>enable
</B> builtin command to enable disabled shell builtins
14599 turning off restricted mode with
14600 <B>set +r
</B> or
<B>shopt -u restricted_shell
</B>.
14604 These restrictions are enforced after any startup files are read.
14608 When a command that is found to be a shell script is executed
14610 <FONT SIZE=-
1><B>COMMAND EXECUTION
</B>
14618 turns off any restrictions in the shell spawned to execute the
14622 <A NAME=
"lbDE"> </A>
14627 <DT><I>Bash Reference Manual
</I>, Brian Fox and Chet Ramey
<DD>
14628 <DT><I>The Gnu Readline Library
</I>, Brian Fox and Chet Ramey
<DD>
14629 <DT><I>The Gnu History Library
</I>, Brian Fox and Chet Ramey
<DD>
14630 <DT><I>Portable Operating System Interface (POSIX) Part
2: Shell and Utilities
</I>, IEEE --
<DD>
14631 <A HREF=
"http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/
9699919799/
</A>
14632 <DT><A HREF=
"http://tiswww.case.edu/~chet/bash/POSIX">http://tiswww.case.edu/~chet/bash/POSIX
</A> -- a description of posix mode
<DD>
14633 <DT><I>sh
</I>(
1),
<I>ksh
</I>(
1),
<I>csh
</I>(
1)
<DD>
14634 <DT><I>emacs
</I>(
1),
<I>vi
</I>(
1)
<DD>
14635 <DT><I>readline
</I>(
3)
<DD>
14638 <A NAME=
"lbDF"> </A>
14644 <A HREF=
"file:/bin/bash"><I>/bin/bash
</I></A>
14647 The
<B>bash
</B> executable
14649 <A HREF=
"file:/etc/profile"><I>/etc/profile
</I></A>
14652 The systemwide initialization file, executed for login shells
14654 <A HREF=
"file:~/.bash_profile"><I>~/.bash_profile
</I></A>
14657 The personal initialization file, executed for login shells
14659 <A HREF=
"file:~/.bashrc"><I>~/.bashrc
</I></A>
14662 The individual per-interactive-shell startup file
14664 <A HREF=
"file:~/.bash_logout"><I>~/.bash_logout
</I></A>
14667 The individual login shell cleanup file, executed when a login shell exits
14669 <A HREF=
"file:~/.bash_history"><I>~/.bash_history
</I></A>
14672 The default value of
<B>HISTFILE
</B>, the file in which bash saves the
14675 <A HREF=
"file:~/.inputrc"><I>~/.inputrc
</I></A>
14678 Individual
<I>readline
</I> initialization file
14681 <A NAME=
"lbDG"> </A>
14684 Brian Fox, Free Software Foundation
14687 <A HREF=
"mailto:bfox@gnu.org">bfox@gnu.org
</A>
14690 Chet Ramey, Case Western Reserve University
14693 <A HREF=
"mailto:chet.ramey@case.edu">chet.ramey@case.edu
</A>
14694 <A NAME=
"lbDH"> </A>
14695 <H3>BUG REPORTS
</H3>
14697 If you find a bug in
14700 you should report it. But first, you should
14701 make sure that it really is a bug, and that it appears in the latest
14705 The latest version is always available from
14706 <I><A HREF=
"ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/
</A></I> and
14707 <I><A HREF=
"http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz">http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz
</A></I>.
14710 Once you have determined that a bug actually exists, use the
14713 command to submit a bug report.
14714 If you have a fix, you are encouraged to mail that as well!
14715 Suggestions and `philosophical' bug reports may be mailed
14716 to
<I><A HREF=
"mailto:bug-bash@gnu.org">bug-bash@gnu.org
</A></I> or posted to the Usenet
14718 <A HREF=
"news:gnu.bash.bug">gnu.bash.bug
</A>.
14722 ALL bug reports should include:
14727 <DT>The version number of
<B>bash
</B><DD>
14728 <DT>The hardware and operating system
<DD>
14729 <DT>The compiler used to compile
<DD>
14730 <DT>A description of the bug behaviour
<DD>
14731 <DT>A short script or `recipe' which exercises the bug
<DD>
14738 inserts the first three items automatically into the template
14739 it provides for filing a bug report.
14742 Comments and bug reports concerning
14743 this manual page should be directed to
14744 <I><A HREF=
"mailto:chet.ramey@case.edu">chet.ramey@case.edu
</A></I>.
14746 <A NAME=
"lbDI"> </A>
14749 It's too big and too slow.
14752 There are some subtle differences between
14755 and traditional versions of
14758 mostly because of the
14759 <FONT SIZE=-
1><B>POSIX
</B>
14765 Aliases are confusing in some uses.
14768 Shell builtin commands and functions are not stoppable/restartable.
14771 Compound commands and command sequences of the form `a ; b ; c'
14772 are not handled gracefully when process suspension is attempted.
14773 When a process is stopped, the shell immediately executes the next
14774 command in the sequence.
14775 It suffices to place the sequence of commands between
14776 parentheses to force it into a subshell, which may be stopped as
14780 Array variables may not (yet) be exported.
14783 There may be only one active coprocess at a time.
14790 <TH ALIGN=LEFT width=
33%
>GNU Bash
5.2<TH ALIGN=CENTER width=
33%
>2022 September
19<TH ALIGN=RIGHT width=
33%
>BASH(
1)
14794 <A NAME=
"index"> </A><H2>Index
</H2>
14796 <DT><A HREF=
"#lbAB">NAME
</A><DD>
14797 <DT><A HREF=
"#lbAC">SYNOPSIS
</A><DD>
14798 <DT><A HREF=
"#lbAD">COPYRIGHT
</A><DD>
14799 <DT><A HREF=
"#lbAE">DESCRIPTION
</A><DD>
14800 <DT><A HREF=
"#lbAF">OPTIONS
</A><DD>
14801 <DT><A HREF=
"#lbAG">ARGUMENTS
</A><DD>
14802 <DT><A HREF=
"#lbAH">INVOCATION
</A><DD>
14803 <DT><A HREF=
"#lbAI">DEFINITIONS
</A><DD>
14804 <DT><A HREF=
"#lbAJ">RESERVED WORDS
</A><DD>
14805 <DT><A HREF=
"#lbAK">SHELL GRAMMAR
</A><DD>
14807 <DT><A HREF=
"#lbAL">Simple Commands
</A><DD>
14808 <DT><A HREF=
"#lbAM">Pipelines
</A><DD>
14809 <DT><A HREF=
"#lbAN">Lists
</A><DD>
14810 <DT><A HREF=
"#lbAO">Compound Commands
</A><DD>
14811 <DT><A HREF=
"#lbAP">Coprocesses
</A><DD>
14812 <DT><A HREF=
"#lbAQ">Shell Function Definitions
</A><DD>
14814 <DT><A HREF=
"#lbAR">COMMENTS
</A><DD>
14815 <DT><A HREF=
"#lbAS">QUOTING
</A><DD>
14816 <DT><A HREF=
"#lbAT">PARAMETERS
</A><DD>
14818 <DT><A HREF=
"#lbAU">Positional Parameters
</A><DD>
14819 <DT><A HREF=
"#lbAV">Special Parameters
</A><DD>
14820 <DT><A HREF=
"#lbAW">Shell Variables
</A><DD>
14821 <DT><A HREF=
"#lbAX">Arrays
</A><DD>
14823 <DT><A HREF=
"#lbAY">EXPANSION
</A><DD>
14825 <DT><A HREF=
"#lbAZ">Brace Expansion
</A><DD>
14826 <DT><A HREF=
"#lbBA">Tilde Expansion
</A><DD>
14827 <DT><A HREF=
"#lbBB">Parameter Expansion
</A><DD>
14828 <DT><A HREF=
"#lbBC">Command Substitution
</A><DD>
14829 <DT><A HREF=
"#lbBD">Arithmetic Expansion
</A><DD>
14830 <DT><A HREF=
"#lbBE">Process Substitution
</A><DD>
14831 <DT><A HREF=
"#lbBF">Word Splitting
</A><DD>
14832 <DT><A HREF=
"#lbBG">Pathname Expansion
</A><DD>
14833 <DT><A HREF=
"#lbBH">Quote Removal
</A><DD>
14835 <DT><A HREF=
"#lbBI">REDIRECTION
</A><DD>
14837 <DT><A HREF=
"#lbBJ">Redirecting Input
</A><DD>
14838 <DT><A HREF=
"#lbBK">Redirecting Output
</A><DD>
14839 <DT><A HREF=
"#lbBL">Appending Redirected Output
</A><DD>
14840 <DT><A HREF=
"#lbBM">Redirecting Standard Output and Standard Error
</A><DD>
14841 <DT><A HREF=
"#lbBN">Appending Standard Output and Standard Error
</A><DD>
14842 <DT><A HREF=
"#lbBO">Here Documents
</A><DD>
14843 <DT><A HREF=
"#lbBP">Here Strings
</A><DD>
14844 <DT><A HREF=
"#lbBQ">Duplicating File Descriptors
</A><DD>
14845 <DT><A HREF=
"#lbBR">Moving File Descriptors
</A><DD>
14846 <DT><A HREF=
"#lbBS">Opening File Descriptors for Reading and Writing
</A><DD>
14848 <DT><A HREF=
"#lbBT">ALIASES
</A><DD>
14849 <DT><A HREF=
"#lbBU">FUNCTIONS
</A><DD>
14850 <DT><A HREF=
"#lbBV">ARITHMETIC EVALUATION
</A><DD>
14851 <DT><A HREF=
"#lbBW">CONDITIONAL EXPRESSIONS
</A><DD>
14852 <DT><A HREF=
"#lbBX">SIMPLE COMMAND EXPANSION
</A><DD>
14853 <DT><A HREF=
"#lbBY">COMMAND EXECUTION
</A><DD>
14854 <DT><A HREF=
"#lbBZ">COMMAND EXECUTION ENVIRONMENT
</A><DD>
14855 <DT><A HREF=
"#lbCA">ENVIRONMENT
</A><DD>
14856 <DT><A HREF=
"#lbCB">EXIT STATUS
</A><DD>
14857 <DT><A HREF=
"#lbCC">SIGNALS
</A><DD>
14858 <DT><A HREF=
"#lbCD">JOB CONTROL
</A><DD>
14859 <DT><A HREF=
"#lbCE">PROMPTING
</A><DD>
14860 <DT><A HREF=
"#lbCF">READLINE
</A><DD>
14862 <DT><A HREF=
"#lbCG">Readline Notation
</A><DD>
14863 <DT><A HREF=
"#lbCH">Readline Initialization
</A><DD>
14864 <DT><A HREF=
"#lbCI">Readline Key Bindings
</A><DD>
14865 <DT><A HREF=
"#lbCJ">Readline Variables
</A><DD>
14866 <DT><A HREF=
"#lbCK">Readline Conditional Constructs
</A><DD>
14867 <DT><A HREF=
"#lbCL">Searching
</A><DD>
14868 <DT><A HREF=
"#lbCM">Readline Command Names
</A><DD>
14869 <DT><A HREF=
"#lbCN">Commands for Moving
</A><DD>
14870 <DT><A HREF=
"#lbCO">Commands for Manipulating the History
</A><DD>
14871 <DT><A HREF=
"#lbCP">Commands for Changing Text
</A><DD>
14872 <DT><A HREF=
"#lbCQ">Killing and Yanking
</A><DD>
14873 <DT><A HREF=
"#lbCR">Numeric Arguments
</A><DD>
14874 <DT><A HREF=
"#lbCS">Completing
</A><DD>
14875 <DT><A HREF=
"#lbCT">Keyboard Macros
</A><DD>
14876 <DT><A HREF=
"#lbCU">Miscellaneous
</A><DD>
14877 <DT><A HREF=
"#lbCV">Programmable Completion
</A><DD>
14879 <DT><A HREF=
"#lbCW">HISTORY
</A><DD>
14880 <DT><A HREF=
"#lbCX">HISTORY EXPANSION
</A><DD>
14882 <DT><A HREF=
"#lbCY">Event Designators
</A><DD>
14883 <DT><A HREF=
"#lbCZ">Word Designators
</A><DD>
14884 <DT><A HREF=
"#lbDA">Modifiers
</A><DD>
14886 <DT><A HREF=
"#lbDB">SHELL BUILTIN COMMANDS
</A><DD>
14887 <DT><A HREF=
"#lbDC">SHELL COMPATIBILITY MODE
</A><DD>
14888 <DT><A HREF=
"#lbDD">RESTRICTED SHELL
</A><DD>
14889 <DT><A HREF=
"#lbDE">SEE ALSO
</A><DD>
14890 <DT><A HREF=
"#lbDF">FILES
</A><DD>
14891 <DT><A HREF=
"#lbDG">AUTHORS
</A><DD>
14892 <DT><A HREF=
"#lbDH">BUG REPORTS
</A><DD>
14893 <DT><A HREF=
"#lbDI">BUGS
</A><DD>
14896 This document was created by man2html from /usr/local/src/bash/bash-
20220907/doc/bash
.1.
<BR>
14897 Time:
19 September
2022 12:
02:
51 EDT