2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
9 .\" Last Change: Tue Nov 13 12:55:51 EST 2001
11 .\" bash_builtins, strip all but Built-Ins section
14 .TH BASH 1 "2001 November 13" "GNU Bash-2.05a"
16 .\" There's some problem with having a `@'
17 .\" in a tagged paragraph with the BSD man macros.
18 .\" It has to do with `@' appearing in the }1 macro.
19 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
20 .\" appears to have fixed it.
21 .\" If you're seeing the characters
22 .\" `@u-3p' appearing before the lines reading
23 .\" `possible-hostname-completions
24 .\" and `complete-hostname' down in READLINE,
25 .\" then uncomment this redefinition.
30 .if !"\\$1"" .nr )I \\$1n
33 .in \\n()Ru+\\n(INu+\\n()Iu
35 .ie !\\n()Iu+\\n()Ru-\w
\a\\*(]X
\au-3p \{\\*(]X
37 .el \\*(]X\h
\a|\\n()Iu+\\n()Ru
\a\c
41 .\" File Name macro. This used to be `.PN', for Path Name,
42 .\" but Sun doesn't seem to like that very much.
48 bash \- GNU Bourne-Again SHell
54 .if n Bash is Copyright (C) 1989-2001 by the Free Software Foundation, Inc.
55 .if t Bash is Copyright \(co 1989-2001 by the Free Software Foundation, Inc.
58 is an \fBsh\fR-compatible command language interpreter that
59 executes commands read from the standard input or from a file.
61 also incorporates useful features from the \fIKorn\fP and \fIC\fP
62 shells (\fBksh\fP and \fBcsh\fP).
65 is intended to be a conformant implementation of the IEEE
66 POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
68 In addition to the single-character shell options documented in the
69 description of the \fBset\fR builtin command, \fBbash\fR
70 interprets the following options when it is invoked:
77 option is present, then commands are read from
79 If there are arguments after the
81 they are assigned to the positional parameters, starting with
87 option is present, the shell becomes
97 option is present, the shell is
103 option is present, or if no arguments remain after option
104 processing, then commands are read from the standard input.
105 This option allows the positional parameters to be set
106 when invoking an interactive shell.
109 A list of all double-quoted strings preceded by \fB$\fP
110 is printed on the standard ouput.
111 These are the strings that
112 are subject to language translation when the current locale
113 is not \fBC\fP or \fBPOSIX\fP.
114 This implies the \fB\-n\fP option; no commands will be executed.
116 .B [\-+]O [\fIshopt_option\fP]
117 \fIshopt_option\fP is one of the shell options accepted by the
118 \fBshopt\fP builtin (see
120 .B SHELL BUILTIN COMMANDS
122 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
124 If \fIshopt_option\fP is not supplied, the names and values of the shell
125 options accepted by \fBshopt\fP are printed on the standard output.
126 If the invocation option is \fB+O\fP, the output is displayed in a format
127 that may be reused as input.
132 signals the end of options and disables further option processing.
133 Any arguments after the
135 are treated as filenames and arguments. An argument of
137 is equivalent to \fB\-\-\fP.
141 also interprets a number of multi-character options.
142 These options must appear on the command line before the
143 single-character options in order for them to be recognized.
147 .B \-\-dump\-po\-strings
148 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
149 \fBpo\fP (portable object) file format.
152 Equivalent to \fB\-D\fP.
155 Display a usage message on standard output and exit successfully.
158 \fB\-\-init\-file\fP \fIfile\fP
160 \fB\-\-rcfile\fP \fIfile\fP
162 Execute commands from
164 instead of the standard personal initialization file
166 if the shell is interactive (see
174 act as if it had been invoked as a login shell (see
182 library to read command lines when the shell is interactive.
185 Do not read either the system-wide startup file
187 or any of the personal initialization files
188 .IR ~/.bash_profile ,
194 reads these files when it is invoked as a login shell (see
200 Do not read and execute the personal initialization file
202 if the shell is interactive.
203 This option is on by default if the shell is invoked as
207 Change the behavior of \fBbash\fP where the default operation differs
208 from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
211 The shell becomes restricted (see
213 .B "RESTRICTED SHELL"
217 Equivalent to \fB\-v\fP.
220 Show version information for this instance of
222 on the standard output and exit successfully.
225 If arguments remain after option processing, and neither the
229 option has been supplied, the first argument is assumed to
230 be the name of a file containing shell commands.
233 is invoked in this fashion,
235 is set to the name of the file, and the positional parameters
236 are set to the remaining arguments.
238 reads and executes commands from this file, then exits.
239 \fBBash\fP's exit status is the exit status of the last command
240 executed in the script.
241 If no commands are executed, the exit status is 0.
242 An attempt is first made to open the file in the current directory, and,
243 if no file is found, then the shell searches the directories in
248 A \fIlogin shell\fP is one whose first character of argument zero is a
250 or one started with the
254 An \fIinteractive\fP shell is one started without non-option arguments
258 whose standard input and output are
259 both connected to terminals (as determined by
261 or one started with the
273 allowing a shell script or a startup file to test this state.
275 The following paragraphs describe how
277 executes its startup files.
278 If any of the files exist but cannot be read,
281 Tildes are expanded in file names as described below under
290 is invoked as an interactive login shell, or as a non-interactive shell
291 with the \fB\-\-login\fP option, it first reads and
292 executes commands from the file \fI/etc/profile\fP, if that
294 After reading that file, it looks for \fI~/.bash_profile\fP,
295 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
296 and executes commands from the first one that exists and is readable.
299 option may be used when the shell is started to inhibit this behavior.
301 When a login shell exits,
303 reads and executes commands from the file \fI~/.bash_logout\fP, if it
306 When an interactive shell that is not a login shell is started,
308 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
309 This may be inhibited by using the
312 The \fB\-\-rcfile\fP \fIfile\fP option will force
314 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
318 is started non-interactively, to run a shell script, for example, it
319 looks for the variable
322 in the environment, expands its value if it appears there, and uses the
323 expanded value as the name of a file to read and execute.
325 behaves as if the following command were executed:
328 .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
329 .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
335 variable is not used to search for the file name.
339 is invoked with the name
341 it tries to mimic the startup behavior of historical versions of
343 as closely as possible,
344 while conforming to the POSIX standard as well.
345 When invoked as an interactive login shell, or a non-interactive
346 shell with the \fB\-\-login\fP option, it first attempts to
347 read and execute commands from
354 option may be used to inhibit this behavior.
355 When invoked as an interactive shell with the name
358 looks for the variable
361 expands its value if it is defined, and uses the
362 expanded value as the name of a file to read and execute.
363 Since a shell invoked as
365 does not attempt to read and execute commands from any other startup
368 option has no effect.
369 A non-interactive shell invoked with the name
371 does not attempt to read any other startup files.
377 mode after the startup files are read.
385 command line option, it follows the POSIX standard for startup files.
386 In this mode, interactive shells expand the
389 variable and commands are read and executed from the file
390 whose name is the expanded value.
391 No other startup files are read.
394 attempts to determine when it is being run by the remote shell
395 daemon, usually \fIrshd\fP.
398 determines it is being run by \fIrshd\fP, it reads and executes
399 commands from \fI~/.bashrc\fP, if that file exists and is readable.
400 It will not do this if invoked as \fBsh\fP.
403 option may be used to inhibit this behavior, and the
405 option may be used to force another file to be read, but
406 \fIrshd\fP does not generally invoke the shell with those options
407 or allow them to be specified.
409 If the shell is started with the effective user (group) id not equal to the
410 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
411 files are read, shell functions are not inherited from the environment, the
414 variable, if it appears in the environment, is ignored,
415 and the effective user id is set to the real user id.
416 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
417 the same, but the effective user id is not reset.
420 The following definitions are used throughout the rest of this
428 A sequence of characters considered as a single unit by the shell.
435 consisting only of alphanumeric characters and underscores, and
436 beginning with an alphabetic character or an underscore. Also
441 A character that, when unquoted, separates words. One of the following:
445 .if t \fB| & ; ( ) < > space tab\fP
446 .if n \fB| & ; ( ) < > space tab\fP
451 A \fItoken\fP that performs a control function. It is one of the following
455 .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
456 .if n \fB|| & && ; ;; ( ) | <newline>\fP
460 \fIReserved words\fP are words that have a special meaning to the shell.
461 The following words are recognized as reserved when unquoted and either
462 the first word of a simple command (see
465 below) or the third word of a
473 .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
474 .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
480 A \fIsimple command\fP is a sequence of optional variable assignments
481 followed by \fBblank\fP-separated words and redirections, and
482 terminated by a \fIcontrol operator\fP. The first word
483 specifies the command to be executed, and is passed as argument zero.
484 The remaining words are passed as arguments to the invoked command.
486 The return value of a \fIsimple command\fP is its exit status, or
487 128+\fIn\^\fP if the command is terminated by signal
491 A \fIpipeline\fP is a sequence of one or more commands separated by
494 The format for a pipeline is:
497 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
500 The standard output of
502 is connected via a pipe to the standard input of
504 This connection is performed before any redirections specified by the
512 precedes a pipeline, the exit status of that
513 pipeline is the logical NOT of the exit status of the last command.
514 Otherwise, the status of the pipeline is the exit status of the last
516 The shell waits for all commands in the pipeline to
517 terminate before returning a value.
521 reserved word precedes a pipeline, the elapsed as well as user and
522 system time consumed by its execution are reported when the pipeline
524 The \fB\-p\fP option changes the output format to that specified by POSIX.
528 variable may be set to a format string that specifies how the timing
529 information should be displayed; see the description of
536 Each command in a pipeline is executed as a separate process (i.e., in a
540 A \fIlist\fP is a sequence of one or more pipelines separated by one
547 and optionally terminated by one of
553 Of these list operators,
557 have equal precedence, followed by
561 which have equal precedence.
563 If a command is terminated by the control operator
565 the shell executes the command in the \fIbackground\fP
566 in a subshell. The shell does not wait for the command to
567 finish, and the return status is 0. Commands separated by a
569 are executed sequentially; the shell waits for each
570 command to terminate in turn. The return status is the
571 exit status of the last command executed.
573 The control operators
577 denote AND lists and OR lists, respectively.
578 An AND list has the form
581 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
585 is executed if, and only if,
587 returns an exit status of zero.
589 An OR list has the form
592 \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
597 is executed if and only if
599 returns a non-zero exit status. The return status of
600 AND and OR lists is the exit status of the last command
601 executed in the list.
602 .SS Compound Commands
604 A \fIcompound command\fP is one of the following:
607 \fIlist\fP is executed in a subshell. Variable assignments and builtin
608 commands that affect the shell's environment do not remain in effect
609 after the command completes. The return status is the exit status of
613 \fIlist\fP is simply executed in the current shell environment.
614 \fIlist\fP must be terminated with a newline or semicolon.
615 This is known as a \fIgroup command\fP.
616 The return status is the exit status of
618 Note that unlike the metacharacters \fB(\fP and \fB\)\fP, \fB{\fP and
619 \fB}\fP are \fIreserved words\fP and must occur where a reserved
620 word is permitted to be recognized. Since they do not cause a word
621 break, they must be separated from \fIlist\fP by whitespace.
624 The \fIexpression\fP is evaluated according to the rules described
627 .BR "ARITHMETIC EVALUATION" .
628 If the value of the expression is non-zero, the return status is 0;
629 otherwise the return status is 1. This is exactly equivalent to
630 \fBlet "\fIexpression\fP"\fR.
632 \fB[[\fP \fIexpression\fP \fB]]\fP
633 Return a status of 0 or 1 depending on the evaluation of
634 the conditional expression \fIexpression\fP.
635 Expressions are composed of the primaries described below under
637 .BR "CONDITIONAL EXPRESSIONS" .
638 Word splitting and pathname expansion are not performed on the words
639 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
640 variable expansion, arithmetic expansion, command substitution, process
641 substitution, and quote removal are performed.
644 When the \fB==\fP and \fB!=\fP operators are used, the string to the
645 right of the operator is considered a pattern and matched according
646 to the rules described below under \fBPattern Matching\fP.
647 The return value is 0 if the string matches or does not match
648 the pattern, respectively, and 1 otherwise.
649 Any part of the pattern may be quoted to force it to be matched as a
653 Expressions may be combined using the following operators, listed
654 in decreasing order of precedence:
660 .B ( \fIexpression\fP )
661 Returns the value of \fIexpression\fP.
662 This may be used to override the normal precedence of operators.
664 .B ! \fIexpression\fP
669 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
676 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
677 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
688 operators do not execute \fIexpression2\fP if the value of
689 \fIexpression1\fP is sufficient to determine the return value of
690 the entire conditional expression.
693 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
694 The list of words following \fBin\fP is expanded, generating a list
696 The variable \fIname\fP is set to each element of this list
697 in turn, and \fIlist\fP is executed each time.
698 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
699 \fIlist\fP once for each positional parameter that is set (see
703 The return status is the exit status of the last command that executes.
704 If the expansion of the items following \fBin\fP results in an empty
705 list, no commands are executed, and the return status is 0.
707 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
708 First, the arithmetic expression \fIexpr1\fP is evaluated according
709 to the rules described below under
711 .BR "ARITHMETIC EVALUATION" .
712 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
713 until it evaluates to zero.
714 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
715 executed and the arithmetic expression \fIexpr3\fP is evaluated.
716 If any expression is omitted, it behaves as if it evaluates to 1.
717 The return value is the exit status of the last command in \fIlist\fP
718 that is executed, or false if any of the expressions is invalid.
720 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
721 The list of words following \fBin\fP is expanded, generating a list
722 of items. The set of expanded words is printed on the standard
723 error, each preceded by a number. If the \fBin\fP
724 \fIword\fP is omitted, the positional parameters are printed (see
729 prompt is then displayed and a line read from the standard input.
730 If the line consists of a number corresponding to one of
731 the displayed words, then the value of
733 is set to that word. If the line is empty, the words and prompt
734 are displayed again. If EOF is read, the command completes. Any
735 other value read causes
737 to be set to null. The line read is saved in the variable
741 is executed after each selection until a
746 is the exit status of the last command executed in
748 or zero if no commands were executed.
750 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
751 ... ) \fIlist\fP ;; ] ... \fBesac\fP
752 A \fBcase\fP command first expands \fIword\fP, and tries to match
753 it against each \fIpattern\fP in turn, using the same matching rules
754 as for pathname expansion (see
755 .B Pathname Expansion
756 below). When a match is found, the
757 corresponding \fIlist\fP is executed. After the first match, no
758 subsequent matches are attempted. The exit status is zero if no
759 pattern matches. Otherwise, it is the exit status of the
760 last command executed in \fIlist\fP.
762 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
763 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
764 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
768 is executed. If its exit status is zero, the
769 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
770 \fIlist\fP is executed in turn, and if its exit status is zero,
771 the corresponding \fBthen\fP \fIlist\fP is executed and the
772 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
773 executed, if present. The exit status is the exit status of the
774 last command executed, or zero if no condition tested true.
777 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
779 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
781 The \fBwhile\fP command continuously executes the \fBdo\fP
782 \fIlist\fP as long as the last command in \fIlist\fP returns
783 an exit status of zero. The \fBuntil\fP command is identical
784 to the \fBwhile\fP command, except that the test is negated;
788 is executed as long as the last command in
790 returns a non-zero exit status.
791 The exit status of the \fBwhile\fP and \fBuntil\fP commands
793 of the last \fBdo\fP \fIlist\fP command executed, or zero if
796 [ \fBfunction\fP ] \fIname\fP () { \fIlist\fP; }
797 This defines a function named \fIname\fP. The \fIbody\fP of the
800 of commands between { and }. This list
801 is executed whenever \fIname\fP is specified as the
802 name of a simple command. The exit status of a function is
803 the exit status of the last command executed in the body. (See
808 In a non-interactive shell, or an interactive shell in which the
809 .B interactive_comments
812 builtin is enabled (see
814 .B "SHELL BUILTIN COMMANDS"
815 below), a word beginning with
817 causes that word and all remaining characters on that line to
818 be ignored. An interactive shell without the
819 .B interactive_comments
820 option enabled does not allow comments. The
821 .B interactive_comments
822 option is on by default in interactive shells.
824 \fIQuoting\fP is used to remove the special meaning of certain
825 characters or words to the shell. Quoting can be used to
826 disable special treatment for special characters, to prevent
827 reserved words from being recognized as such, and to prevent
830 Each of the \fImetacharacters\fP listed above under
833 has special meaning to the shell and must be quoted if it is to
836 When the command history expansion facilities are being used, the
837 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
838 to prevent history expansion.
840 There are three quoting mechanisms: the
841 .IR "escape character" ,
842 single quotes, and double quotes.
844 A non-quoted backslash (\fB\e\fP) is the
845 .IR "escape character" .
846 It preserves the literal value of the next character that follows,
847 with the exception of <newline>. If a \fB\e\fP<newline> pair
848 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
849 is treated as a line continuation (that is, it is removed from the
850 input stream and effectively ignored).
852 Enclosing characters in single quotes preserves the literal value
853 of each character within the quotes. A single quote may not occur
854 between single quotes, even when preceded by a backslash.
856 Enclosing characters in double quotes preserves the literal value
857 of all characters within the quotes, with the exception of
866 retain their special meaning within double quotes. The backslash
867 retains its special meaning only when followed by one of the following
875 A double quote may be quoted within double quotes by preceding it with
878 The special parameters
882 have special meaning when in double
888 Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
889 word expands to \fIstring\fP, with backslash-escaped characters replaced
890 as specifed by the ANSI C standard. Backslash escape sequences, if
891 present, are decoded as follows:
926 the eight-bit character whose value is the octal value \fInnn\fP
927 (one to three digits)
930 the eight-bit character whose value is the hexadecimal value \fIHH\fP
931 (one or two hex digits)
935 The expanded result is single-quoted, as if the dollar sign had
938 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
939 the string to be translated according to the current locale.
940 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
942 If the string is translated and replaced, the replacement is
947 is an entity that stores values.
950 a number, or one of the special characters listed below under
951 .BR "Special Parameters" .
952 For the shell's purposes, a
954 is a parameter denoted by a
956 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
957 Attributes are assigned using the
963 .BR "SHELL BUILTIN COMMANDS" ).
965 A parameter is set if it has been assigned a value. The null string is
966 a valid value. Once a variable is set, it may be unset only by using
971 .B SHELL BUILTIN COMMANDS
976 may be assigned to by a statement of the form
979 \fIname\fP=[\fIvalue\fP]
984 is not given, the variable is assigned the null string. All
986 undergo tilde expansion, parameter and variable expansion,
987 command substitution, arithmetic expansion, and quote
991 below). If the variable has its
995 is subject to arithmetic expansion even if the $((...)) expansion is
997 .B "Arithmetic Expansion"
999 Word splitting is not performed, with the exception
1000 of \fB"$@"\fP as explained below under
1001 .BR "Special Parameters" .
1002 Pathname expansion is not performed.
1003 Assignment statements may also appear as arguments to the
1011 .SS Positional Parameters
1014 .I positional parameter
1015 is a parameter denoted by one or more
1016 digits, other than the single digit 0. Positional parameters are
1017 assigned from the shell's arguments when it is invoked,
1018 and may be reassigned using the
1020 builtin command. Positional parameters may not be assigned to
1021 with assignment statements. The positional parameters are
1022 temporarily replaced when a shell function is executed (see
1027 When a positional parameter consisting of more than a single
1028 digit is expanded, it must be enclosed in braces (see
1032 .SS Special Parameters
1034 The shell treats several parameters specially. These parameters may
1035 only be referenced; assignment to them is not allowed.
1039 Expands to the positional parameters, starting from one. When the
1040 expansion occurs within double quotes, it expands to a single word
1041 with the value of each parameter separated by the first character
1045 special variable. That is, "\fB$*\fP" is equivalent
1046 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1048 is the first character of the value of the
1054 is unset, the parameters are separated by spaces.
1058 is null, the parameters are joined without intervening separators.
1061 Expands to the positional parameters, starting from one. When the
1062 expansion occurs within double quotes, each parameter expands to a
1063 separate word. That is, "\fB$@\fP" is equivalent to
1064 "\fB$1\fP" "\fB$2\fP" ...
1065 When there are no positional parameters, "\fB$@\fP" and
1067 expand to nothing (i.e., they are removed).
1070 Expands to the number of positional parameters in decimal.
1073 Expands to the status of the most recently executed foreground
1077 Expands to the current option flags as specified upon invocation,
1080 builtin command, or those set by the shell itself
1086 Expands to the process ID of the shell. In a () subshell, it
1087 expands to the process ID of the current shell, not the
1091 Expands to the process ID of the most recently executed background
1092 (asynchronous) command.
1095 Expands to the name of the shell or shell script. This is set at
1096 shell initialization. If
1098 is invoked with a file of commands,
1100 is set to the name of that file. If
1106 is set to the first argument after the string to be
1107 executed, if one is present. Otherwise, it is set
1108 to the file name used to invoke
1110 as given by argument zero.
1113 At shell startup, set to the absolute file name of the shell or shell
1114 script being executed as passed in the argument list.
1115 Subsequently, expands to the last argument to the previous command,
1117 Also set to the full file name of each command executed and placed in
1118 the environment exported to that command.
1119 When checking mail, this parameter holds the name of the mail file
1120 currently being checked.
1124 The following variables are set by the shell:
1129 Expands to the full file name used to invoke this instance of
1133 A readonly array variable whose members hold version information for
1136 The values assigned to the array members are as follows:
1141 .B BASH_VERSINFO[\fR0\fP]
1142 The major version number (the \fIrelease\fP).
1144 .B BASH_VERSINFO[\fR1\fP]
1145 The minor version number (the \fIversion\fP).
1147 .B BASH_VERSINFO[\fR2\fP]
1150 .B BASH_VERSINFO[\fR3\fP]
1153 .B BASH_VERSINFO[\fR4\fP]
1154 The release status (e.g., \fIbeta1\fP).
1156 .B BASH_VERSINFO[\fR5\fP]
1157 The value of \fBMACHTYPE\fP.
1162 Expands to a string describing the version of this instance of
1166 An index into \fB${COMP_WORDS}\fP of the word containing the current
1168 This variable is available only in shell functions invoked by the
1169 programmable completion facilities (see \fBProgrammable Completion\fP
1173 The current command line.
1174 This variable is available only in shell functions and external
1175 commands invoked by the
1176 programmable completion facilities (see \fBProgrammable Completion\fP
1180 The index of the current cursor position relative to the beginning of
1181 the current command.
1182 If the current cursor position is at the end of the current command,
1183 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1184 This variable is available only in shell functions and external
1185 commands invoked by the
1186 programmable completion facilities (see \fBProgrammable Completion\fP
1190 An array variable (see \fBArrays\fP below) consisting of the individual
1191 words in the current command line.
1192 This variable is available only in shell functions invoked by the
1193 programmable completion facilities (see \fBProgrammable Completion\fP
1197 An array variable (see
1199 below) containing the current contents of the directory stack.
1200 Directories appear in the stack in the order they are displayed by the
1203 Assigning to members of this array variable may be used to modify
1204 directories already in the stack, but the
1208 builtins must be used to add and remove directories.
1209 Assignment to this variable will not change the current directory.
1213 is unset, it loses its special properties, even if it is
1217 Expands to the effective user ID of the current user, initialized at
1218 shell startup. This variable is readonly.
1221 The name of any currently-executing shell function.
1222 This variable exists only when a shell function is executing.
1226 have no effect and return an error status.
1230 is unset, it loses its special properties, even if it is
1234 An array variable containing the list of groups of which the current
1239 have no effect and return an error status.
1243 is unset, it loses its special properties, even if it is
1247 The history number, or index in the history list, of the current
1252 is unset, it loses its special properties, even if it is
1256 Automatically set to the name of the current host.
1259 Automatically set to a string that uniquely
1260 describes the type of machine on which
1263 The default is system-dependent.
1266 Each time this parameter is referenced, the shell substitutes
1267 a decimal number representing the current sequential line number
1268 (starting with 1) within a script or function. When not in a
1269 script or function, the value substituted is not guaranteed to
1274 is unset, it loses its special properties, even if it is
1278 Automatically set to a string that fully describes the system
1281 is executing, in the standard GNU \fIcpu-company-system\fP format.
1282 The default is system-dependent.
1285 The previous working directory as set by the
1290 The value of the last option argument processed by the
1292 builtin command (see
1294 .B SHELL BUILTIN COMMANDS
1298 The index of the next argument to be processed by the
1300 builtin command (see
1302 .B SHELL BUILTIN COMMANDS
1306 Automatically set to a string that
1307 describes the operating system on which
1310 The default is system-dependent.
1313 An array variable (see
1315 below) containing a list of exit status values from the processes
1316 in the most-recently-executed foreground pipeline (which may
1317 contain only a single command).
1320 The process ID of the shell's parent. This variable is readonly.
1323 The current working directory as set by the
1328 Each time this parameter is referenced, a random integer between
1330 generated. The sequence of random numbers may be initialized by assigning
1337 is unset, it loses its special properties, even if it is
1341 Set to the line of input read by the
1343 builtin command when no arguments are supplied.
1346 Each time this parameter is
1347 referenced, the number of seconds since shell invocation is returned. If a
1348 value is assigned to
1351 the value returned upon subsequent
1353 the number of seconds since the assignment plus the value assigned.
1357 is unset, it loses its special properties, even if it is
1361 A colon-separated list of enabled shell options. Each word in
1362 the list is a valid argument for the
1366 builtin command (see
1368 .B "SHELL BUILTIN COMMANDS"
1369 below). The options appearing in
1372 are those reported as
1375 If this variable is in the environment when
1377 starts up, each shell option in the list will be enabled before
1378 reading any startup files.
1379 This variable is read-only.
1382 Incremented by one each time an instance of
1387 Expands to the user ID of the current user, initialized at shell startup.
1388 This variable is readonly.
1391 The following variables are used by the shell. In some cases,
1393 assigns a default value to a variable; these cases are noted
1399 If this parameter is set when \fBbash\fP is executing a shell script,
1400 its value is interpreted as a filename containing commands to
1401 initialize the shell, as in
1406 is subjected to parameter expansion, command substitution, and arithmetic
1407 expansion before being interpreted as a file name.
1410 is not used to search for the resultant file name.
1413 The search path for the
1416 This is a colon-separated list of directories in which the shell looks
1417 for destination directories specified by the
1420 A sample value is ``.:~:/usr''.
1423 Used by the \fBselect\fP builtin command to determine the terminal width
1424 when printing selection lists. Automatically set upon receipt of a SIGWINCH.
1427 An array variable from which \fBbash\fP reads the possible completions
1428 generated by a shell function invoked by the programmable completion
1429 facility (see \fBProgrammable Completion\fP below).
1432 The default editor for the
1437 A colon-separated list of suffixes to ignore when performing
1438 filename completion (see
1442 A filename whose suffix matches one of the entries in
1445 is excluded from the list of matched filenames.
1446 A sample value is ``.o:~''.
1449 A colon-separated list of patterns defining the set of filenames to
1450 be ignored by pathname expansion.
1451 If a filename matched by a pathname expansion pattern also matches one
1455 it is removed from the list of matches.
1458 If set to a value of
1460 lines which begin with a
1462 character are not entered on the history list.
1463 If set to a value of
1465 lines matching the last history line are not entered.
1468 combines the two options.
1469 If unset, or if set to any other value than those above,
1471 by the parser are saved on the history list, subject to the value
1474 This variable's function is superseded by
1476 The second and subsequent lines of a multi-line compound command are
1477 not tested, and are added to the history regardless of the value of
1481 The name of the file in which command history is saved (see
1484 below). The default value is \fI~/.bash_history\fP. If unset, the
1485 command history is not saved when an interactive shell exits.
1488 The maximum number of lines contained in the history file. When this
1489 variable is assigned a value, the history file is truncated, if
1490 necessary, to contain no more than that number of lines. The default
1491 value is 500. The history file is also truncated to this size after
1492 writing it when an interactive shell exits.
1495 A colon-separated list of patterns used to decide which command lines
1496 should be saved on the history list. Each pattern is anchored at the
1497 beginning of the line and must match the complete line (no implicit
1498 `\fB*\fP' is appended). Each pattern is tested against the line
1499 after the checks specified by
1502 In addition to the normal shell pattern matching characters, `\fB&\fP'
1503 matches the previous history line. `\fB&\fP' may be escaped using a
1504 backslash; the backslash is removed before attempting a match.
1505 The second and subsequent lines of a multi-line compound command are
1506 not tested, and are added to the history regardless of the value of
1510 The number of commands to remember in the command history (see
1513 below). The default value is 500.
1516 The home directory of the current user; the default argument for the
1517 \fBcd\fP builtin command.
1518 The value of this variable is also used when performing tilde expansion.
1521 Contains the name of a file in the same format as
1523 that should be read when the shell needs to complete a
1525 The list of possible hostname completions may be changed while the
1527 the next time hostname completion is attempted after the
1530 adds the contents of the new file to the existing list.
1534 is set, but has no value, \fBbash\fP attempts to read
1536 to obtain the list of possible hostname completions.
1540 is unset, the hostname list is cleared.
1544 .I Internal Field Separator
1546 for word splitting after expansion and to
1547 split lines into words with the
1549 builtin command. The default value is
1550 ``<space><tab><newline>''.
1554 action of an interactive shell on receipt of an
1557 character as the sole input. If set, the value is the number of
1561 characters which must be
1562 typed as the first characters on an input line before
1564 exits. If the variable exists but does not have a numeric value, or
1565 has no value, the default value is 10. If it does not exist,
1568 signifies the end of input to the shell.
1571 The filename for the
1573 startup file, overriding the default of
1581 Used to determine the locale category for any category not specifically
1582 selected with a variable starting with \fBLC_\fP.
1585 This variable overrides the value of \fBLANG\fP and any other
1586 \fBLC_\fP variable specifying a locale category.
1589 This variable determines the collation order used when sorting the
1590 results of pathname expansion, and determines the behavior of range
1591 expressions, equivalence classes, and collating sequences within
1592 pathname expansion and pattern matching.
1595 This variable determines the interpretation of characters and the
1596 behavior of character classes within pathname expansion and pattern
1600 This variable determines the locale used to translate double-quoted
1601 strings preceded by a \fB$\fP.
1604 This variable determines the locale category used for number formatting.
1607 Used by the \fBselect\fP builtin command to determine the column length
1608 for printing selection lists. Automatically set upon receipt of a SIGWINCH.
1611 If this parameter is set to a file name and the
1614 variable is not set,
1616 informs the user of the arrival of mail in the specified file.
1622 checks for mail. The default is 60 seconds. When it is time to check
1623 for mail, the shell does so before displaying the primary prompt.
1624 If this variable is unset, or set to a value that is not a number
1625 greater than or equal to zero, the shell disables mail checking.
1628 A colon-separated list of file names to be checked for mail.
1629 The message to be printed when mail arrives in a particular file
1630 may be specified by separating the file name from the message with a `?'.
1631 When used in the text of the message, \fB$_\fP expands to the name of
1632 the current mailfile.
1636 \fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1639 supplies a default value for this variable, but the location of the user
1640 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
1644 If set to the value 1,
1646 displays error messages generated by the
1648 builtin command (see
1650 .B SHELL BUILTIN COMMANDS
1654 is initialized to 1 each time the shell is invoked or a shell
1658 The search path for commands. It
1659 is a colon-separated list of directories in which
1660 the shell looks for commands (see
1662 .B COMMAND EXECUTION
1663 below). The default path is system-dependent,
1664 and is set by the administrator who installs
1667 .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.\fP.
1668 .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
1671 If this variable is in the environment when \fBbash\fP starts, the shell
1672 enters \fIposix mode\fP before reading the startup files, as if the
1674 invocation option had been supplied. If it is set while the shell is
1675 running, \fBbash\fP enables \fIposix mode\fP, as if the command
1676 .if t \f(CWset -o posix\fP
1677 .if n \fIset -o posix\fP
1681 If set, the value is executed as a command prior to issuing each primary
1685 The value of this parameter is expanded (see
1688 below) and used as the primary prompt string. The default value is
1689 ``\fB\es\-\ev\e$ \fP''.
1692 The value of this parameter is expanded as with
1694 and used as the secondary prompt string. The default is
1698 The value of this parameter is used as the prompt for the
1706 The value of this parameter is expanded as with
1708 and the value is printed before each command
1710 displays during an execution trace. The first character of
1713 is replicated multiple times, as necessary, to indicate multiple
1714 levels of indirection. The default is ``\fB+ \fP''.
1717 The value of this parameter is used as a format string specifying
1718 how the timing information for pipelines prefixed with the
1720 reserved word should be displayed.
1721 The \fB%\fP character introduces an escape sequence that is
1722 expanded to a time value or other information.
1723 The escape sequences and their meanings are as follows; the
1724 braces denote optional portions.
1733 The elapsed time in seconds.
1736 The number of CPU seconds spent in user mode.
1739 The number of CPU seconds spent in system mode.
1742 The CPU percentage, computed as (%U + %S) / %R.
1746 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1747 the number of fractional digits after a decimal point.
1748 A value of 0 causes no decimal point or fraction to be output.
1749 At most three places after the decimal point may be specified;
1750 values of \fIp\fP greater than 3 are changed to 3.
1751 If \fIp\fP is not specified, the value 3 is used.
1753 The optional \fBl\fP specifies a longer format, including
1754 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1755 The value of \fIp\fP determines whether or not the fraction is
1758 If this variable is not set, \fBbash\fP acts as if it had the
1759 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1760 If the value is null, no timing information is displayed.
1761 A trailing newline is added when the format string is displayed.
1764 If set to a value greater than zero, the value is interpreted as the
1765 number of seconds to wait for input after issuing the primary prompt.
1767 terminates after waiting for that number of seconds if input does
1771 This variable controls how the shell interacts with the user and
1772 job control. If this variable is set, single word simple
1773 commands without redirections are treated as candidates for resumption
1774 of an existing stopped job. There is no ambiguity allowed; if there is
1775 more than one job beginning with the string typed, the job most recently
1776 accessed is selected. The
1778 of a stopped job, in this context, is the command line used to
1782 the string supplied must match the name of a stopped job exactly;
1785 the string supplied needs to match a substring of the name of a
1788 value provides functionality analogous to the
1793 below). If set to any other value, the supplied string must
1794 be a prefix of a stopped job's name; this provides functionality
1800 The two or three characters which control history expansion
1801 and tokenization (see
1803 .B HISTORY EXPANSION
1804 below). The first character is the \fIhistory expansion\fP character,
1805 the character which signals the start of a history
1806 expansion, normally `\fB!\fP'.
1807 The second character is the \fIquick substitution\fP
1808 character, which is used as shorthand for re-running the previous
1809 command entered, substituting one string for another in the command.
1810 The default is `\fB^\fP'.
1811 The optional third character is the character
1812 which indicates that the remainder of the line is a comment when found
1813 as the first character of a word, normally `\fB#\fP'. The history
1814 comment character causes history substitution to be skipped for the
1815 remaining words on the line. It does not necessarily cause the shell
1816 parser to treat the rest of the line as a comment.
1820 provides one-dimensional array variables. Any variable may be used as
1823 builtin will explicitly declare an array. There is no maximum
1824 limit on the size of an array, nor any requirement that members
1825 be indexed or assigned contiguously. Arrays are indexed using
1826 integers and are zero-based.
1828 An array is created automatically if any variable is assigned to using
1829 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
1831 is treated as an arithmetic expression that must evaluate to a number
1832 greater than or equal to zero. To explicitly declare an array, use
1833 .B declare \-a \fIname\fP
1836 .B SHELL BUILTIN COMMANDS
1838 .B declare \-a \fIname\fP[\fIsubscript\fP]
1839 is also accepted; the \fIsubscript\fP is ignored. Attributes may be
1840 specified for an array variable using the
1844 builtins. Each attribute applies to all members of an array.
1846 Arrays are assigned to using compound assignments of the form
1847 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
1848 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
1849 \fIstring\fP is required. If
1850 the optional brackets and subscript are supplied, that index is assigned to;
1851 otherwise the index of the element assigned is the last index assigned
1852 to by the statement plus one. Indexing starts at zero.
1853 This syntax is also accepted by the
1855 builtin. Individual array elements may be assigned to using the
1856 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
1858 Any element of an array may be referenced using
1859 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
1860 conflicts with pathname expansion. If
1861 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
1862 all members of \fIname\fP. These subscripts differ only when the
1863 word appears within double quotes. If the word is double-quoted,
1864 ${\fIname\fP[*]} expands to a single
1865 word with the value of each array member separated by the first
1869 special variable, and ${\fIname\fP[@]} expands each element of
1870 \fIname\fP to a separate word. When there are no array members,
1871 ${\fIname\fP[@]} expands to nothing. This is analogous to the expansion
1872 of the special parameters \fB*\fP and \fB@\fP (see
1873 .B Special Parameters
1874 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
1875 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
1876 \fB@\fP, the expansion is the number of elements in the array.
1877 Referencing an array variable without a subscript is equivalent to
1878 referencing element zero.
1882 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
1883 destroys the array element at index \fIsubscript\fP.
1884 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
1885 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
1886 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
1893 builtins each accept a
1895 option to specify an array. The
1899 option to assign a list of words read from the standard input
1904 builtins display array values in a way that allows them to be
1905 reused as assignments.
1907 Expansion is performed on the command line after it has been split into
1908 words. There are seven kinds of expansion performed:
1909 .IR "brace expansion" ,
1910 .IR "tilde expansion" ,
1911 .IR "parameter and variable expansion" ,
1912 .IR "command substitution" ,
1913 .IR "arithmetic expansion" ,
1914 .IR "word splitting" ,
1916 .IR "pathname expansion" .
1918 The order of expansions is: brace expansion, tilde expansion,
1919 parameter, variable and arithmetic expansion and
1920 command substitution
1921 (done in a left-to-right fashion), word splitting, and pathname
1924 On systems that can support it, there is an additional expansion
1925 available: \fIprocess substitution\fP.
1927 Only brace expansion, word splitting, and pathname expansion
1928 can change the number of words of the expansion; other expansions
1929 expand a single word to a single word.
1930 The only exceptions to this are the expansions of
1931 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
1932 as explained above (see
1937 .I "Brace expansion"
1938 is a mechanism by which arbitrary strings
1939 may be generated. This mechanism is similar to
1940 \fIpathname expansion\fP, but the filenames generated
1941 need not exist. Patterns to be brace expanded take
1942 the form of an optional
1944 followed by a series of comma-separated strings
1945 between a pair of braces, followed by an optional
1947 The preamble is prefixed to each string contained
1948 within the braces, and the postscript is then appended
1949 to each resulting string, expanding left to right.
1951 Brace expansions may be nested. The results of each expanded
1952 string are not sorted; left to right order is preserved.
1953 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
1955 Brace expansion is performed before any other expansions,
1956 and any characters special to other expansions are preserved
1957 in the result. It is strictly textual.
1959 does not apply any syntactic interpretation to the context of the
1960 expansion or the text between the braces.
1962 A correctly-formed brace expansion must contain unquoted opening
1963 and closing braces, and at least one unquoted comma.
1964 Any incorrectly formed brace expansion is left unchanged.
1965 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
1966 being considered part of a brace expression.
1967 To avoid conflicts with parameter expansion, the string \fB${\fP
1968 is not considered eligible for brace expansion.
1970 This construct is typically used as shorthand when the common
1971 prefix of the strings to be generated is longer than in the
1975 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1979 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1982 Brace expansion introduces a slight incompatibility with
1983 historical versions of
1986 does not treat opening or closing braces specially when they
1987 appear as part of a word, and preserves them in the output.
1989 removes braces from words as a consequence of brace
1990 expansion. For example, a word entered to
1993 appears identically in the output. The same word is
1998 If strict compatibility with
2004 option or disable brace expansion with the
2010 .B SHELL BUILTIN COMMANDS
2014 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2015 the characters preceding the first unquoted slash (or all characters,
2016 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2017 If none of the characters in the tilde-prefix are quoted, the
2018 characters in the tilde-prefix following the tilde are treated as a
2019 possible \fIlogin name\fP.
2020 If this login name is the null string, the tilde is replaced with the
2021 value of the shell parameter
2027 is unset, the home directory of the user executing the shell is
2028 substituted instead.
2029 Otherwise, the tilde-prefix is replaced with the home directory
2030 associated with the specified login name.
2032 If the tilde-prefix is a `~+', the value of the shell variable
2035 replaces the tilde-prefix.
2036 If the tilde-prefix is a `~\-', the value of the shell variable
2039 if it is set, is substituted.
2040 If the characters following the tilde in the tilde-prefix consist
2041 of a number \fIN\fP, optionally prefixed
2042 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2043 element from the directory stack, as it would be displayed by the
2045 builtin invoked with the tilde-prefix as an argument.
2046 If the characters following the tilde in the tilde-prefix consist of a
2047 number without a leading `+' or `\-', `+' is assumed.
2049 If the login name is invalid, or the tilde expansion fails, the word
2052 Each variable assignment is checked for unquoted tilde-prefixes immediately
2057 In these cases, tilde expansion is also performed.
2058 Consequently, one may use file names with tildes in assignments to
2066 and the shell assigns the expanded value.
2067 .SS Parameter Expansion
2069 The `\fB$\fP' character introduces parameter expansion,
2070 command substitution, or arithmetic expansion. The parameter name
2071 or symbol to be expanded may be enclosed in braces, which
2072 are optional but serve to protect the variable to be expanded from
2073 characters immediately following it which could be
2074 interpreted as part of the name.
2076 When braces are used, the matching ending brace is the first `\fB}\fP'
2077 not escaped by a backslash or within a quoted string, and not within an
2078 embedded arithmetic expansion, command substitution, or paramter
2084 The value of \fIparameter\fP is substituted. The braces are required
2087 is a positional parameter with more than one digit,
2090 is followed by a character which is not to be
2091 interpreted as part of its name.
2094 If the first character of \fIparameter\fP is an exclamation point,
2095 a level of variable indirection is introduced.
2096 \fBBash\fP uses the value of the variable formed from the rest of
2097 \fIparameter\fP as the name of the variable; this variable is then
2098 expanded and that value is used in the rest of the substitution, rather
2099 than the value of \fIparameter\fP itself.
2100 This is known as \fIindirect expansion\fP.
2101 The exception to this is the expansion of ${!\fIprefix\fP*}
2104 In each of the cases below, \fIword\fP is subject to tilde expansion,
2105 parameter expansion, command substitution, and arithmetic expansion.
2106 When not performing substring expansion, \fBbash\fP tests for a parameter
2107 that is unset or null; omitting the colon results in a test only for a
2108 parameter that is unset.
2112 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
2113 \fBUse Default Values\fP. If
2115 is unset or null, the expansion of
2117 is substituted. Otherwise, the value of
2121 ${\fIparameter\fP\fB:=\fP\fIword\fP}
2122 \fBAssign Default Values\fP.
2125 is unset or null, the expansion of
2131 is then substituted. Positional parameters and special parameters may
2132 not be assigned to in this way.
2134 ${\fIparameter\fP\fB:?\fP\fIword\fP}
2135 \fBDisplay Error if Null or Unset\fP.
2138 is null or unset, the expansion of \fIword\fP (or a message to that effect
2141 is not present) is written to the standard error and the shell, if it
2142 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
2145 ${\fIparameter\fP\fB:+\fP\fIword\fP}
2146 \fBUse Alternate Value\fP.
2149 is null or unset, nothing is substituted, otherwise the expansion of
2154 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
2156 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
2158 \fBSubstring Expansion.\fP
2159 Expands to up to \fIlength\fP characters of \fIparameter\fP
2160 starting at the character specified by \fIoffset\fP.
2161 If \fIlength\fP is omitted, expands to the substring of
2162 \fIparameter\fP starting at the character specified by \fIoffset\fP.
2163 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2166 ARITHMETIC EVALUATION
2168 \fIlength\fP must evaluate to a number greater than or equal to zero.
2169 If \fIoffset\fP evaluates to a number less than zero, the value
2170 is used as an offset from the end of the value of \fIparameter\fP.
2171 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2172 parameters beginning at \fIoffset\fP.
2173 If \fIparameter\fP is an array name indexed by @ or *,
2174 the result is the \fIlength\fP
2175 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2176 Substring indexing is zero-based unless the positional parameters
2177 are used, in which case the indexing starts at 1.
2179 ${\fB!\fP\fIprefix\fP\fB*\fP}
2180 Expands to the names of variables whose names begin with \fIprefix\fP,
2181 separated by the first character of the
2186 ${\fB#\fP\fIparameter\fP}
2187 The length in characters of the value of \fIparameter\fP is substituted.
2194 the value substituted is the number of positional parameters.
2197 is an array name subscripted by
2201 the value substituted is the number of elements in the array.
2204 ${\fIparameter\fP\fB#\fP\fIword\fP}
2206 ${\fIparameter\fP\fB##\fP\fIword\fP}
2210 is expanded to produce a pattern just as in pathname
2211 expansion. If the pattern matches the beginning of
2214 then the result of the expansion is the expanded value of
2216 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2217 longest matching pattern (the ``\fB##\fP'' case) deleted.
2224 the pattern removal operation is applied to each positional
2225 parameter in turn, and the expansion is the resultant list.
2228 is an array variable subscripted with
2232 the pattern removal operation is applied to each member of the
2233 array in turn, and the expansion is the resultant list.
2236 ${\fIparameter\fP\fB%\fP\fIword\fP}
2238 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2240 The \fIword\fP is expanded to produce a pattern just as in
2242 If the pattern matches a trailing portion of the expanded value of
2244 then the result of the expansion is the expanded value of
2246 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2247 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2254 the pattern removal operation is applied to each positional
2255 parameter in turn, and the expansion is the resultant list.
2258 is an array variable subscripted with
2262 the pattern removal operation is applied to each member of the
2263 array in turn, and the expansion is the resultant list.
2266 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2268 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2270 The \fIpattern\fP is expanded to produce a pattern just as in
2272 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2273 against its value is replaced with \fIstring\fP.
2274 In the first form, only the first match is replaced.
2275 The second form causes all matches of \fIpattern\fP to be
2276 replaced with \fIstring\fP.
2277 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2278 of the expanded value of \fIparameter\fP.
2279 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2280 of the expanded value of \fIparameter\fP.
2281 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2282 and the \fB/\fP following \fIpattern\fP may be omitted.
2289 the substitution operation is applied to each positional
2290 parameter in turn, and the expansion is the resultant list.
2293 is an array variable subscripted with
2297 the substitution operation is applied to each member of the
2298 array in turn, and the expansion is the resultant list.
2299 .SS Command Substitution
2301 \fICommand substitution\fP allows the output of a command to replace
2302 the command name. There are two forms:
2306 \fB$(\fP\fIcommand\fP\|\fB)\fP
2310 \fB`\fP\fIcommand\fP\fB`\fP
2314 performs the expansion by executing \fIcommand\fP and
2315 replacing the command substitution with the standard output of the
2316 command, with any trailing newlines deleted.
2317 Embedded newlines are not deleted, but they may be removed during
2319 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2320 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2322 When the old-style backquote form of substitution is used,
2323 backslash retains its literal meaning except when followed by
2328 The first backquote not preceded by a backslash terminates the
2329 command substitution.
2330 When using the $(\^\fIcommand\fP\|) form, all characters between the
2331 parentheses make up the command; none are treated specially.
2333 Command substitutions may be nested. To nest when using the backquoted form,
2334 escape the inner backquotes with backslashes.
2336 If the substitution appears within double quotes, word splitting and
2337 pathname expansion are not performed on the results.
2338 .SS Arithmetic Expansion
2340 Arithmetic expansion allows the evaluation of an arithmetic expression
2341 and the substitution of the result. The format for arithmetic expansion is:
2344 \fB$((\fP\fIexpression\fP\fB))\fP
2349 is treated as if it were within double quotes, but a double quote
2350 inside the parentheses is not treated specially.
2351 All tokens in the expression undergo parameter expansion, string
2352 expansion, command substitution, and quote removal.
2353 Arithmetic substitutions may be nested.
2355 The evaluation is performed according to the rules listed below under
2357 .BR "ARITHMETIC EVALUATION" .
2362 prints a message indicating failure and no substitution occurs.
2363 .SS Process Substitution
2365 \fIProcess substitution\fP is supported on systems that support named
2366 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2367 It takes the form of
2368 \fB<(\fP\fIlist\^\fP\fB)\fP
2370 \fB>(\fP\fIlist\^\fP\fB)\fP.
2371 The process \fIlist\fP is run with its input or output connected to a
2372 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2373 passed as an argument to the current command as the result of the
2374 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2375 the file will provide input for \fIlist\fP. If the
2376 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2377 argument should be read to obtain the output of \fIlist\fP.
2379 When available, process substitution is performed
2380 simultaneously with parameter and variable expansion,
2381 command substitution,
2382 and arithmetic expansion.
2385 The shell scans the results of
2386 parameter expansion,
2387 command substitution,
2389 arithmetic expansion
2390 that did not occur within double quotes for
2391 .IR "word splitting" .
2393 The shell treats each character of
2396 as a delimiter, and splits the results of the other
2397 expansions into words on these characters. If
2402 .BR <space><tab><newline> ,
2407 characters serves to delimit words. If
2410 has a value other than the default, then sequences of
2411 the whitespace characters
2415 are ignored at the beginning and end of the
2416 word, as long as the whitespace character is in the
2423 whitespace character).
2430 whitespace, along with any adjacent
2433 whitespace characters, delimits a field.
2437 whitespace characters is also treated as a delimiter.
2441 is null, no word splitting occurs.
2443 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2444 Unquoted implicit null arguments, resulting from the expansion of
2445 parameters that have no values, are removed.
2446 If a parameter with no value is expanded within double quotes, a
2447 null argument results and is retained.
2449 Note that if no expansion occurs, no splitting
2451 .SS Pathname Expansion
2453 After word splitting,
2456 option has been set,
2458 scans each word for the characters
2463 If one of these characters appears, then the word is
2466 and replaced with an alphabetically sorted list of
2467 file names matching the pattern.
2468 If no matching file names are found,
2469 and the shell option
2471 is disabled, the word is left unchanged.
2474 option is set, and no matches are found,
2475 the word is removed.
2478 is enabled, the match is performed without regard to the case
2479 of alphabetic characters.
2480 When a pattern is used for pathname expansion,
2483 at the start of a name or immediately following a slash
2484 must be matched explicitly, unless the shell option
2487 When matching a pathname, the slash character must always be
2491 character is not treated specially.
2492 See the description of
2496 .B SHELL BUILTIN COMMANDS
2497 for a description of the
2507 shell variable may be used to restrict the set of file names matching a
2512 is set, each matching file name that also matches one of the patterns in
2515 is removed from the list of matches.
2520 are always ignored, even when
2523 is set. However, setting
2526 has the effect of enabling the
2528 shell option, so all other file names beginning with a
2531 To get the old behavior of ignoring file names beginning with a
2535 one of the patterns in
2540 option is disabled when
2545 \fBPattern Matching\fP
2547 Any character that appears in a pattern, other than the special pattern
2548 characters described below, matches itself. The NUL character may not
2549 occur in a pattern. The special pattern characters must be quoted if
2550 they are to be matched literally.
2552 The special pattern characters have the following meanings:
2557 Matches any string, including the null string.
2560 Matches any single character.
2563 Matches any one of the enclosed characters. A pair of characters
2564 separated by a hyphen denotes a
2565 \fIrange expression\fP;
2566 any character that sorts between those two characters, inclusive,
2567 using the current locale's collating sequence and character set,
2568 is matched. If the first character following the
2574 then any character not enclosed is matched.
2575 The sorting order of characters in range expressions is determined by
2576 the current locale and the value of the \fBLC_COLLATE\fP shell variable,
2580 may be matched by including it as the first or last character
2584 may be matched by including it as the first character
2593 \fIcharacter classes\fP can be specified using the syntax
2594 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
2595 following classes defined in the POSIX.2 standard:
2599 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
2600 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
2602 A character class matches any character belonging to that class.
2610 an \fIequivalence class\fP can be specified using the syntax
2611 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
2612 same collation weight (as defined by the current locale) as
2613 the character \fIc\fP.
2621 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
2626 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
2627 builtin, several extended pattern matching operators are recognized.
2628 In the following description, a \fIpattern-list\fP is a list of one
2629 or more patterns separated by a \fB|\fP.
2630 Composite patterns may be formed using one or more of the following
2636 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
2637 Matches zero or one occurrence of the given patterns
2639 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
2640 Matches zero or more occurrences of the given patterns
2642 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
2643 Matches one or more occurrences of the given patterns
2645 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
2646 Matches exactly one of the given patterns
2648 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
2649 Matches anything except one of the given patterns
2654 After the preceding expansions, all unquoted occurrences of the
2658 and \^\f3"\fP\^ that did not result from one of the above
2659 expansions are removed.
2661 Before a command is executed, its input and output
2664 using a special notation interpreted by the shell.
2665 Redirection may also be used to open and close files for the
2666 current shell execution environment. The following redirection
2667 operators may precede or appear anywhere within a
2671 Redirections are processed in the order they appear, from
2674 In the following descriptions, if the file descriptor number is
2675 omitted, and the first character of the redirection operator is
2677 the redirection refers to the standard input (file descriptor
2678 0). If the first character of the redirection operator is
2680 the redirection refers to the standard output (file descriptor
2683 The word following the redirection operator in the following
2684 descriptions, unless otherwise noted, is subjected to brace expansion,
2685 tilde expansion, parameter expansion, command substitution, arithmetic
2686 expansion, quote removal, pathname expansion, and word splitting.
2687 If it expands to more than one word,
2691 Note that the order of redirections is significant. For example,
2695 ls \fB>\fP dirlist 2\fB>&\fP1
2698 directs both standard output and standard error to the file
2703 ls 2\fB>&\fP1 \fB>\fP dirlist
2706 directs only the standard output to file
2708 because the standard error was duplicated as standard output
2709 before the standard output was redirected to
2712 \fBBash\fP handles several filenames specially when they are used in
2713 redirections, as described in the following table:
2719 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
2722 File descriptor 0 is duplicated.
2725 File descriptor 1 is duplicated.
2728 File descriptor 2 is duplicated.
2730 .B /dev/tcp/\fIhost\fP/\fIport\fP
2731 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
2732 is an integer port number or service name, \fBbash\fP attempts to open
2733 a TCP connection to the corresponding socket.
2735 .B /dev/udp/\fIhost\fP/\fIport\fP
2736 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
2737 is an integer port number or service name, \fBbash\fP attempts to open
2738 a UDP connection to the corresponding socket.
2742 A failure to open or create a file causes the redirection to fail.
2743 .SS Redirecting Input
2745 Redirection of input causes the file whose name results from
2748 to be opened for reading on file descriptor
2750 or the standard input (file descriptor 0) if
2754 The general format for redirecting input is:
2757 [\fIn\fP]\fB<\fP\fIword\fP
2759 .SS Redirecting Output
2761 Redirection of output causes the file whose name results from
2764 to be opened for writing on file descriptor
2766 or the standard output (file descriptor 1) if
2768 is not specified. If the file does not exist it is created;
2769 if it does exist it is truncated to zero size.
2771 The general format for redirecting output is:
2774 [\fIn\fP]\fB>\fP\fIword\fP
2777 If the redirection operator is
2783 builtin has been enabled, the redirection will fail if the file
2784 whose name results from the expansion of \fIword\fP exists and is
2786 If the redirection operator is
2788 or the redirection operator is
2794 builtin command is not enabled, the redirection is attempted even
2795 if the file named by \fIword\fP exists.
2796 .SS Appending Redirected Output
2798 Redirection of output in this fashion
2799 causes the file whose name results from
2802 to be opened for appending on file descriptor
2804 or the standard output (file descriptor 1) if
2806 is not specified. If the file does not exist it is created.
2808 The general format for appending output is:
2811 [\fIn\fP]\fB>>\fP\fIword\fP
2814 .SS Redirecting Standard Output and Standard Error
2818 standard output (file descriptor 1) and
2819 the standard error output (file descriptor 2)
2820 to be redirected to the file whose name is the
2823 with this construct.
2825 There are two formats for redirecting standard output and
2836 Of the two forms, the first is preferred.
2837 This is semantically equivalent to
2840 \fB>\fP\fIword\fP 2\fB>&\fP1
2844 This type of redirection instructs the shell to read input from the
2845 current source until a line containing only
2847 (with no trailing blanks)
2849 the lines read up to that point are then used as the standard
2850 input for a command.
2852 The format of here-documents is as follows:
2856 \fB<<\fP[\fB\-\fP]\fIword\fP
2862 No parameter expansion, command substitution, arithmetic expansion,
2863 or pathname expansion is performed on
2865 If any characters in
2869 is the result of quote removal on
2871 and the lines in the here-document are not expanded.
2872 If \fIword\fP is unquoted,
2873 all lines of the here-document are subjected to parameter expansion,
2874 command substitution, and arithmetic expansion. In the latter
2875 case, the character sequence
2879 must be used to quote the characters
2885 If the redirection operator is
2887 then all leading tab characters are stripped from input lines and the
2891 here-documents within shell scripts to be indented in a
2893 .SS "Duplicating File Descriptors"
2895 The redirection operator
2898 [\fIn\fP]\fB<&\fP\fIword\fP
2901 is used to duplicate input file descriptors.
2904 expands to one or more digits, the file descriptor denoted by
2906 is made to be a copy of that file descriptor.
2909 do not specify a file descriptor open for input, a redirection error occurs.
2918 is not specified, the standard input (file descriptor 0) is used.
2923 [\fIn\fP]\fB>&\fP\fIword\fP
2926 is used similarly to duplicate output file descriptors. If
2928 is not specified, the standard output (file descriptor 1) is used.
2931 do not specify a file descriptor open for output, a redirection error occurs.
2932 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
2933 expand to one or more digits, the standard output and standard
2934 error are redirected as described previously.
2935 .SS "Opening File Descriptors for Reading and Writing"
2937 The redirection operator
2940 [\fIn\fP]\fB<>\fP\fIword\fP
2943 causes the file whose name is the expansion of
2945 to be opened for both reading and writing on file descriptor
2947 or on file descriptor 0 if
2949 is not specified. If the file does not exist, it is created.
2951 \fIAliases\fP allow a string to be substituted for a word when it is used
2952 as the first word of a simple command.
2953 The shell maintains a list of aliases that may be set and unset with the
2957 builtin commands (see
2959 .B SHELL BUILTIN COMMANDS
2961 The first word of each command, if unquoted,
2962 is checked to see if it has an
2963 alias. If so, that word is replaced by the text of the alias.
2964 The alias name and the replacement text may contain any valid
2965 shell input, including the
2967 listed above, with the exception that the alias name may not
2968 contain \fI=\fP. The first word of the replacement text is tested
2969 for aliases, but a word that is identical to an alias being expanded
2970 is not expanded a second time. This means that one may alias
2976 does not try to recursively expand the replacement text.
2977 If the last character of the alias value is a
2979 then the next command
2980 word following the alias is also checked for alias expansion.
2982 Aliases are created and listed with the
2984 command, and removed with the
2988 There is no mechanism for using arguments in the replacement text.
2989 If arguments are needed, a shell function should be used (see
2994 Aliases are not expanded when the shell is not interactive, unless
2997 shell option is set using
2999 (see the description of
3003 \fBSHELL BUILTIN COMMANDS\fP
3006 The rules concerning the definition and use of aliases are
3009 always reads at least one complete line
3010 of input before executing any
3011 of the commands on that line. Aliases are expanded when a
3012 command is read, not when it is executed. Therefore, an
3013 alias definition appearing on the same line as another
3014 command does not take effect until the next line of input is read.
3015 The commands following the alias definition
3016 on that line are not affected by the new alias.
3017 This behavior is also an issue when functions are executed.
3018 Aliases are expanded when a function definition is read,
3019 not when the function is executed, because a function definition
3020 is itself a compound command. As a consequence, aliases
3021 defined in a function are not available until after that
3022 function is executed. To be safe, always put
3023 alias definitions on a separate line, and do not use
3025 in compound commands.
3027 For almost every purpose, aliases are superseded by
3030 A shell function, defined as described above under
3032 .BR "SHELL GRAMMAR" ,
3033 stores a series of commands for later execution.
3034 When the name of a shell function is used as a simple command name,
3035 the list of commands associated with that function name is executed.
3036 Functions are executed in the context of the
3037 current shell; no new process is created to interpret
3038 them (contrast this with the execution of a shell script).
3039 When a function is executed, the arguments to the
3040 function become the positional parameters
3041 during its execution.
3042 The special parameter
3044 is updated to reflect the change. Positional parameter 0
3049 variable is set to the name of the function while the function
3051 All other aspects of the shell execution
3052 environment are identical between a function and its caller
3053 with the exception that the
3056 trap (see the description of the
3060 .B SHELL BUILTIN COMMANDS
3061 below) is not inherited.
3063 Variables local to the function may be declared with the
3065 builtin command. Ordinarily, variables and their values
3066 are shared between the function and its caller.
3068 If the builtin command
3070 is executed in a function, the function completes and
3071 execution resumes with the next command after the function
3072 call. When a function completes, the values of the
3073 positional parameters and the special parameter
3075 are restored to the values they had prior to the function's
3078 Function names and definitions may be listed with the
3084 builtin commands. The
3090 will list the function names only.
3091 Functions may be exported so that subshells
3092 automatically have them defined with the
3098 Functions may be recursive. No limit is imposed on the number
3100 .SH "ARITHMETIC EVALUATION"
3101 The shell allows arithmetic expressions to be evaluated, under
3102 certain circumstances (see the \fBlet\fP builtin command and
3103 \fBArithmetic Expansion\fP).
3104 Evaluation is done in long integers with no check for overflow,
3105 though division by 0 is trapped and flagged as an error.
3106 The operators and their precedence and associativity are the same
3107 as in the C language.
3108 The following list of operators is grouped into levels of
3109 equal-precedence operators.
3110 The levels are listed in order of decreasing precedence.
3114 .B \fIid\fP++ \fIid\fP\-\-
3115 variable post-increment and post-decrement
3117 .B ++\fIid\fP \-\-\fIid\fP
3118 variable pre-increment and pre-decrement
3121 unary minus and plus
3124 logical and bitwise negation
3130 multiplication, division, remainder
3133 addition, subtraction
3136 left and right bitwise shifts
3142 equality and inequality
3148 bitwise exclusive OR
3159 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
3160 conditional evaluation
3162 .B = *= /= %= += \-= <<= >>= &= ^= |=
3165 .B \fIexpr1\fP , \fIexpr2\fP
3169 Shell variables are allowed as operands; parameter expansion is
3170 performed before the expression is evaluated.
3171 Within an expression, shell variables may also be referenced by name
3172 without using the parameter expansion syntax.
3173 The value of a variable is evaluated as an arithmetic expression
3174 when it is referenced.
3175 A shell variable need not have its integer attribute
3176 turned on to be used in an expression.
3178 Constants with a leading 0 are interpreted as octal numbers.
3179 A leading 0x or 0X denotes hexadecimal.
3180 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
3181 is a decimal number between 2 and 64 representing the arithmetic
3182 base, and \fIn\fP is a number in that base.
3183 If \fIbase#\fP is omitted, then base 10 is used.
3184 The digits greater than 9 are represented by the lowercase letters,
3185 the uppercase letters, @, and _, in that order.
3186 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
3187 letters may be used interchangably to represent numbers between 10
3190 Operators are evaluated in order of precedence. Sub-expressions in
3191 parentheses are evaluated first and may override the precedence
3193 .SH "CONDITIONAL EXPRESSIONS"
3194 Conditional expressions are used by the \fB[[\fP compound command and
3195 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
3196 and perform string and arithmetic comparisons.
3197 Expressions are formed from the following unary or binary primaries.
3198 If any \fIfile\fP argument to one of the primaries is of the form
3199 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
3200 If the \fIfile\fP argument to one of the primaries is one of
3201 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
3202 descriptor 0, 1, or 2, respectively, is checked.
3207 True if \fIfile\fP exists.
3210 True if \fIfile\fP exists and is a block special file.
3213 True if \fIfile\fP exists and is a character special file.
3216 True if \fIfile\fP exists and is a directory.
3219 True if \fIfile\fP exists.
3222 True if \fIfile\fP exists and is a regular file.
3225 True if \fIfile\fP exists and is set-group-id.
3228 True if \fIfile\fP exists and is a symbolic link.
3231 True if \fIfile\fP exists and its ``sticky'' bit is set.
3234 True if \fIfile\fP exists and is a named pipe (FIFO).
3237 True if \fIfile\fP exists and is readable.
3240 True if \fIfile\fP exists and has a size greater than zero.
3243 True if file descriptor
3245 is open and refers to a terminal.
3248 True if \fIfile\fP exists and its set-user-id bit is set.
3251 True if \fIfile\fP exists and is writable.
3254 True if \fIfile\fP exists and is executable.
3257 True if \fIfile\fP exists and is owned by the effective user id.
3260 True if \fIfile\fP exists and is owned by the effective group id.
3263 True if \fIfile\fP exists and is a symbolic link.
3266 True if \fIfile\fP exists and is a socket.
3269 True if \fIfile\fP exists and has been modified since it was last read.
3271 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3272 True if \fIfile1\fP is newer (according to
3273 modification date) than \fIfile2\fP.
3275 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3276 True if \fIfile1\fP is older than \fIfile2\fP.
3278 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3279 True if \fIfile1\fP and \fIfile2\fP have the same device and
3282 .B \-o \fIoptname\fP
3283 True if shell option
3286 See the list of options under the description of the
3293 True if the length of \fIstring\fP is zero.
3298 True if the length of
3302 \fIstring1\fP \fB==\fP \fIstring2\fP
3303 True if the strings are equal. \fB=\fP may be used in place of
3306 \fIstring1\fP \fB!=\fP \fIstring2\fP
3307 True if the strings are not equal.
3309 \fIstring1\fP \fB<\fP \fIstring2\fP
3310 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
3311 in the current locale.
3313 \fIstring1\fP \fB>\fP \fIstring2\fP
3314 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
3315 in the current locale.
3317 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
3328 These arithmetic binary operators return true if \fIarg1\fP
3329 is equal to, not equal to, less than, less than or equal to,
3330 greater than, or greater than or equal to \fIarg2\fP, respectively.
3334 may be positive or negative integers.
3336 .SH "SIMPLE COMMAND EXPANSION"
3337 When a simple command is executed, the shell performs the following
3338 expansions, assignments, and redirections, from left to right.
3340 The words that the parser has marked as variable assignments (those
3341 preceding the command name) and redirections are saved for later
3344 The words that are not variable assignments or redirections are
3345 expanded. If any words remain after expansion, the first word
3346 is taken to be the name of the command and the remaining words are
3349 Redirections are performed as described above under
3353 The text after the \fB=\fP in each variable assignment undergoes tilde
3354 expansion, parameter expansion, command substitution, arithmetic expansion,
3355 and quote removal before being assigned to the variable.
3357 If no command name results, the variable assignments affect the current
3358 shell environment. Otherwise, the variables are added to the environment
3359 of the executed command and do not affect the current shell environment.
3360 If any of the assignments attempts to assign a value to a readonly variable,
3361 an error occurs, and the command exits with a non-zero status.
3363 If no command name results, redirections are performed, but do not
3364 affect the current shell environment. A redirection error causes the
3365 command to exit with a non-zero status.
3367 If there is a command name left after expansion, execution proceeds as
3368 described below. Otherwise, the command exits. If one of the expansions
3369 contained a command substitution, the exit status of the command is
3370 the exit status of the last command substitution performed. If there
3371 were no command substitutions, the command exits with a status of zero.
3372 .SH "COMMAND EXECUTION"
3373 After a command has been split into words, if it results in a
3374 simple command and an optional list of arguments, the following
3377 If the command name contains no slashes, the shell attempts to
3378 locate it. If there exists a shell function by that name, that
3379 function is invoked as described above in
3382 If the name does not match a function, the shell searches for
3383 it in the list of shell builtins. If a match is found, that
3386 If the name is neither a shell function nor a builtin,
3387 and contains no slashes,
3389 searches each element of the
3392 for a directory containing an executable file by that name.
3394 uses a hash table to remember the full pathnames of executable
3399 .B "SHELL BUILTIN COMMANDS"
3401 A full search of the directories in
3404 is performed only if the command is not found in the hash table.
3405 If the search is unsuccessful, the shell prints an error
3406 message and returns an exit status of 127.
3408 If the search is successful, or if the command name contains
3409 one or more slashes, the shell executes the named program in a
3410 separate execution environment.
3411 Argument 0 is set to the name given, and the remaining arguments
3412 to the command are set to the arguments given, if any.
3414 If this execution fails because the file is not in executable
3415 format, and the file is not a directory, it is assumed to be
3416 a \fIshell script\fP, a file
3417 containing shell commands. A subshell is spawned to execute
3418 it. This subshell reinitializes itself, so
3419 that the effect is as if a new shell had been invoked
3420 to handle the script, with the exception that the locations of
3421 commands remembered by the parent (see
3425 \fBSHELL BUILTIN COMMANDS\fP)
3426 are retained by the child.
3428 If the program is a file beginning with
3430 the remainder of the first line specifies an interpreter
3431 for the program. The shell executes the
3432 specified interpreter on operating systems that do not
3433 handle this executable format themselves. The arguments to the
3434 interpreter consist of a single optional argument following the
3435 interpreter name on the first line of the program, followed
3436 by the name of the program, followed by the command
3438 .SH COMMAND EXECUTION ENVIRONMENT
3439 The shell has an \fIexecution environment\fP, which consists of the
3443 open files inherited by the shell at invocation, as modified by
3444 redirections supplied to the \fBexec\fP builtin
3446 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
3447 \fBpopd\fP, or inherited by the shell at invocation
3449 the file creation mode mask as set by \fBumask\fP or inherited from
3452 current traps set by \fBtrap\fP
3454 shell parameters that are set by variable assignment or with \fBset\fP
3455 or inherited from the shell's parent in the environment
3457 shell functions defined during execution or inherited from the shell's
3458 parent in the environment
3460 options enabled at invocation (either by default or with command-line
3461 arguments) or by \fBset\fP
3463 options enabled by \fBshopt\fP
3465 shell aliases defined with \fBalias\fP
3467 various process IDs, including those of background jobs, the value
3468 of \fB$$\fP, and the value of \fB$PPID\fP
3470 When a simple command other than a builtin or shell function
3471 is to be executed, it
3472 is invoked in a separate execution environment that consists of
3473 the following. Unless otherwise noted, the values are inherited
3477 the shell's open files, plus any modifications and additions specified
3478 by redirections to the command
3480 the current working directory
3482 the file creation mode mask
3484 shell variables marked for export, along with variables exported for
3485 the command, passed in the environment
3487 traps caught by the shell are reset to the values the inherited
3488 from the shell's parent, and traps ignored by the shell are ignored
3490 A command invoked in this separate environment cannot affect the
3491 shell's execution environment.
3493 Command substitution and asynchronous commands are invoked in a
3494 subshell environment that is a duplicate of the shell environment,
3495 except that traps caught by the shell are reset to the values
3496 that the shell inherited from its parent at invocation. Builtin
3497 commands that are invoked as part of a pipeline are also executed in a
3498 subshell environment. Changes made to the subshell environment
3499 cannot affect the shell's execution environment.
3501 If a command is followed by a \fB&\fP and job control is not active, the
3502 default standard input for the command is the empty file \fI/dev/null\fP.
3503 Otherwise, the invoked command inherits the file descriptors of the calling
3504 shell as modified by redirections.
3506 When a program is invoked it is given an array of strings
3510 \fIname\fP\-\fIvalue\fP pairs, of the form
3511 .IR "name\fR=\fPvalue" .
3513 The shell provides several ways to manipulate the environment.
3514 On invocation, the shell scans its own environment and
3515 creates a parameter for each name found, automatically marking
3518 to child processes. Executed commands inherit the environment.
3523 commands allow parameters and functions to be added to and
3524 deleted from the environment. If the value of a parameter
3525 in the environment is modified, the new value becomes part
3526 of the environment, replacing the old. The environment
3527 inherited by any executed command consists of the shell's
3528 initial environment, whose values may be modified in the shell,
3529 less any pairs removed by the
3531 command, plus any additions via the
3537 The environment for any
3539 or function may be augmented temporarily by prefixing it with
3540 parameter assignments, as described above in
3543 These assignment statements affect only the environment seen
3548 option is set (see the
3550 builtin command below), then
3552 parameter assignments are placed in the environment for a command,
3553 not just those that precede the command name.
3557 invokes an external command, the variable
3559 is set to the full file name of the command and passed to that
3560 command in its environment.
3562 For the shell's purposes, a command which exits with a
3563 zero exit status has succeeded. An exit status of zero
3564 indicates success. A non-zero exit status indicates failure.
3565 When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
3566 the value of 128+\fIN\fP as the exit status.
3568 If a command is not found, the child process created to
3569 execute it returns a status of 127. If a command is found
3570 but is not executable, the return status is 126.
3572 If a command fails because of an error during expansion or redirection,
3573 the exit status is greater than zero.
3575 Shell builtin commands return a status of 0 (\fItrue\fP) if
3576 successful, and non-zero (\fIfalse\fP) if an error occurs
3578 All builtins return an exit status of 2 to indicate incorrect usage.
3580 \fBBash\fP itself returns the exit status of the last command
3581 executed, unless a syntax error occurs, in which case it exits
3582 with a non-zero value. See also the \fBexit\fP builtin
3585 When \fBbash\fP is interactive, in the absence of any traps, it ignores
3588 (so that \fBkill 0\fP does not kill an interactive shell),
3592 is caught and handled (so that the \fBwait\fP builtin is interruptible).
3593 In all cases, \fBbash\fP ignores
3596 If job control is in effect,
3607 Synchronous jobs started by \fBbash\fP have signal handlers
3608 set to the values inherited by the shell from its parent.
3609 When job control is not in effect, asynchronous commands
3617 Commands run as a result of command substitution ignore the
3618 keyboard-generated job control signals
3627 The shell exits by default upon receipt of a
3630 Before exiting, an interactive shell resends the
3633 to all jobs, running or stopped.
3634 Stopped jobs are sent
3637 to ensure that they receive the
3640 To prevent the shell from
3641 sending the signal to a particular job, it should be removed from the
3646 .B "SHELL BUILTIN COMMANDS"
3656 shell option has been set with
3662 to all jobs when an interactive login shell exits.
3664 When \fBbash\fP receives a signal for which a trap has been set while
3665 waiting for a command to complete, the trap will not be executed until
3666 the command completes.
3667 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
3668 builtin, the reception of a signal for which a trap has been set will
3669 cause the \fBwait\fP builtin to return immediately with an exit status
3670 greater than 128, immediately after which the trap is executed.
3673 refers to the ability to selectively stop (\fIsuspend\fP)
3674 the execution of processes and continue (\fIresume\fP)
3675 their execution at a later point. A user typically employs
3676 this facility via an interactive interface supplied jointly
3677 by the system's terminal driver and
3680 The shell associates a
3682 with each pipeline. It keeps a table of currently executing
3683 jobs, which may be listed with the
3687 starts a job asynchronously (in the
3689 it prints a line that looks like:
3695 indicating that this job is job number 1 and that the process ID
3696 of the last process in the pipeline associated with this job is 25647.
3697 All of the processes in a single pipeline are members of the same job.
3701 abstraction as the basis for job control.
3703 To facilitate the implementation of the user interface to job
3704 control, the operating system maintains the notion of a \fIcurrent terminal
3705 process group ID\fP. Members of this process group (processes whose
3706 process group ID is equal to the current terminal process group ID)
3707 receive keyboard-generated signals such as
3710 These processes are said to be in the
3713 processes are those whose process group ID differs from the terminal's;
3714 such processes are immune to keyboard-generated signals.
3715 Only foreground processes are allowed to read from or write to the
3716 terminal. Background processes which attempt to read from (write to) the
3719 .B SIGTTIN (SIGTTOU)
3720 signal by the terminal driver,
3721 which, unless caught, suspends the process.
3723 If the operating system on which
3728 contains facilities to use it.
3731 character (typically
3733 Control-Z) while a process is running
3734 causes that process to be stopped and returns control to
3737 .I "delayed suspend"
3738 character (typically
3740 Control-Y) causes the process to be stopped when it
3741 attempts to read input from the terminal, and control to
3744 The user may then manipulate the state of this job, using the
3746 command to continue it in the background, the
3748 command to continue it in the foreground, or
3751 command to kill it. A \fB^Z\fP takes effect immediately,
3752 and has the additional side effect of causing pending output
3753 and typeahead to be discarded.
3755 There are a number of ways to refer to a job in the shell.
3758 introduces a job name. Job number
3760 may be referred to as
3762 A job may also be referred to using a prefix of the name used to
3763 start it, or using a substring that appears in its command line.
3768 job. If a prefix matches more than one job,
3770 reports an error. Using
3772 on the other hand, refers to any job containing the string
3774 in its command line. If the substring matches more than one job,
3776 reports an error. The symbols
3780 refer to the shell's notion of the
3782 which is the last job stopped while it was in
3783 the foreground or started in the background.
3786 may be referenced using
3788 In output pertaining to jobs (e.g., the output of the
3790 command), the current job is always flagged with a
3792 and the previous job with a
3795 Simply naming a job can be used to bring it into the
3800 bringing job 1 from the background into the foreground.
3803 resumes job 1 in the background, equivalent to
3806 The shell learns immediately whenever a job changes state.
3809 waits until it is about to print a prompt before reporting
3810 changes in a job's status so as to not interrupt
3811 any other output. If the
3818 reports such changes immediately.
3822 is executed for each child that exits.
3824 If an attempt to exit
3826 is made while jobs are stopped, the shell prints a warning message. The
3828 command may then be used to inspect their status.
3829 If a second attempt to exit is made without an intervening command,
3830 the shell does not print another warning, and the stopped
3831 jobs are terminated.
3833 When executing interactively,
3835 displays the primary prompt
3838 when it is ready to read a command, and the secondary prompt
3841 when it needs more input to complete a command.
3843 allows these prompt strings to be customized by inserting a number of
3844 backslash-escaped special characters that are decoded as follows:
3849 an ASCII bell character (07)
3852 the date in "Weekday Month Date" format (e.g., "Tue May 26")
3855 an ASCII escape character (033)
3858 the hostname up to the first `.'
3864 the number of jobs currently managed by the shell
3867 the basename of the shell's terminal device name
3876 the name of the shell, the basename of
3878 (the portion following the final slash)
3881 the current time in 24-hour HH:MM:SS format
3884 the current time in 12-hour HH:MM:SS format
3887 the current time in 12-hour am/pm format
3890 the current time in 24-hour HH:MM format
3893 the username of the current user
3896 the version of \fBbash\fP (e.g., 2.00)
3899 the release of \fBbash\fP, version + patchelvel (e.g., 2.00.0)
3902 the current working directory
3905 the basename of the current working directory
3908 the history number of this command
3911 the command number of this command
3914 if the effective UID is 0, a
3920 the character corresponding to the octal number \fInnn\fP
3926 begin a sequence of non-printing characters, which could be used to
3927 embed a terminal control sequence into the prompt
3930 end a sequence of non-printing characters
3934 The command number and the history number are usually different:
3935 the history number of a command is its position in the history
3936 list, which may include commands restored from the history file
3940 below), while the command number is the position in the sequence
3941 of commands executed during the current shell session.
3942 After the string is decoded, it is expanded via
3943 parameter expansion, command substitution, arithmetic
3944 expansion, and quote removal, subject to the value of the
3946 shell option (see the description of the
3950 .B "SHELL BUILTIN COMMANDS"
3953 This is the library that handles reading input when using an interactive
3956 option is given at shell invocation.
3957 By default, the line editing commands are similar to those of emacs.
3958 A vi-style line editing interface is also available.
3959 To turn off line editing after the shell is running, use the
3967 .B SHELL BUILTIN COMMANDS
3969 .SS "Readline Notation"
3971 In this section, the emacs-style notation is used to denote
3972 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
3973 means Control\-N. Similarly,
3975 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
3978 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
3981 key. This makes ESC the \fImeta prefix\fP.
3982 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
3983 or press the Escape key
3984 then hold the Control key while pressing the
3988 Readline commands may be given numeric
3990 which normally act as a repeat count.
3991 Sometimes, however, it is the sign of the argument that is significant.
3992 Passing a negative argument to a command that acts in the forward
3993 direction (e.g., \fBkill\-line\fP) causes that command to act in a
3995 Commands whose behavior with arguments deviates from this are noted
3998 When a command is described as \fIkilling\fP text, the text
3999 deleted is saved for possible future retrieval
4000 (\fIyanking\fP). The killed text is saved in a
4001 \fIkill ring\fP. Consecutive kills cause the text to be
4002 accumulated into one unit, which can be yanked all at once.
4003 Commands which do not kill text separate the chunks of text
4005 .SS "Readline Initialization"
4007 Readline is customized by putting commands in an initialization
4008 file (the \fIinputrc\fP file).
4009 The name of this file is taken from the value of the
4012 variable. If that variable is unset, the default is
4014 When a program which uses the readline library starts up, the
4015 initialization file is read, and the key bindings and variables
4017 There are only a few basic constructs allowed in the
4018 readline initialization file.
4019 Blank lines are ignored.
4020 Lines beginning with a \fB#\fP are comments.
4021 Lines beginning with a \fB$\fP indicate conditional constructs.
4022 Other lines denote key bindings and variable settings.
4024 The default key-bindings may be changed with an
4027 Other programs that use this library may add their own commands
4030 For example, placing
4033 M\-Control\-u: universal\-argument
4037 C\-Meta\-u: universal\-argument
4041 would make M\-C\-u execute the readline command
4042 .IR universal\-argument .
4044 The following symbolic character names are recognized:
4057 In addition to command names, readline allows keys to be bound
4058 to a string that is inserted when the key is pressed (a \fImacro\fP).
4059 .SS "Readline Key Bindings"
4061 The syntax for controlling key bindings in the
4063 file is simple. All that is required is the name of the
4064 command or the text of a macro and a key sequence to which
4065 it should be bound. The name may be specified in one of two ways:
4066 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
4067 prefixes, or as a key sequence.
4069 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4071 is the name of a key spelled out in English. For example:
4074 Control-u: universal\-argument
4076 Meta-Rubout: backward-kill-word
4078 Control-o: "> output"
4081 In the above example,
4083 is bound to the function
4084 .BR universal\-argument ,
4086 is bound to the function
4087 .BR backward\-kill\-word ,
4090 is bound to run the macro
4091 expressed on the right hand side (that is, to insert the text
4092 .if t \f(CW> output\fP
4096 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4100 above in that strings denoting
4101 an entire key sequence may be specified by placing the sequence
4102 within double quotes. Some GNU Emacs style key escapes can be
4103 used, as in the following example, but the symbolic character names
4107 "\eC\-u": universal\-argument
4109 "\eC\-x\eC\-r": re\-read\-init\-file
4111 "\ee[11~": "Function Key 1"
4116 is again bound to the function
4117 .BR universal\-argument .
4119 is bound to the function
4120 .BR re\-read\-init\-file ,
4123 is bound to insert the text
4124 .if t \f(CWFunction Key 1\fP.
4125 .if n ``Function Key 1''.
4127 The full set of GNU Emacs style escape sequences is
4151 In addition to the GNU Emacs style escape sequences, a second
4152 set of backslash escapes is available:
4181 the eight-bit character whose value is the octal value \fInnn\fP
4182 (one to three digits)
4185 the eight-bit character whose value is the hexadecimal value \fIHH\fP
4186 (one or two hex digits)
4190 When entering the text of a macro, single or double quotes must
4191 be used to indicate a macro definition.
4192 Unquoted text is assumed to be a function name.
4193 In the macro body, the backslash escapes described above are expanded.
4194 Backslash will quote any other character in the macro text,
4198 allows the current readline key bindings to be displayed or modified
4201 builtin command. The editing mode may be switched during interactive
4206 builtin command (see
4208 .B SHELL BUILTIN COMMANDS
4210 .SS "Readline Variables"
4212 Readline has variables that can be used to further customize its
4213 behavior. A variable may be set in the
4215 file with a statement of the form
4218 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
4221 Except where noted, readline variables can take the values
4225 The variables and their default values are:
4229 .B bell\-style (audible)
4230 Controls what happens when readline wants to ring the terminal bell.
4231 If set to \fBnone\fP, readline never rings the bell. If set to
4232 \fBvisible\fP, readline uses a visible bell if one is available.
4233 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
4235 .B comment\-begin (``#'')
4236 The string that is inserted when the readline
4238 command is executed.
4239 This command is bound to
4241 in emacs mode and to
4245 .B completion\-ignore\-case (Off)
4246 If set to \fBOn\fP, readline performs filename matching and completion
4247 in a case\-insensitive fashion.
4249 .B completion\-query\-items (100)
4250 This determines when the user is queried about viewing
4251 the number of possible completions
4252 generated by the \fBpossible\-completions\fP command.
4253 It may be set to any integer value greater than or equal to
4254 zero. If the number of possible completions is greater than
4255 or equal to the value of this variable, the user is asked whether
4256 or not he wishes to view them; otherwise they are simply listed
4259 .B convert\-meta (On)
4260 If set to \fBOn\fP, readline will convert characters with the
4261 eighth bit set to an ASCII key sequence
4262 by stripping the eighth bit and prefixing an
4263 escape character (in effect, using escape as the \fImeta prefix\fP).
4265 .B disable\-completion (Off)
4266 If set to \fBOn\fP, readline will inhibit word completion. Completion
4267 characters will be inserted into the line as if they had been
4268 mapped to \fBself-insert\fP.
4270 .B editing\-mode (emacs)
4271 Controls whether readline begins with a set of key bindings similar
4272 to \fIemacs\fP or \fIvi\fP.
4274 can be set to either
4279 .B enable\-keypad (Off)
4280 When set to \fBOn\fP, readline will try to enable the application
4281 keypad when it is called. Some systems need this to enable the
4284 .B expand\-tilde (Off)
4285 If set to \fBon\fP, tilde expansion is performed when readline
4286 attempts word completion.
4288 .B history-preserve-point
4289 If set to \fBon\fP, the history code attempts to place point at the
4290 same location on each history line retrived with \fBprevious-history\fP
4291 or \fBnext-history\fP.
4293 .B horizontal\-scroll\-mode (Off)
4294 When set to \fBOn\fP, makes readline use a single line for display,
4295 scrolling the input horizontally on a single screen line when it
4296 becomes longer than the screen width rather than wrapping to a new line.
4298 .B input\-meta (Off)
4299 If set to \fBOn\fP, readline will enable eight-bit input (that is,
4300 it will not strip the high bit from the characters it reads),
4301 regardless of what the terminal claims it can support. The name
4303 is a synonym for this variable.
4305 .B isearch\-terminators (``C\-[C\-J'')
4306 The string of characters that should terminate an incremental
4307 search without subsequently executing the character as a command.
4308 If this variable has not been given a value, the characters
4309 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
4312 Set the current readline keymap. The set of valid keymap names is
4313 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4316 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4317 equivalent to \fIemacs\-standard\fP. The default value is
4321 also affects the default keymap.
4323 .B mark\-directories (On)
4324 If set to \fBOn\fP, completed directory names have a slash
4327 .B mark\-modified\-lines (Off)
4328 If set to \fBOn\fP, history lines that have been modified are displayed
4329 with a preceding asterisk (\fB*\fP).
4331 .B match\-hidden\-files (On)
4332 This variable, when set to \fBOn\fP, causes readline to match files whose
4333 names begin with a `.' (hidden files) when performing filename
4334 completion, unless the leading `.' is
4335 supplied by the user in the filename to be completed.
4337 .B output\-meta (Off)
4338 If set to \fBOn\fP, readline will display characters with the
4339 eighth bit set directly rather than as a meta-prefixed escape
4342 .B print\-completions\-horizontally (Off)
4343 If set to \fBOn\fP, readline will display completions with matches
4344 sorted horizontally in alphabetical order, rather than down the screen.
4346 .B show\-all\-if\-ambiguous (Off)
4347 This alters the default behavior of the completion functions. If
4350 words which have more than one possible completion cause the
4351 matches to be listed immediately instead of ringing the bell.
4353 .B visible\-stats (Off)
4354 If set to \fBOn\fP, a character denoting a file's type as reported
4355 by \fIstat\fP(2) is appended to the filename when listing possible
4358 .SS "Readline Conditional Constructs"
4360 Readline implements a facility similar in spirit to the conditional
4361 compilation features of the C preprocessor which allows key
4362 bindings and variable settings to be performed as the result
4363 of tests. There are four parser directives used.
4367 construct allows bindings to be made based on the
4368 editing mode, the terminal being used, or the application using
4369 readline. The text of the test extends to the end of the line;
4370 no characters are required to isolate it.
4373 The \fBmode=\fP form of the \fB$if\fP directive is used to test
4374 whether readline is in emacs or vi mode.
4375 This may be used in conjunction
4376 with the \fBset keymap\fP command, for instance, to set bindings in
4377 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
4378 readline is starting out in emacs mode.
4380 The \fBterm=\fP form may be used to include terminal-specific
4381 key bindings, perhaps to bind the key sequences output by the
4382 terminal's function keys. The word on the right side of the
4384 is tested against the both full name of the terminal and the portion
4385 of the terminal name before the first \fB\-\fP. This allows
4392 .IP \fBapplication\fP
4393 The \fBapplication\fP construct is used to include
4394 application-specific settings. Each program using the readline
4395 library sets the \fIapplication name\fP, and an initialization
4396 file can test for a particular value.
4397 This could be used to bind key sequences to functions useful for
4398 a specific program. For instance, the following command adds a
4399 key sequence that quotes the current or previous word in Bash:
4404 # Quote the current or previous word
4405 "\eC\-xq": "\eeb\e"\eef\e""
4411 This command, as seen in the previous example, terminates an
4414 Commands in this branch of the \fB$if\fP directive are executed if
4417 This directive takes a single filename as an argument and reads commands
4418 and bindings from that file. For example, the following directive
4419 would read \fI/etc/inputrc\fP:
4423 \fB$include\fP \^ \fI/etc/inputrc\fP
4428 Readline provides commands for searching through the command history
4432 below) for lines containing a specified string.
4433 There are two search modes:
4436 .IR non-incremental .
4438 Incremental searches begin before the user has finished typing the
4440 As each character of the search string is typed, readline displays
4441 the next entry from the history matching the string typed so far.
4442 An incremental search requires only as many characters as needed to
4443 find the desired history entry.
4444 The characters present in the value of the \fBisearch-terminators\fP
4445 variable are used to terminate an incremental search.
4446 If that variable has not been assigned a value the Escape and
4447 Control-J characters will terminate an incremental search.
4448 Control-G will abort an incremental search and restore the original
4450 When the search is terminated, the history entry containing the
4451 search string becomes the current line.
4453 To find other matching entries in the history list, type Control-S or
4454 Control-R as appropriate.
4455 This will search backward or forward in the history for the next
4456 entry matching the search string typed so far.
4457 Any other key sequence bound to a readline command will terminate
4458 the search and execute that command.
4459 For instance, a \fInewline\fP will terminate the search and accept
4460 the line, thereby executing the command from the history list.
4462 Readline remembers the last incremental search string. If two
4463 Control-Rs are typed without any intervening characters defining a
4464 new search string, any remembered search string is used.
4466 Non-incremental searches read the entire search string before starting
4467 to search for matching history lines. The search string may be
4468 typed by the user or be part of the contents of the current line.
4469 .SS "Readline Command Names"
4471 The following is a list of the names of the commands and the default
4472 key sequences to which they are bound.
4473 Command names without an accompanying key sequence are unbound by default.
4474 In the following descriptions, \fIpoint\fP refers to the current cursor
4475 position, and \fImark\fP refers to a cursor position saved by the
4476 \fBset\-mark\fP command.
4477 The text between the point and mark is referred to as the \fIregion\fP.
4478 .SS Commands for Moving
4482 .B beginning\-of\-line (C\-a)
4483 Move to the start of the current line.
4485 .B end\-of\-line (C\-e)
4486 Move to the end of the line.
4488 .B forward\-char (C\-f)
4489 Move forward a character.
4491 .B backward\-char (C\-b)
4492 Move back a character.
4494 .B forward\-word (M\-f)
4495 Move forward to the end of the next word. Words are composed of
4496 alphanumeric characters (letters and digits).
4498 .B backward\-word (M\-b)
4499 Move back to the start of the current or previous word. Words are
4500 composed of alphanumeric characters (letters and digits).
4502 .B clear\-screen (C\-l)
4503 Clear the screen leaving the current line at the top of the screen.
4504 With an argument, refresh the current line without clearing the
4507 .B redraw\-current\-line
4508 Refresh the current line.
4510 .SS Commands for Manipulating the History
4514 .B accept\-line (Newline, Return)
4515 Accept the line regardless of where the cursor is. If this line is
4516 non-empty, add it to the history list according to the state of the
4519 variable. If the line is a modified history
4520 line, then restore the history line to its original state.
4522 .B previous\-history (C\-p)
4523 Fetch the previous command from the history list, moving back in
4526 .B next\-history (C\-n)
4527 Fetch the next command from the history list, moving forward in the
4530 .B beginning\-of\-history (M\-<)
4531 Move to the first line in the history.
4533 .B end\-of\-history (M\->)
4534 Move to the end of the input history, i.e., the line currently being
4537 .B reverse\-search\-history (C\-r)
4538 Search backward starting at the current line and moving `up' through
4539 the history as necessary. This is an incremental search.
4541 .B forward\-search\-history (C\-s)
4542 Search forward starting at the current line and moving `down' through
4543 the history as necessary. This is an incremental search.
4545 .B non\-incremental\-reverse\-search\-history (M\-p)
4546 Search backward through the history starting at the current line
4547 using a non-incremental search for a string supplied by the user.
4549 .B non\-incremental\-forward\-search\-history (M\-n)
4550 Search forward through the history using a non-incremental search for
4551 a string supplied by the user.
4553 .B history\-search\-forward
4554 Search forward through the history for the string of characters
4555 between the start of the current line and the point.
4556 This is a non-incremental search.
4558 .B history\-search\-backward
4559 Search backward through the history for the string of characters
4560 between the start of the current line and the point.
4561 This is a non-incremental search.
4563 .B yank\-nth\-arg (M\-C\-y)
4564 Insert the first argument to the previous command (usually
4565 the second word on the previous line) at point.
4568 insert the \fIn\fPth word from the previous command (the words
4569 in the previous command begin with word 0). A negative argument
4570 inserts the \fIn\fPth word from the end of the previous command.
4573 yank\-last\-arg (M\-.\^, M\-_\^)
4574 Insert the last argument to the previous command (the last word of
4575 the previous history entry). With an argument,
4576 behave exactly like \fByank\-nth\-arg\fP.
4577 Successive calls to \fByank\-last\-arg\fP move back through the history
4578 list, inserting the last argument of each line in turn.
4580 .B shell\-expand\-line (M\-C\-e)
4581 Expand the line as the shell does. This
4582 performs alias and history expansion as well as all of the shell
4583 word expansions. See
4585 .B HISTORY EXPANSION
4586 below for a description of history expansion.
4588 .B history\-expand\-line (M\-^)
4589 Perform history expansion on the current line.
4592 .B HISTORY EXPANSION
4593 below for a description of history expansion.
4596 Perform history expansion on the current line and insert a space.
4599 .B HISTORY EXPANSION
4600 below for a description of history expansion.
4602 .B alias\-expand\-line
4603 Perform alias expansion on the current line.
4607 above for a description of alias expansion.
4609 .B history\-and\-alias\-expand\-line
4610 Perform history and alias expansion on the current line.
4612 .B insert\-last\-argument (M\-.\^, M\-_\^)
4613 A synonym for \fByank\-last\-arg\fP.
4615 .B operate\-and\-get\-next (C\-o)
4616 Accept the current line for execution and fetch the next line
4617 relative to the current line from the history for editing. Any
4618 argument is ignored.
4620 .SS Commands for Changing Text
4624 .B delete\-char (C\-d)
4625 Delete the character at point. If point is at the
4626 beginning of the line, there are no characters in the line, and
4627 the last character typed was not bound to \fBdelete\-char\fP,
4632 .B backward\-delete\-char (Rubout)
4633 Delete the character behind the cursor. When given a numeric argument,
4634 save the deleted text on the kill ring.
4636 .B forward\-backward\-delete\-char
4637 Delete the character under the cursor, unless the cursor is at the
4638 end of the line, in which case the character behind the cursor is
4641 .B quoted\-insert (C\-q, C\-v)
4642 Add the next character typed to the line verbatim. This is
4643 how to insert characters like \fBC\-q\fP, for example.
4645 .B tab\-insert (C\-v TAB)
4646 Insert a tab character.
4648 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
4649 Insert the character typed.
4651 .B transpose\-chars (C\-t)
4652 Drag the character before point forward over the character at point,
4653 moving point forward as well.
4654 If point is at the end of the line, then this transposes
4655 the two characters before point.
4656 Negative arguments have no effect.
4658 .B transpose\-words (M\-t)
4659 Drag the word before point past the word after point,
4660 moving point over that word as well.
4661 If point is at the end of the line, this transposes
4662 the last two words on the line.
4664 .B upcase\-word (M\-u)
4665 Uppercase the current (or following) word. With a negative argument,
4666 uppercase the previous word, but do not move point.
4668 .B downcase\-word (M\-l)
4669 Lowercase the current (or following) word. With a negative argument,
4670 lowercase the previous word, but do not move point.
4672 .B capitalize\-word (M\-c)
4673 Capitalize the current (or following) word. With a negative argument,
4674 capitalize the previous word, but do not move point.
4676 .SS Killing and Yanking
4680 .B kill\-line (C\-k)
4681 Kill the text from point to the end of the line.
4683 .B backward\-kill\-line (C\-x Rubout)
4684 Kill backward to the beginning of the line.
4686 .B unix\-line\-discard (C\-u)
4687 Kill backward from point to the beginning of the line.
4688 The killed text is saved on the kill-ring.
4689 .\" There is no real difference between this and backward-kill-line
4691 .B kill\-whole\-line
4692 Kill all characters on the current line, no matter where point is.
4694 .B kill\-word (M\-d)
4695 Kill from point to the end of the current word, or if between
4696 words, to the end of the next word.
4697 Word boundaries are the same as those used by \fBforward\-word\fP.
4699 .B backward\-kill\-word (M\-Rubout)
4700 Kill the word behind point.
4701 Word boundaries are the same as those used by \fBbackward\-word\fP.
4703 .B unix\-word\-rubout (C\-w)
4704 Kill the word behind point, using white space as a word boundary.
4705 The killed text is saved on the kill-ring.
4707 .B delete\-horizontal\-space (M\-\e)
4708 Delete all spaces and tabs around point.
4711 Kill the text in the current region.
4713 .B copy\-region\-as\-kill
4714 Copy the text in the region to the kill buffer.
4716 .B copy\-backward\-word
4717 Copy the word before point to the kill buffer.
4718 The word boundaries are the same as \fBbackward\-word\fP.
4720 .B copy\-forward\-word
4721 Copy the word following point to the kill buffer.
4722 The word boundaries are the same as \fBforward\-word\fP.
4725 Yank the top of the kill ring into the buffer at point.
4728 Rotate the kill ring, and yank the new top. Only works following
4733 .SS Numeric Arguments
4737 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
4738 Add this digit to the argument already accumulating, or start a new
4739 argument. M\-\- starts a negative argument.
4741 .B universal\-argument
4742 This is another way to specify an argument.
4743 If this command is followed by one or more digits, optionally with a
4744 leading minus sign, those digits define the argument.
4745 If the command is followed by digits, executing
4746 .B universal\-argument
4747 again ends the numeric argument, but is otherwise ignored.
4748 As a special case, if this command is immediately followed by a
4749 character that is neither a digit or minus sign, the argument count
4750 for the next command is multiplied by four.
4751 The argument count is initially one, so executing this function the
4752 first time makes the argument count four, a second time makes the
4753 argument count sixteen, and so on.
4760 Attempt to perform completion on the text before point.
4762 attempts completion treating the text as a variable (if the
4763 text begins with \fB$\fP), username (if the text begins with
4764 \fB~\fP), hostname (if the text begins with \fB@\fP), or
4765 command (including aliases and functions) in turn. If none
4766 of these produces a match, filename completion is attempted.
4768 .B possible\-completions (M\-?)
4769 List the possible completions of the text before point.
4771 .B insert\-completions (M\-*)
4772 Insert all completions of the text before point
4773 that would have been generated by
4774 \fBpossible\-completions\fP.
4777 Similar to \fBcomplete\fP, but replaces the word to be completed
4778 with a single match from the list of possible completions.
4779 Repeated execution of \fBmenu\-complete\fP steps through the list
4780 of possible completions, inserting each match in turn.
4781 At the end of the list of completions, the bell is rung
4782 (subject to the setting of \fBbell\-style\fP)
4783 and the original text is restored.
4784 An argument of \fIn\fP moves \fIn\fP positions forward in the list
4785 of matches; a negative argument may be used to move backward
4787 This command is intended to be bound to \fBTAB\fP, but is unbound
4790 .B delete\-char\-or\-list
4791 Deletes the character under the cursor if not at the beginning or
4792 end of the line (like \fBdelete\-char\fP).
4793 If at the end of the line, behaves identically to
4794 \fBpossible\-completions\fP.
4795 This command is unbound by default.
4797 .B complete\-filename (M\-/)
4798 Attempt filename completion on the text before point.
4800 .B possible\-filename\-completions (C\-x /)
4801 List the possible completions of the text before point,
4802 treating it as a filename.
4804 .B complete\-username (M\-~)
4805 Attempt completion on the text before point, treating
4808 .B possible\-username\-completions (C\-x ~)
4809 List the possible completions of the text before point,
4810 treating it as a username.
4812 .B complete\-variable (M\-$)
4813 Attempt completion on the text before point, treating
4814 it as a shell variable.
4816 .B possible\-variable\-completions (C\-x $)
4817 List the possible completions of the text before point,
4818 treating it as a shell variable.
4820 .B complete\-hostname (M\-@)
4821 Attempt completion on the text before point, treating
4824 .B possible\-hostname\-completions (C\-x @)
4825 List the possible completions of the text before point,
4826 treating it as a hostname.
4828 .B complete\-command (M\-!)
4829 Attempt completion on the text before point, treating
4830 it as a command name. Command completion attempts to
4831 match the text against aliases, reserved words, shell
4832 functions, shell builtins, and finally executable filenames,
4835 .B possible\-command\-completions (C\-x !)
4836 List the possible completions of the text before point,
4837 treating it as a command name.
4839 .B dynamic\-complete\-history (M\-TAB)
4840 Attempt completion on the text before point, comparing
4841 the text against lines from the history list for possible
4844 .B complete\-into\-braces (M\-{)
4845 Perform filename completion and insert the list of possible completions
4846 enclosed within braces so the list is available to the shell (see
4854 .B start\-kbd\-macro (C\-x (\^)
4855 Begin saving the characters typed into the current keyboard macro.
4857 .B end\-kbd\-macro (C\-x )\^)
4858 Stop saving the characters typed into the current keyboard macro
4859 and store the definition.
4861 .B call\-last\-kbd\-macro (C\-x e)
4862 Re-execute the last keyboard macro defined, by making the characters
4863 in the macro appear as if typed at the keyboard.
4869 .B re\-read\-init\-file (C\-x C\-r)
4870 Read in the contents of the \fIinputrc\fP file, and incorporate
4871 any bindings or variable assignments found there.
4874 Abort the current editing command and
4875 ring the terminal's bell (subject to the setting of
4878 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
4879 If the metafied character \fIx\fP is lowercase, run the command
4880 that is bound to the corresponding uppercase character.
4882 .B prefix\-meta (ESC)
4883 Metafy the next character typed.
4890 .B undo (C\-_, C\-x C\-u)
4891 Incremental undo, separately remembered for each line.
4893 .B revert\-line (M\-r)
4894 Undo all changes made to this line. This is like executing the
4896 command enough times to return the line to its initial state.
4898 .B tilde\-expand (M\-&)
4899 Perform tilde expansion on the current word.
4901 .B set\-mark (C\-@, M\-<space>)
4902 Set the mark to the point. If a
4903 numeric argument is supplied, the mark is set to that position.
4905 .B exchange\-point\-and\-mark (C\-x C\-x)
4906 Swap the point with the mark. The current cursor position is set to
4907 the saved position, and the old cursor position is saved as the mark.
4909 .B character\-search (C\-])
4910 A character is read and point is moved to the next occurrence of that
4911 character. A negative count searches for previous occurrences.
4913 .B character\-search\-backward (M\-C\-])
4914 A character is read and point is moved to the previous occurrence of that
4915 character. A negative count searches for subsequent occurrences.
4917 .B insert\-comment (M\-#)
4918 The value of the readline
4920 variable is inserted at the beginning of the current line, and the line
4921 is accepted as if a newline had been typed. The default value of
4922 \fBcomment\-begin\fP causes this command to make the current line
4925 .B glob\-expand\-word (C\-x *)
4926 The word before point is treated as a pattern for pathname expansion,
4927 and the list of matching file names is inserted, replacing the word.
4929 .B glob\-list\-expansions (C\-x g)
4930 The list of expansions that would have been generated by
4931 .B glob\-expand\-word
4932 is displayed, and the line is redrawn.
4935 Print all of the functions and their key bindings to the
4936 readline output stream. If a numeric argument is supplied,
4937 the output is formatted in such a way that it can be made part
4938 of an \fIinputrc\fP file.
4941 Print all of the settable readline variables and their values to the
4942 readline output stream. If a numeric argument is supplied,
4943 the output is formatted in such a way that it can be made part
4944 of an \fIinputrc\fP file.
4947 Print all of the readline key sequences bound to macros and the
4948 strings they ouput. If a numeric argument is supplied,
4949 the output is formatted in such a way that it can be made part
4950 of an \fIinputrc\fP file.
4952 .B display\-shell\-version (C\-x C\-v)
4953 Display version information about the current instance of
4956 .SS Programmable Completion
4958 When word completion is attempted for an argument to a command for
4959 which a completion specification (a \fIcompspec\fP) has been defined
4960 using the \fBcomplete\fP builtin (see
4962 .B "SHELL BUILTIN COMMANDS"
4963 below), the programmable completion facilities are invoked.
4965 First, the command name is identified.
4966 If a compspec has been defined for that command, the
4967 compspec is used to generate the list of possible completions for the word.
4968 If the command word is a full pathname, a compspec for the full
4969 pathname is searched for first.
4970 If no compspec is found for the full pathname, an attempt is made to
4971 find a compspec for the portion following the final slash.
4973 Once a compspec has been found, it is used to generate the list of
4975 If a compspec is not found, the default \fBbash\fP completion as
4976 described above under \fBCompleting\fP is performed.
4978 First, the actions specified by the compspec are used.
4979 Only matches which are prefixed by the word being completed are
4985 option is used for filename or directory name completion, the shell
4989 is used to filter the matches.
4991 Any completions specified by a filename expansion pattern to the
4992 \fB\-G\fP option are generated next.
4993 The words generated by the pattern need not match the word
4998 shell variable is not used to filter the matches, but the
5003 Next, the string specified as the argument to the \fB\-W\fP option
5005 The string is first split using the characters in the
5008 special variable as delimiters.
5009 Shell quoting is honored.
5010 Each word is then expanded using
5011 brace expansion, tilde expansion, parameter and variable expansion,
5012 command substitution, arithmetic expansion, and pathname expansion,
5013 as described above under
5016 The results are split using the rules described above under
5017 \fBWord Splitting\fP.
5018 The results of the expansion are prefix-matched against the word being
5019 completed, and the matching words become the possible completions.
5021 After these matches have been generated, any shell function or command
5022 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
5023 When the command or function is invoked, the
5029 variables are assigned values as described above under
5030 \fBShell Variables\fP.
5031 If a shell function is being invoked, the
5037 variables are also set.
5038 When the function or command is invoked, the first argument is the
5039 name of the command whose arguments are being completed, the
5040 second argument is the word being completed, and the third argument
5041 is the word preceding the word being completed on the current command line.
5042 No filtering of the generated completions against the word being completed
5043 is performed; the function or command has complete freedom in generating
5046 Any function specified with \fB\-F\fP is invoked first.
5047 The function may use any of the shell facilities, including the
5048 \fBcompgen\fP builtin described below, to generate the matches.
5049 It must put the possible completions in the
5054 Next, any command specified with the \fB\-C\fP option is invoked
5055 in an environment equivalent to command substitution.
5056 It should print a list of completions, one per line, to the
5058 Backslash may be used to escape a newline, if necessary.
5060 After all of the possible completions are generated, any filter
5061 specified with the \fB\-X\fP option is applied to the list.
5062 The filter is a pattern as used for pathname expansion; a \fB&\fP
5063 in the pattern is replaced with the text of the word being completed.
5064 A literal \fB&\fP may be escaped with a backslash; the backslash
5065 is removed before attempting a match.
5066 Any completion that matches the pattern will be removed from the list.
5067 A leading \fB!\fP negates the pattern; in this case any completion
5068 not matching the pattern will be removed.
5070 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
5071 options are added to each member of the completion list, and the result is
5072 returned to the readline completion code as the list of possible
5075 If the previously-applied actions do not generate any matches, and the
5076 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
5077 compspec was defined, directory name completion is attempted.
5079 By default, if a compspec is found, whatever it generates is returned
5080 to the completion code as the full set of possible completions.
5081 The default \fBbash\fP completions are not attempted, and the readline
5082 default of filename completion is disabled.
5083 If the \fB-o default\fP option was supplied to \fBcomplete\fP when the
5084 compspec was defined, readline's default completion will be performed
5085 if the compspec generates no matches.
5091 builtin is enabled, the shell provides access to the
5092 \fIcommand history\fP,
5093 the list of commands previously typed.
5094 The value of the \fBHISTSIZE\fP variable is used as the
5095 number of commands to save in a history list.
5096 The text of the last
5099 commands (default 500) is saved. The shell
5100 stores each command in the history list prior to parameter and
5101 variable expansion (see
5104 above) but after history expansion is performed, subject to the
5105 values of the shell variables
5112 On startup, the history is initialized from the file named by
5116 (default \fI~/.bash_history\fP).
5117 The file named by the value of
5120 is truncated, if necessary, to contain no more than
5121 the number of lines specified by the value of
5124 When an interactive shell exits, the last
5127 lines are copied from the history list to
5132 shell option is enabled
5133 (see the description of
5137 .B "SHELL BUILTIN COMMANDS"
5138 below), the lines are appended to the history file,
5139 otherwise the history file is overwritten.
5143 is unset, or if the history file is unwritable, the history is
5144 not saved. After saving the history, the history file is truncated
5145 to contain no more than
5151 is not set, no truncation is performed.
5157 .B SHELL BUILTIN COMMANDS
5158 below) may be used to list or edit and re-execute a portion of
5162 builtin may be used to display or modify the history list and
5163 manipulate the history file.
5164 When using command-line editing, search commands
5165 are available in each editing mode that provide access to the
5168 The shell allows control over which commands are saved on the history
5175 variables may be set to cause the shell to save only a subset of the
5179 shell option, if enabled, causes the shell to attempt to save each
5180 line of a multi-line command in the same history entry, adding
5181 semicolons where necessary to preserve syntactic correctness.
5184 shell option causes the shell to save the command with embedded newlines
5185 instead of semicolons. See the description of the
5189 .B "SHELL BUILTIN COMMANDS"
5190 for information on setting and unsetting shell options.
5191 .SH "HISTORY EXPANSION"
5193 The shell supports a history expansion feature that
5194 is similar to the history expansion in
5196 This section describes what syntax features are available. This
5197 feature is enabled by default for interactive shells, and can be
5202 builtin command (see
5204 .B SHELL BUILTIN COMMANDS
5205 below). Non-interactive shells do not perform history expansion
5208 History expansions introduce words from the history list into
5209 the input stream, making it easy to repeat commands, insert the
5210 arguments to a previous command into the current input line, or
5211 fix errors in previous commands quickly.
5213 History expansion is performed immediately after a complete line
5214 is read, before the shell breaks it into words.
5215 It takes place in two parts.
5216 The first is to determine which line from the history list
5217 to use during substitution.
5218 The second is to select portions of that line for inclusion into
5220 The line selected from the history is the \fIevent\fP,
5221 and the portions of that line that are acted upon are \fIwords\fP.
5222 Various \fImodifiers\fP are available to manipulate the selected words.
5223 The line is broken into words in the same fashion as when reading input,
5224 so that several \fImetacharacter\fP-separated words surrounded by
5225 quotes are considered one word.
5226 History expansions are introduced by the appearance of the
5227 history expansion character, which is \^\fB!\fP\^ by default.
5228 Only backslash (\^\fB\e\fP\^) and single quotes can quote
5229 the history expansion character.
5231 Several shell options settable with the
5233 builtin may be used to tailor the behavior of history expansion.
5236 shell option is enabled (see the description of the
5240 is being used, history substitutions are not immediately passed to
5242 Instead, the expanded line is reloaded into the
5244 editing buffer for further modification.
5247 is being used, and the
5249 shell option is enabled, a failed history substitution will be reloaded
5252 editing buffer for correction.
5257 builtin command may be used to see what a history expansion will
5263 builtin may be used to add commands to the end of the history list
5264 without actually executing them, so that they are available for
5267 The shell allows control of the various characters used by the
5268 history expansion mechanism (see the description of
5271 .BR "Shell Variables" ).
5272 .SS Event Designators
5274 An event designator is a reference to a command line entry in the
5280 Start a history substitution, except when followed by a
5285 Refer to command line
5289 Refer to the current command line minus
5293 Refer to the previous command. This is a synonym for `!\-1'.
5296 Refer to the most recent command starting with
5299 .B !?\fIstring\fR\fB[?]\fR
5300 Refer to the most recent command containing
5302 The trailing \fB?\fP may be omitted if
5304 is followed immediately by a newline.
5306 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
5307 Quick substitution. Repeat the last command, replacing
5312 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
5313 (see \fBModifiers\fP below).
5316 The entire command line typed so far.
5318 .SS Word Designators
5320 Word designators are used to select desired words from the event.
5323 separates the event specification from the word designator.
5324 It may be omitted if the word designator begins with a
5331 Words are numbered from the beginning of the line,
5332 with the first word being denoted by 0 (zero).
5333 Words are inserted into the current line separated by single spaces.
5338 The zeroth word. For the shell, this is the command
5345 The first argument. That is, word 1.
5351 The word matched by the most recent `?\fIstring\fR?' search.
5354 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
5357 All of the words but the zeroth. This is a synonym
5358 for `\fI1\-$\fP'. It is not an error to use
5360 if there is just one
5361 word in the event; the empty string is returned in that case.
5364 Abbreviates \fIx\-$\fP.
5367 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
5370 If a word designator is supplied without an event specification, the
5371 previous command is used as the event.
5374 After the optional word designator, there may appear a sequence of
5375 one or more of the following modifiers, each preceded by a `:'.
5381 Remove a trailing file name component, leaving only the head.
5384 Remove all leading file name components, leaving the tail.
5387 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
5391 Remove all but the trailing suffix.
5394 Print the new command but do not execute it.
5397 Quote the substituted words, escaping further substitutions.
5400 Quote the substituted words as with
5402 but break into words at
5406 .B s/\fIold\fP/\fInew\fP/
5409 for the first occurrence of
5411 in the event line. Any delimiter can be used in place of /. The
5412 final delimiter is optional if it is the last character of the
5413 event line. The delimiter may be quoted in
5417 with a single backslash. If & appears in
5421 A single backslash will quote the &. If
5423 is null, it is set to the last
5425 substituted, or, if no previous history substitutions took place,
5429 .B !?\fIstring\fR\fB[?]\fR
5433 Repeat the previous substitution.
5436 Cause changes to be applied over the entire event line. This is
5437 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
5438 or `\fB:&\fP'. If used with
5439 `\fB:s\fP', any delimiter can be used
5440 in place of /, and the final delimiter is optional
5441 if it is the last character of the event line.
5443 .SH "SHELL BUILTIN COMMANDS"
5444 .\" start of bash_builtins
5447 Unless otherwise noted, each builtin command documented in this
5448 section as accepting options preceded by
5452 to signify the end of the options.
5456 \fB:\fP [\fIarguments\fP]
5458 No effect; the command does nothing beyond expanding
5460 and performing any specified
5461 redirections. A zero exit code is returned.
5464 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
5466 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
5468 Read and execute commands from
5471 shell environment and return the exit status of the last command
5476 does not contain a slash, file names in
5479 are used to find the directory containing
5481 The file searched for in
5484 need not be executable.
5485 When \fBbash\fP is not in \fIposix mode\fP, the current directory is
5486 searched if no file is found in
5493 builtin command is turned off, the
5497 If any \fIarguments\fP are supplied, they become the positional
5498 parameters when \fIfilename\fP is executed. Otherwise the positional
5499 parameters are unchanged.
5500 The return status is the status of the last command exited within
5501 the script (0 if no commands are executed), and false if
5503 is not found or cannot be read.
5505 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
5506 \fBAlias\fP with no arguments or with the
5508 option prints the list of aliases in the form
5509 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
5510 When arguments are supplied, an alias is defined for
5511 each \fIname\fP whose \fIvalue\fP is given.
5512 A trailing space in \fIvalue\fP causes the next word to be
5513 checked for alias substitution when the alias is expanded.
5514 For each \fIname\fP in the argument list for which no \fIvalue\fP
5515 is supplied, the name and value of the alias is printed.
5516 \fBAlias\fP returns true unless a \fIname\fP is given for which
5517 no alias has been defined.
5519 \fBbg\fP [\fIjobspec\fP]
5520 Resume the suspended job \fIjobspec\fP in the background, as if it
5521 had been started with
5523 If \fIjobspec\fP is not present, the shell's notion of the
5524 \fIcurrent job\fP is used.
5527 returns 0 unless run when job control is disabled or, when run with
5528 job control enabled, if \fIjobspec\fP was not found or started without
5532 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
5534 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
5536 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
5538 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
5540 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
5544 key and function bindings, or bind a key sequence to a
5546 function or macro. The binding syntax accepted is identical to that of
5548 but each binding must be passed as a separate argument;
5549 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the
5557 as the keymap to be affected by the subsequent bindings.
5561 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
5562 vi\-move, vi\-command\fP, and
5564 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
5565 equivalent to \fIemacs\-standard\fP.
5568 List the names of all \fBreadline\fP functions.
5571 Display \fBreadline\fP function names and bindings in such a way
5572 that they can be re-read.
5575 List current \fBreadline\fP function names and bindings.
5578 Display \fBreadline\fP variable names and values in such a way that they
5582 List current \fBreadline\fP variable names and values.
5585 Display \fBreadline\fP key sequences bound to macros and the strings
5586 they output in such a way that they can be re-read.
5589 Display \fBreadline\fP key sequences bound to macros and the strings
5592 .B \-f \fIfilename\fP
5593 Read key bindings from \fIfilename\fP.
5595 .B \-q \fIfunction\fP
5596 Query about which keys invoke the named \fIfunction\fP.
5598 .B \-u \fIfunction\fP
5599 Unbind all keys bound to the named \fIfunction\fP.
5602 Remove any current binding for \fIkeyseq\fP.
5604 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
5605 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
5609 The return value is 0 unless an unrecognized option is given or an
5613 \fBbreak\fP [\fIn\fP]
5620 loop. If \fIn\fP is specified, break \fIn\fP levels.
5624 is greater than the number of enclosing loops, all enclosing loops
5625 are exited. The return value is 0 unless the shell is not executing
5630 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
5631 Execute the specified shell builtin, passing it
5633 and return its exit status.
5634 This is useful when defining a
5635 function whose name is the same as a shell builtin,
5636 retaining the functionality of the builtin within the function.
5637 The \fBcd\fP builtin is commonly redefined this way.
5638 The return status is false if
5640 is not a shell builtin command.
5642 \fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
5643 Change the current directory to \fIdir\fP. The variable
5652 defines the search path for the directory containing
5654 Alternative directory names in
5657 are separated by a colon (:). A null directory name in
5660 is the same as the current directory, i.e., ``\fB.\fP''. If
5662 begins with a slash (/),
5668 option says to use the physical directory structure instead of
5669 following symbolic links (see also the
5673 builtin command); the
5675 option forces symbolic links to be followed. An argument of
5680 The return value is true if the directory was successfully changed;
5683 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
5688 suppressing the normal shell function lookup. Only builtin
5689 commands or commands found in the
5692 are executed. If the
5694 option is given, the search for
5696 is performed using a default value for
5698 that is guaranteed to find all of the standard utilities.
5703 option is supplied, a description of
5707 option causes a single word indicating the command or file name
5710 to be displayed; the
5712 option produces a more verbose description.
5717 option is supplied, the exit status is 0 if
5719 was found, and 1 if not. If neither option is supplied and
5720 an error occurred or
5722 cannot be found, the exit status is 127. Otherwise, the exit status of the
5724 builtin is the exit status of
5727 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
5728 Generate possible completion matches for \fIword\fP according to
5729 the \fIoption\fPs, which may be any option accepted by the
5731 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
5732 the matches to the standard output.
5733 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
5734 set by the programmable completion facilities, while available, will not
5737 The matches will be generated in the same way as if the programmable
5738 completion code had generated them directly from a completion specification
5739 with the same flags.
5740 If \fIword\fP is specified, only those completions matching \fIword\fP
5743 The return value is true unless an invalid option is supplied, or no
5744 matches were generated.
5747 \fBcomplete\fP [\fB\-abcdefgjkvu\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
5749 [\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
5751 \fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
5753 Specify how arguments to each \fIname\fP should be completed.
5754 If the \fB\-p\fP option is supplied, or if no options are supplied,
5755 existing completion specifications are printed in a way that allows
5756 them to be reused as input.
5757 The \fB\-r\fP option removes a completion specification for
5758 each \fIname\fP, or, if no \fIname\fPs are supplied, all
5759 completion specifications.
5761 The process of applying these completion specifications when word completion
5762 is attempted is described above under \fBProgrammable Completion\fP.
5764 Other options, if specified, have the following meanings.
5765 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
5766 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
5767 should be quoted to protect them from expansion before the
5773 \fB\-o\fP \fIcomp-option\fP
5774 The \fIcomp-option\fP controls several aspects of the compspec's behavior
5775 beyond the simple generation of completions.
5776 \fIcomp-option\fP may be one of:
5780 Use readline's default completion if the compspec generates no matches.
5783 Perform directory name completion if the compspec generates no matches.
5786 Tell readline that the compspec generates filenames, so it can perform any
5787 filename\-specific processing (like adding a slash to directory names or
5788 suppressing trailing spaces). Intended to be used with shell functions.
5791 \fB\-A\fP \fIaction\fP
5792 The \fIaction\fP may be one of the following to generate a list of possible
5797 Alias names. May also be specified as \fB\-a\fP.
5800 Array variable names.
5803 \fBReadline\fP key binding names.
5806 Names of shell builtin commands. May also be specified as \fB\-b\fP.
5809 Command names. May also be specified as \fB\-c\fP.
5812 Directory names. May also be specified as \fB\-d\fP.
5815 Names of disabled shell builtins.
5818 Names of enabled shell builtins.
5821 Names of exported shell variables. May also be specified as \fB\-e\fP.
5824 File names. May also be specified as \fB\-f\fP.
5827 Names of shell functions.
5830 Group names. May also be specified as \fB\-g\fP.
5833 Help topics as accepted by the \fBhelp\fP builtin.
5836 Hostnames, as taken from the file specified by the
5842 Job names, if job control is active. May also be specified as \fB\-j\fP.
5845 Shell reserved words. May also be specified as \fB\-k\fP.
5848 Names of running jobs, if job control is active.
5851 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
5854 Shell option names as accepted by the \fBshopt\fP builtin.
5860 Names of stopped jobs, if job control is active.
5863 User names. May also be specified as \fB\-u\fP.
5866 Names of all shell variables. May also be specified as \fB\-v\fP.
5869 \fB\-G\fP \fIglobpat\fP
5870 The filename expansion pattern \fIglobpat\fP is expanded to generate
5871 the possible completions.
5873 \fB\-W\fP \fIwordlist\fP
5874 The \fIwordlist\fP is split using the characters in the
5877 special variable as delimiters, and each resultant word is expanded.
5878 The possible completions are the members of the resultant list which
5879 match the word being completed.
5881 \fB\-C\fP \fIcommand\fP
5882 \fIcommand\fP is executed in a subshell environment, and its output is
5883 used as the possible completions.
5885 \fB\-F\fP \fIfunction\fP
5886 The shell function \fIfunction\fP is executed in the current shell
5888 When it finishes, the possible completions are retrieved from the value
5894 \fB\-X\fP \fIfilterpat\fP
5895 \fIfilterpat\fP is a pattern as used for filename expansion.
5896 It is applied to the list of possible completions generated by the
5897 preceding options and arguments, and each completion matching
5898 \fIfilterpat\fP is removed from the list.
5899 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
5900 case, any completion not matching \fIfilterpat\fP is removed.
5902 \fB\-P\fP \fIprefix\fP
5903 \fIprefix\fP is added at the beginning of each possible completion
5904 after all other options have been applied.
5906 \fB\-S\fP \fIsuffix\fP
5907 \fIsuffix\fP is appended to each possible completion
5908 after all other options have been applied.
5911 The return value is true unless an invalid option is supplied, an option
5912 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
5913 argument, an attempt is made to remove a completion specification for
5914 a \fIname\fP for which no specification exists, or
5915 an error occurs adding a completion specification.
5918 \fBcontinue\fP [\fIn\fP]
5919 Resume the next iteration of the enclosing
5928 is specified, resume at the \fIn\fPth enclosing loop.
5932 is greater than the number of enclosing loops, the last enclosing loop
5933 (the ``top-level'' loop) is resumed. The return value is 0 unless the
5934 shell is not executing a loop when
5939 \fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
5941 \fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
5943 Declare variables and/or give them attributes.
5944 If no \fIname\fPs are given then display the values of variables.
5947 option will display the attributes and values of each
5951 is used, additional options are ignored.
5954 option inhibits the display of function definitions; only the
5955 function name and attributes are printed.
5960 The following options can
5961 be used to restrict output to variables with the specified attribute or
5962 to give variables attributes:
5967 Each \fIname\fP is an array variable (see
5972 Use function names only.
5975 The variable is treated as an integer; arithmetic evaluation (see
5977 .B "ARITHMETIC EVALUATION" ") "
5978 is performed when the variable is assigned a value.
5981 Make \fIname\fPs readonly. These names cannot then be assigned values
5982 by subsequent assignment statements or unset.
5985 Mark \fIname\fPs for export to subsequent commands via the environment.
5988 Using `+' instead of `\-'
5989 turns off the attribute instead, with the exception that \fB+a\fP
5990 may not be used to destroy an array variable. When used in a function,
5992 \fIname\fP local, as with the
5994 command. The return value is 0 unless an invalid option is encountered,
5995 an attempt is made to define a function using
5996 .if n ``\-f foo=bar'',
5997 .if t \f(CW\-f foo=bar\fP,
5998 an attempt is made to assign a value to a readonly variable,
5999 an attempt is made to assign a value to an array variable without
6000 using the compound assignment syntax (see
6002 above), one of the \fInames\fP is not a valid shell variable name,
6003 an attempt is made to turn off readonly status for a readonly variable,
6004 an attempt is made to turn off array status for an array variable,
6005 or an attempt is made to display a non-existent function with \fB\-f\fP.
6008 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
6009 Without options, displays the list of currently remembered directories.
6010 The default display is on a single line with directory names separated
6012 Directories are added to the list with the
6016 command removes entries from the list.
6021 Displays the \fIn\fPth entry counting from the left of the list
6024 when invoked without options, starting with zero.
6027 Displays the \fIn\fPth entry counting from the right of the list
6030 when invoked without options, starting with zero.
6033 Clears the directory stack by deleting all of the entries.
6036 Produces a longer listing; the default listing format uses a
6037 tilde to denote the home directory.
6040 Print the directory stack with one entry per line.
6043 Print the directory stack with one entry per line,
6044 prefixing each entry with its index in the stack.
6047 The return value is 0 unless an
6048 invalid option is supplied or \fIn\fP indexes beyond the end
6049 of the directory stack.
6052 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
6053 Without options, each
6055 is removed from the table of active jobs.
6056 If the \fB\-h\fP option is given, each
6058 is not removed from the table, but is marked so that
6061 is not sent to the job if the shell receives a
6066 is present, and neither the
6070 option is supplied, the \fIcurrent job\fP is used.
6075 option means to remove or mark all jobs; the
6079 argument restricts operation to running jobs.
6080 The return value is 0 unless a
6082 does not specify a valid job.
6084 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
6085 Output the \fIarg\fPs, separated by spaces, followed by a newline.
6086 The return status is always 0.
6087 If \fB\-n\fP is specified, the trailing newline is
6088 suppressed. If the \fB\-e\fP option is given, interpretation of
6089 the following backslash-escaped characters is enabled. The
6091 option disables the interpretation of these escape characters,
6092 even on systems where they are interpreted by default.
6093 The \fBxpg_echo\fP shell option may be used to
6094 dynamically determine whether or not \fBecho\fP expands these
6095 escape characters by default.
6099 to mean the end of options.
6101 interprets the following escape sequences:
6112 suppress trailing newline
6136 the eight-bit character whose value is the octal value \fInnn\fP
6137 (one to three digits)
6140 the eight-bit character whose value is the hexadecimal value \fIHH\fP
6141 (one or two hex digits)
6145 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
6146 Enable and disable builtin shell commands.
6147 Disabling a builtin allows a disk command which has the same name
6148 as a shell builtin to be executed without specifying a full pathname,
6149 even though the shell normally searches for builtins before disk commands.
6150 If \fB\-n\fP is used, each \fIname\fP
6151 is disabled; otherwise,
6152 \fInames\fP are enabled. For example, to use the
6154 binary found via the
6157 instead of the shell builtin version, run
6158 .if t \f(CWenable -n test\fP.
6159 .if n ``enable -n test''.
6162 option means to load the new builtin command
6166 on systems that support dynamic loading. The
6168 option will delete a builtin previously loaded with
6170 If no \fIname\fP arguments are given, or if the
6172 option is supplied, a list of shell builtins is printed.
6173 With no other option arguments, the list consists of all enabled
6175 If \fB\-n\fP is supplied, only disabled builtins are printed.
6176 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
6177 indication of whether or not each is enabled.
6178 If \fB\-s\fP is supplied, the output is restricted to the POSIX
6179 \fIspecial\fP builtins.
6180 The return value is 0 unless a
6182 is not a shell builtin or there is an error loading a new builtin
6183 from a shared object.
6185 \fBeval\fP [\fIarg\fP ...]
6186 The \fIarg\fPs are read and concatenated together into a single
6187 command. This command is then read and executed by the shell, and
6188 its exit status is returned as the value of
6192 or only null arguments,
6196 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
6199 is specified, it replaces the shell.
6200 No new process is created. The
6202 become the arguments to \fIcommand\fP.
6206 the shell places a dash at the beginning of the zeroth arg passed to
6214 to be executed with an empty environment. If
6216 is supplied, the shell passes
6218 as the zeroth argument to the executed command. If
6220 cannot be executed for some reason, a non-interactive shell exits,
6221 unless the shell option
6223 is enabled, in which case it returns failure.
6224 An interactive shell returns failure if the file cannot be executed.
6227 is not specified, any redirections take effect in the current shell,
6228 and the return status is 0. If there is a redirection error, the
6231 \fBexit\fP [\fIn\fP]
6232 Cause the shell to exit
6233 with a status of \fIn\fP. If
6235 is omitted, the exit status
6236 is that of the last command executed.
6240 is executed before the shell terminates.
6243 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
6249 are marked for automatic export to the environment of
6250 subsequently executed commands. If the
6258 are given, or if the
6260 option is supplied, a list
6261 of all names that are exported in this shell is printed.
6264 option causes the export property to be removed from the
6267 returns an exit status of 0 unless an invalid option is
6269 one of the \fInames\fP is not a valid shell variable name, or
6273 that is not a function.
6276 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
6278 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
6280 Fix Command. In the first form, a range of commands from
6284 is selected from the history list.
6288 may be specified as a string (to locate the last command beginning
6289 with that string) or as a number (an index into the history list,
6290 where a negative number is used as an offset from the current
6293 is not specified it is set to
6294 the current command for listing (so that
6295 .if n ``fc \-l \-10''
6296 .if t \f(CWfc \-l \-10\fP
6297 prints the last 10 commands) and to
6302 is not specified it is set to the previous
6303 command for editing and \-16 for listing.
6308 the command numbers when listing. The
6310 option reverses the order of
6311 the commands. If the
6314 the commands are listed on
6315 standard output. Otherwise, the editor given by
6318 on a file containing those commands. If
6324 variable is used, and
6331 is not set. If neither variable is set,
6333 is used. When editing is complete, the edited commands are
6334 echoed and executed.
6336 In the second form, \fIcommand\fP is re-executed after each instance
6337 of \fIpat\fP is replaced by \fIrep\fP.
6338 A useful alias to use with this is
6340 .if t \f(CWr='fc \-s'\fP,
6344 runs the last command beginning with
6350 re-executes the last command.
6352 If the first form is used, the return value is 0 unless an invalid
6353 option is encountered or
6357 specify history lines out of range.
6360 option is supplied, the return value is the value of the last
6361 command executed or failure if an error occurs with the temporary
6362 file of commands. If the second form is used, the return status
6363 is that of the command re-executed, unless
6365 does not specify a valid history line, in which case
6369 \fBfg\fP [\fIjobspec\fP]
6372 in the foreground, and make it the current job.
6375 is not present, the shell's notion of the \fIcurrent job\fP is used.
6376 The return value is that of the command placed into the foreground,
6377 or failure if run when job control is disabled or, when run with
6378 job control enabled, if
6380 does not specify a valid job or
6382 specifies a job that was started without job control.
6384 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
6386 is used by shell procedures to parse positional parameters.
6388 contains the option characters to be recognized; if a character
6389 is followed by a colon, the option is expected to have an
6390 argument, which should be separated from it by white space.
6391 The colon and question mark characters may not be used as
6393 Each time it is invoked,
6395 places the next option in the shell variable
6399 if it does not exist,
6400 and the index of the next argument to be processed into the
6406 is initialized to 1 each time the shell or a shell script
6407 is invoked. When an option requires an argument,
6409 places that argument into the variable
6412 The shell does not reset
6415 automatically; it must be manually reset between multiple
6418 within the same shell invocation if a new set of parameters
6421 When the end of options is encountered, \fBgetopts\fP exits with a
6422 return value greater than zero.
6423 \fBOPTIND\fP is set to the index of the first non-option argument,
6424 and \fBname\fP is set to ?.
6427 normally parses the positional parameters, but if more arguments are
6431 parses those instead.
6434 can report errors in two ways. If the first character of
6438 error reporting is used. In normal operation diagnostic messages
6439 are printed when invalid options or missing option arguments are
6444 is set to 0, no error messages will be displayed, even if the first
6449 If an invalid option is seen,
6454 prints an error message and unsets
6460 the option character found is placed in
6463 and no diagnostic message is printed.
6465 If a required argument is not found, and
6468 a question mark (\^\fB?\fP\^) is placed in
6472 is unset, and a diagnostic message is printed.
6475 is silent, then a colon (\^\fB:\fP\^) is placed in
6480 is set to the option character found.
6483 returns true if an option, specified or unspecified, is found.
6484 It returns false if the end of options is encountered or an
6487 \fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-t\fP] [\fIname\fP]
6490 the full file name of the command is determined by searching
6496 option is supplied, no path search is performed, and
6498 is used as the full file name of the command.
6501 option causes the shell to forget all
6502 remembered locations.
6505 option is supplied, the full pathname to which each \fIname\fP corresponds
6506 is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
6507 the \fIname\fP is printed before the hashed full pathname.
6508 If no arguments are given, information about remembered commands is printed.
6509 The return status is true unless a
6511 is not found or an invalid option is supplied.
6513 \fBhelp\fP [\fB\-s\fP] [\fIpattern\fP]
6514 Display helpful information about builtin commands. If
6518 gives detailed help on all commands matching
6520 otherwise help for all the builtins and shell control structures
6522 The \fB\-s\fP option restricts the information displayed to a short
6524 The return status is 0 unless no command matches
6528 \fBhistory [\fIn\fP]
6530 \fBhistory\fP \fB\-c\fP
6532 \fBhistory \-d\fP \fIoffset\fP
6534 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
6536 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
6538 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
6540 With no options, display the command
6541 history list with line numbers. Lines listed
6544 have been modified. An argument of
6548 lines. If \fIfilename\fP is supplied, it is used as the
6549 name of the history file; if not, the value of
6552 is used. Options, if supplied, have the following meanings:
6557 Clear the history list by deleting all the entries.
6559 \fB\-d\fP \fIoffset\fP
6560 Delete the history entry at position \fIoffset\fP.
6563 Append the ``new'' history lines (history lines entered since the
6564 beginning of the current \fBbash\fP session) to the history file.
6567 Read the history lines not already read from the history
6568 file into the current history list. These are lines
6569 appended to the history file since the beginning of the
6570 current \fBbash\fP session.
6573 Read the contents of the history file
6574 and use them as the current history.
6577 Write the current history to the history file, overwriting the
6578 history file's contents.
6581 Perform history substitution on the following \fIargs\fP and display
6582 the result on the standard output.
6583 Does not store the results in the history list.
6584 Each \fIarg\fP must be quoted to disable normal history expansion.
6589 in the history list as a single entry. The last command in the
6590 history list is removed before the
6595 The return value is 0 unless an invalid option is encountered, an
6596 error occurs while reading or writing the history file, an invalid
6597 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
6598 history expansion supplied as an argument to \fB\-p\fP fails.
6602 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
6604 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
6606 The first form lists the active jobs. The options have the following
6613 in addition to the normal information.
6616 List only the process ID of the job's process group
6620 Display information only about jobs that have changed status since
6621 the user was last notified of their status.
6624 Restrict output to running jobs.
6627 Restrict output to stopped jobs.
6632 is given, output is restricted to information about that job.
6633 The return status is 0 unless an invalid option is encountered
6648 with the corresponding process group ID, and executes
6652 returning its exit status.
6656 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
6658 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
6660 Send the signal named by
6664 to the processes named by
6669 is either a signal name such as
6674 is a signal number. If
6676 is a signal name, the name may be
6677 given with or without the
6683 is not present, then
6689 lists the signal names.
6690 If any arguments are supplied when
6692 is given, the names of the signals corresponding to the arguments are
6693 listed, and the return status is 0.
6694 The \fIexit_status\fP argument to
6696 is a number specifying either a signal number or the exit status of
6697 a process terminated by a signal.
6699 returns true if at least one signal was successfully sent, or false
6700 if an error occurs or an invalid option is encountered.
6702 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
6705 is an arithmetic expression to be evaluated (see
6707 .BR "ARITHMETIC EVALUATION" ).
6712 returns 1; 0 is returned otherwise.
6714 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
6715 For each argument, a local variable named
6717 is created, and assigned
6719 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
6722 is used within a function, it causes the variable
6724 to have a visible scope restricted to that function and its children.
6727 writes a list of local variables to the standard output. It is
6730 when not within a function. The return status is 0 unless
6732 is used outside a function, an invalid
6735 \fIname\fP is a readonly variable.
6740 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
6741 Removes entries from the directory stack. With no arguments,
6742 removes the top directory from the stack, and performs a
6744 to the new top directory.
6745 Arguments, if supplied, have the following meanings:
6750 Removes the \fIn\fPth entry counting from the left of the list
6753 starting with zero. For example:
6755 .if t \f(CWpopd +0\fP
6756 removes the first directory,
6758 .if t \f(CWpopd +1\fP
6762 Removes the \fIn\fPth entry counting from the right of the list
6765 starting with zero. For example:
6767 .if t \f(CWpopd -0\fP
6768 removes the last directory,
6770 .if t \f(CWpopd -1\fP
6774 Suppresses the normal change of directory when removing directories
6775 from the stack, so that only the stack is manipulated.
6780 command is successful, a
6782 is performed as well, and the return status is 0.
6784 returns false if an invalid option is encountered, the directory stack
6785 is empty, a non-existent directory stack entry is specified, or the
6786 directory change fails.
6789 \fBprintf\fP \fIformat\fP [\fIarguments\fP]
6790 Write the formatted \fIarguments\fP to the standard output under the
6791 control of the \fIformat\fP.
6792 The \fIformat\fP is a character string which contains three types of objects:
6793 plain characters, which are simply copied to standard output, character
6794 escape sequences, which are converted and copied to the standard output, and
6795 format specifications, each of which causes printing of the next successive
6797 In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
6798 \fBprintf\fP to expand backslash escape sequences in the corresponding
6799 \fIargument\fP, and \fB%q\fP causes \fBprintf\fP to output the corresponding
6800 \fIargument\fP in a format that can be reused as shell input.
6802 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
6803 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
6804 extra format specifications behave as if a zero value or null string, as
6805 appropriate, had been supplied. The return value is zero on success,
6806 non-zero on failure.
6809 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
6811 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
6813 Adds a directory to the top of the directory stack, or rotates
6814 the stack, making the new top of the stack the current working
6815 directory. With no arguments, exchanges the top two directories
6816 and returns 0, unless the directory stack is empty.
6817 Arguments, if supplied, have the following meanings:
6822 Rotates the stack so that the \fIn\fPth directory
6823 (counting from the left of the list shown by
6829 Rotates the stack so that the \fIn\fPth directory
6830 (counting from the right of the list shown by
6832 starting with zero) is at the top.
6835 Suppresses the normal change of directory when adding directories
6836 to the stack, so that only the stack is manipulated.
6841 to the directory stack at the top, making it the
6842 new current working directory.
6847 command is successful, a
6849 is performed as well.
6850 If the first form is used,
6852 returns 0 unless the cd to
6854 fails. With the second form,
6856 returns 0 unless the directory stack is empty,
6857 a non-existent directory stack element is specified,
6858 or the directory change to the specified new current directory
6862 \fBpwd\fP [\fB\-LP\fP]
6863 Print the absolute pathname of the current working directory.
6864 The pathname printed contains no symbolic links if the
6866 option is supplied or the
6870 builtin command is enabled.
6873 option is used, the pathname printed may contain symbolic links.
6874 The return status is 0 unless an error occurs while
6875 reading the name of the current directory or an
6876 invalid option is supplied.
6878 \fBread\fP [\fB\-ers\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
6879 One line is read from the standard input, and the first word
6880 is assigned to the first
6882 the second word to the second
6884 and so on, with leftover words and their intervening separators assigned
6887 If there are fewer words read from the standard input than names,
6888 the remaining names are assigned empty values.
6892 are used to split the line into words.
6893 The backslash character (\fB\e\fP) may be used to remove any special
6894 meaning for the next character read and for line continuation.
6895 Options, if supplied, have the following meanings:
6900 The words are assigned to sequential indices
6901 of the array variable
6905 is unset before any new values are assigned.
6906 Other \fIname\fP arguments are ignored.
6909 The first character of \fIdelim\fP is used to terminate the input line,
6910 rather than newline.
6913 If the standard input
6914 is coming from a terminal,
6919 above) is used to obtain the line.
6922 \fBread\fP returns after reading \fInchars\fP characters rather than
6923 waiting for a complete line of input.
6926 Display \fIprompt\fP on standard error, without a
6927 trailing newline, before attempting to read any input. The prompt
6928 is displayed only if input is coming from a terminal.
6931 Backslash does not act as an escape character.
6932 The backslash is considered to be part of the line.
6933 In particular, a backslash-newline pair may not be used as a line
6937 Silent mode. If input is coming from a terminal, characters are
6940 .B \-t \fItimeout\fP
6941 Cause \fBread\fP to time out and return failure if a complete line of
6942 input is not read within \fItimeout\fP seconds.
6943 This option has no effect if \fBread\fP is not reading input from the
6949 are supplied, the line read is assigned to the variable
6952 The return code is zero, unless end-of-file is encountered or \fBread\fP
6956 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
6959 \fInames\fP are marked readonly; the values of these
6961 may not be changed by subsequent assignment.
6964 option is supplied, the functions corresponding to the
6969 option restricts the variables to arrays.
6972 arguments are given, or if the
6974 option is supplied, a list of all readonly names is printed.
6977 option causes output to be displayed in a format that
6978 may be reused as input.
6979 The return status is 0 unless an invalid option is encountered,
6982 is not a valid shell variable name, or
6986 that is not a function.
6988 \fBreturn\fP [\fIn\fP]
6989 Causes a function to exit with the return value specified by
6993 is omitted, the return status is that of the last command
6994 executed in the function body. If used outside a function,
6995 but during execution of a script by the
6997 (\fBsource\fP) command, it causes the shell to stop executing
6998 that script and return either
7000 or the exit status of the last command executed within the
7001 script as the exit status of the script. If used outside a
7002 function and not during execution of a script by \fB.\fP\^,
7003 the return status is false.
7005 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
7006 Without options, the name and value of each shell variable are displayed
7007 in a format that can be reused as input.
7008 The output is sorted according to the current locale.
7009 When options are specified, they set or unset shell attributes.
7010 Any arguments remaining after the options are processed are treated
7011 as values for the positional parameters and are assigned, in order, to
7016 Options, if specified, have the following meanings:
7021 Automatically mark variables and functions which are modified or created
7022 for export to the environment of subsequent commands.
7025 Report the status of terminated background jobs
7026 immediately, rather than before the next primary prompt. This is
7027 effective only when job control is enabled.
7030 Exit immediately if a \fIsimple command\fP (see
7033 above) exits with a non-zero status. The shell does not exit if the
7034 command that fails is part of an
7041 statement, part of a
7045 list, or if the command's return value is
7048 A trap on \fBERR\fP, if set, is executed before the shell exits.
7051 Disable pathname expansion.
7054 Remember the location of commands as they are looked up for execution.
7055 This is enabled by default.
7058 All arguments in the form of assignment statements
7059 are placed in the environment for a command, not just
7060 those that precede the command name.
7063 Monitor mode. Job control is enabled. This option is on
7064 by default for interactive shells on systems that support
7068 above). Background processes run in a separate process
7069 group and a line containing their exit status is printed
7070 upon their completion.
7073 Read commands but do not execute them. This may be used to
7074 check a shell script for syntax errors. This is ignored by
7077 .B \-o \fIoption\-name\fP
7078 The \fIoption\-name\fP can be one of the following:
7090 Use an emacs-style command line editing interface. This is enabled
7091 by default when the shell is interactive, unless the shell is started
7109 Enable command history, as described above under
7112 This option is on by default in interactive shells.
7115 The effect is as if the shell command
7116 .if t \f(CWIGNOREEOF=10\fP
7117 .if n ``IGNOREEOF=10''
7162 Change the behavior of
7164 where the default operation differs
7165 from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
7176 Use a vi-style command line editing interface.
7185 is supplied with no \fIoption\-name\fP, the values of the current options are
7189 is supplied with no \fIoption\-name\fP, a series of
7191 commands to recreate the current option settings is displayed on
7192 the standard output.
7198 mode. In this mode, the
7204 files are not processed, shell functions are not inherited from the
7205 environment, and the
7208 variable, if it appears in the environment, is ignored.
7209 If the shell is started with the effective user (group) id not equal to the
7210 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
7211 are taken and the effective user id is set to the real user id.
7212 If the \fB\-p\fP option is supplied at startup, the effective user id is
7214 Turning this option off causes the effective user
7215 and group ids to be set to the real user and group ids.
7218 Exit after reading and executing one command.
7221 Treat unset variables as an error when performing
7222 parameter expansion. If expansion is attempted on an
7223 unset variable, the shell prints an error message, and,
7224 if not interactive, exits with a non-zero status.
7227 Print shell input lines as they are read.
7230 After expanding each \fIsimple command\fP,
7231 display the expanded value of
7234 followed by the command and its expanded arguments.
7237 The shell performs brace expansion (see
7239 above). This is on by default.
7244 does not overwrite an existing file with the
7249 redirection operators. This may be overridden when
7250 creating output files by using the redirection operator
7258 style history substitution. This option is on by
7259 default when the shell is interactive.
7262 If set, the shell does not follow symbolic links when executing
7265 that change the current working directory. It uses the
7266 physical directory structure instead. By default,
7268 follows the logical chain of directories when performing commands
7269 which change the current directory.
7272 If no arguments follow this option, then the positional parameters are
7273 unset. Otherwise, the positional parameters are set to the
7274 \fIarg\fPs, even if some of them begin with a
7278 Signal the end of options, cause all remaining \fIarg\fPs to be
7279 assigned to the positional parameters. The
7283 options are turned off.
7284 If there are no \fIarg\fPs,
7285 the positional parameters remain unchanged.
7288 The options are off by default unless otherwise noted.
7289 Using + rather than \- causes these options to be turned off.
7290 The options can also be specified as arguments to an invocation of
7292 The current set of options may be found in
7294 The return status is always true unless an invalid option is encountered.
7297 \fBshift\fP [\fIn\fP]
7298 The positional parameters from \fIn\fP+1 ... are renamed to
7301 Parameters represented by the numbers \fB$#\fP
7302 down to \fB$#\fP\-\fIn\fP+1 are unset.
7304 must be a non-negative number less than or equal to \fB$#\fP.
7307 is 0, no parameters are changed.
7310 is not given, it is assumed to be 1.
7313 is greater than \fB$#\fP, the positional parameters are not changed.
7314 The return status is greater than zero if
7318 or less than zero; otherwise 0.
7320 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
7321 Toggle the values of variables controlling optional shell behavior.
7322 With no options, or with the
7324 option, a list of all settable options is displayed, with
7325 an indication of whether or not each is set.
7326 The \fB\-p\fP option causes output to be displayed in a form that
7327 may be reused as input.
7328 Other options have the following meanings:
7333 Enable (set) each \fIoptname\fP.
7336 Disable (unset) each \fIoptname\fP.
7339 Suppresses normal output (quiet mode); the return status indicates
7340 whether the \fIoptname\fP is set or unset.
7341 If multiple \fIoptname\fP arguments are given with
7343 the return status is zero if all \fIoptnames\fP are enabled; non-zero
7347 Restricts the values of \fIoptname\fP to be those defined for the
7358 is used with no \fIoptname\fP arguments, the display is limited to
7359 those options which are set or unset, respectively.
7360 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
7363 The return status when listing options is zero if all \fIoptnames\fP
7364 are enabled, non-zero otherwise. When setting or unsetting options,
7365 the return status is zero unless an \fIoptname\fP is not a valid shell
7368 The list of \fBshopt\fP options is:
7374 If set, an argument to the
7376 builtin command that
7377 is not a directory is assumed to be the name of a variable whose
7378 value is the directory to change to.
7381 If set, minor errors in the spelling of a directory component in a
7383 command will be corrected.
7384 The errors checked for are transposed characters,
7385 a missing character, and one character too many.
7386 If a correction is found, the corrected file name is printed,
7387 and the command proceeds.
7388 This option is only used by interactive shells.
7391 If set, \fBbash\fP checks that a command found in the hash
7392 table exists before trying to execute it. If a hashed command no
7393 longer exists, a normal path search is performed.
7396 If set, \fBbash\fP checks the window size after each command
7397 and, if necessary, updates the values of
7407 attempts to save all lines of a multiple-line
7408 command in the same history entry. This allows
7409 easy re-editing of multi-line commands.
7414 includes filenames beginning with a `.' in the results of pathname
7418 If set, a non-interactive shell will not exit if
7419 it cannot execute the file specified as an argument to the
7421 builtin command. An interactive shell does not exit if
7426 If set, aliases are expanded as described above under
7429 This option is enabled by default for interactive shells.
7432 If set, the extended pattern matching features described above under
7433 \fBPathname Expansion\fP are enabled.
7436 If set, the history list is appended to the file named by the value
7439 variable when the shell exits, rather than overwriting the file.
7444 is being used, a user is given the opportunity to re-edit a
7445 failed history substitution.
7450 is being used, the results of history substitution are not immediately
7451 passed to the shell parser. Instead, the resulting line is loaded into
7452 the \fBreadline\fP editing buffer, allowing further modification.
7457 is being used, \fBbash\fP will attempt to perform hostname completion when a
7458 word containing a \fB@\fP is being completed (see
7464 This is enabled by default.
7467 If set, \fBbash\fP will send
7470 to all jobs when an interactive login shell exits.
7472 .B interactive_comments
7473 If set, allow a word beginning with
7475 to cause that word and all remaining characters on that
7476 line to be ignored in an interactive shell (see
7479 above). This option is enabled by default.
7484 option is enabled, multi-line commands are saved to the history with
7485 embedded newlines rather than using semicolon separators where possible.
7488 The shell sets this option if it is started as a login shell (see
7492 The value may not be changed.
7495 If set, and a file that \fBbash\fP is checking for mail has been
7496 accessed since the last time it was checked, the message ``The mail in
7497 \fImailfile\fP has been read'' is displayed.
7499 .B no_empty_cmd_completion
7504 will not attempt to search the \fBPATH\fP for possible completions when
7505 completion is attempted on an empty line.
7510 matches filenames in a case\-insensitive fashion when performing pathname
7512 .B Pathname Expansion
7518 allows patterns which match no
7520 .B Pathname Expansion
7522 to expand to a null string, rather than themselves.
7525 If set, the programmable completion facilities (see
7526 \fBProgrammable Completion\fP above) are enabled.
7527 This option is enabled by default.
7530 If set, prompt strings undergo variable and parameter expansion after
7531 being expanded as described in
7534 above. This option is enabled by default.
7537 The shell sets this option if it is started in restricted mode (see
7539 .B "RESTRICTED SHELL"
7541 The value may not be changed.
7542 This is not reset when the startup files are executed, allowing
7543 the startup files to discover whether or not a shell is restricted.
7548 builtin prints an error message when the shift count exceeds the
7549 number of positional parameters.
7553 \fBsource\fP (\fB.\fP) builtin uses the value of
7556 to find the directory containing the file supplied as an argument.
7557 This option is enabled by default.
7560 If set, the \fBecho\fP builtin expands backslash-escape sequences
7564 \fBsuspend\fP [\fB\-f\fP]
7565 Suspend the execution of this shell until it receives a
7570 option says not to complain if this is
7571 a login shell; just suspend anyway. The return status is 0 unless
7572 the shell is a login shell and
7574 is not supplied, or if job control is not enabled.
7577 \fBtest\fP \fIexpr\fP
7579 \fB[\fP \fIexpr\fP \fB]\fP
7580 Return a status of 0 or 1 depending on
7581 the evaluation of the conditional expression
7583 Each operator and operand must be a separate argument.
7584 Expressions are composed of the primaries described above under
7586 .BR "CONDITIONAL EXPRESSIONS" .
7589 Expressions may be combined using the following operators, listed
7590 in decreasing order of precedence.
7600 Returns the value of \fIexpr\fP.
7601 This may be used to override the normal precedence of operators.
7603 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
7610 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
7618 \fBtest\fP and \fB[\fP evaluate conditional
7619 expressions using a set of rules based on the number of arguments.
7625 The expression is false.
7628 The expression is true if and only if the argument is not null.
7631 If the first argument is \fB!\fP, the expression is true if and
7632 only if the second argument is null.
7633 If the first argument is one of the unary conditional operators listed above
7636 .BR "CONDITIONAL EXPRESSIONS" ,
7637 the expression is true if the unary test is true.
7638 If the first argument is not a valid unary conditional operator, the expression
7642 If the second argument is one of the binary conditional operators listed above
7645 .BR "CONDITIONAL EXPRESSIONS" ,
7646 the result of the expression is the result of the binary test using
7647 the first and third arguments as operands.
7648 If the first argument is \fB!\fP, the value is the negation of
7649 the two-argument test using the second and third arguments.
7650 If the first argument is exactly \fB(\fP and the third argument is
7651 exactly \fB)\fP, the result is the one-argument test of the second
7653 Otherwise, the expression is false.
7654 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
7658 If the first argument is \fB!\fP, the result is the negation of
7659 the three-argument expression composed of the remaining arguments.
7660 Otherwise, the expression is parsed and evaluated according to
7661 precedence using the rules listed above.
7664 The expression is parsed and evaluated according to precedence
7665 using the rules listed above.
7670 Print the accumulated user and system times for the shell and
7671 for processes run from the shell. The return status is 0.
7673 \fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP ...]
7676 is to be read and executed when the shell receives
7683 all specified signals are
7684 reset to their original values (the values they had
7685 upon entrance to the shell).
7688 is the null string the signal specified by each
7690 is ignored by the shell and by the commands it invokes.
7695 has been supplied, then the trap commands associated with each
7698 If no arguments are supplied or if only
7702 prints the list of commands associated with each signal number.
7706 a signal name defined in <\fIsignal.h\fP>, or a signal number.
7714 is executed on exit from the shell.
7722 is executed after every \fIsimple command\fP (see
7733 is executed whenever a simple command has a non\-zero exit status.
7737 trap is not executed if the failed command is part of an
7744 statement, part of a
7748 list, or if the command's return value is
7753 option causes the shell to print a list of signal names and
7754 their corresponding numbers.
7755 Signals ignored upon entry to the shell cannot be trapped or reset.
7756 Trapped signals are reset to their original values in a child
7757 process when it is created.
7758 The return status is false if any
7760 is invalid; otherwise
7764 \fBtype\fP [\fB\-atp\fP] \fIname\fP [\fIname\fP ...]
7768 would be interpreted if used as a command name.
7773 prints a string which is one of
7782 is an alias, shell reserved word, function, builtin, or disk file,
7786 is not found, then nothing is printed, and an exit status of false
7792 either returns the name of the disk file
7793 that would be executed if
7795 were specified as a command name,
7797 .if t \f(CWtype -t name\fP
7798 .if n ``type -t name''
7801 If a command is hashed,
7803 prints the hashed value, not necessarily the file that appears
7811 prints all of the places that contain
7814 This includes aliases and functions,
7817 option is not also used.
7818 The table of hashed commands is not consulted
7822 returns true if any of the arguments are found, false if
7825 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
7826 Provides control over the resources available to the shell and to
7827 processes started by it, on systems that allow such control.
7828 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
7829 set for the given resource. A hard limit cannot be increased once it
7830 is set; a soft limit may be increased up to the value of the hard limit.
7831 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
7835 can be a number in the unit specified for the resource
7836 or one of the special values
7841 which stand for the current hard limit, the current soft limit, and
7842 no limit, respectively.
7845 is omitted, the current value of the soft limit of the resource is
7846 printed, unless the \fB\-H\fP option is given. When more than one
7847 resource is specified, the limit name and unit are printed before the value.
7848 Other options are interpreted as follows:
7853 All current limits are reported
7856 The maximum size of core files created
7859 The maximum size of a process's data segment
7862 The maximum size of files created by the shell
7865 The maximum size that may be locked into memory
7868 The maximum resident set size
7871 The maximum number of open file descriptors (most systems do not
7872 allow this value to be set)
7875 The pipe size in 512-byte blocks (this may not be set)
7878 The maximum stack size
7881 The maximum amount of cpu time in seconds
7884 The maximum number of processes available to a single user
7887 The maximum amount of virtual memory available to the shell
7892 is given, it is the new value of the specified resource (the
7894 option is display only).
7895 If no option is given, then
7897 is assumed. Values are in 1024-byte increments, except for
7899 which is in seconds,
7901 which is in units of 512-byte blocks,
7906 which are unscaled values.
7907 The return status is 0 unless an invalid option or argument is supplied,
7908 or an error occurs while setting a new limit.
7911 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
7912 The user file-creation mask is set to
7916 begins with a digit, it
7917 is interpreted as an octal number; otherwise
7918 it is interpreted as a symbolic mode mask similar
7923 is omitted, the current value of the mask is printed.
7926 option causes the mask to be printed in symbolic form; the
7927 default output is an octal number.
7930 option is supplied, and
7932 is omitted, the output is in a form that may be reused as input.
7933 The return status is 0 if the mode was successfully changed or if
7934 no \fImode\fP argument was supplied, and false otherwise.
7936 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
7937 Remove each \fIname\fP from the list of defined aliases. If
7939 is supplied, all alias definitions are removed. The return
7940 value is true unless a supplied
7942 is not a defined alias.
7944 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
7947 remove the corresponding variable or function.
7948 If no options are supplied, or the
7950 option is given, each
7952 refers to a shell variable.
7953 Read-only variables may not be unset.
7959 refers to a shell function, and the function definition
7961 Each unset variable or function is removed from the environment
7962 passed to subsequent commands.
7979 are unset, they lose their special properties, even if they are
7980 subsequently reset. The exit status is true unless a
7982 does not exist or is readonly.
7984 \fBwait\fP [\fIn\fP]
7985 Wait for the specified process and return its termination
7989 ID or a job specification; if a job spec is given, all processes
7990 in that job's pipeline are waited for. If
7992 is not given, all currently active child processes
7993 are waited for, and the return status is zero. If
7995 specifies a non-existent process or job, the return status is
7996 127. Otherwise, the return status is the exit status of the last
7997 process or job waited for.
8000 .SH "RESTRICTED SHELL"
8006 is started with the name
8010 option is supplied at invocation,
8011 the shell becomes restricted.
8012 A restricted shell is used to
8013 set up an environment more controlled than the standard shell.
8014 It behaves identically to
8016 with the exception that the following are disallowed or not performed:
8018 changing directories with \fBcd\fP
8020 setting or unsetting the values of
8027 specifying command names containing
8030 specifying a file name containing a
8032 as an argument to the
8036 Specifying a filename containing a slash as an argument to the
8042 importing function definitions from the shell environment at startup
8044 parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
8046 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
8050 builtin command to replace the shell with another command
8052 adding or deleting builtin commands with the
8066 turning off restricted mode with
8067 \fBset +r\fP or \fBset +o restricted\fP.
8069 These restrictions are enforced after any startup files are read.
8071 When a command that is found to be a shell script is executed (see
8073 .B "COMMAND EXECUTION"
8076 turns off any restrictions in the shell spawned to execute the
8083 \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
8085 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
8087 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
8089 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
8091 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
8093 \fIemacs\fP(1), \fIvi\fP(1)
8101 The \fBbash\fP executable
8104 The systemwide initialization file, executed for login shells
8107 The personal initialization file, executed for login shells
8110 The individual per-interactive-shell startup file
8113 The individual login shell cleanup file, executed when a login shell exits
8116 Individual \fIreadline\fP initialization file
8119 Brian Fox, Free Software Foundation
8123 Chet Ramey, Case Western Reserve University
8127 If you find a bug in
8129 you should report it. But first, you should
8130 make sure that it really is a bug, and that it appears in the latest
8135 Once you have determined that a bug actually exists, use the
8137 command to submit a bug report.
8138 If you have a fix, you are encouraged to mail that as well!
8139 Suggestions and `philosophical' bug reports may be mailed
8140 to \fIbug-bash@gnu.org\fP or posted to the Usenet
8144 ALL bug reports should include:
8148 The version number of \fBbash\fR
8150 The hardware and operating system
8152 The compiler used to compile
8154 A description of the bug behaviour
8156 A short script or `recipe' which exercises the bug
8160 inserts the first three items automatically into the template
8161 it provides for filing a bug report.
8163 Comments and bug reports concerning
8164 this manual page should be directed to
8165 .IR chet@ins.CWRU.Edu .
8168 It's too big and too slow.
8170 There are some subtle differences between
8172 and traditional versions of
8174 mostly because of the
8179 Aliases are confusing in some uses.
8181 Shell builtin commands and functions are not stoppable/restartable.
8183 Compound commands and command sequences of the form `a ; b ; c'
8184 are not handled gracefully when process suspension is attempted.
8185 When a process is stopped, the shell immediately executes the next
8186 command in the sequence.
8187 It suffices to place the sequence of commands between
8188 parentheses to force it into a subshell, which may be stopped as
8191 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
8192 parsed until substitution is attempted. This will delay error
8193 reporting until some time after the command is entered.
8195 Array variables may not (yet) be exported.