2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
9 .\" Last Change: Sat Jun 26 14:26:44 EDT 2004
11 .\" bash_builtins, strip all but Built-Ins section
14 .TH BASH 1 "2004 June 26" "GNU Bash-3.0"
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-2004 by the Free Software Foundation, Inc.
55 .if t Bash is Copyright \(co 1989-2004 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 is
93 act as if it had been invoked as a login shell (see
101 option is present, the shell becomes
105 .B "RESTRICTED SHELL"
111 option is present, or if no arguments remain after option
112 processing, then commands are read from the standard input.
113 This option allows the positional parameters to be set
114 when invoking an interactive shell.
117 A list of all double-quoted strings preceded by \fB$\fP
118 is printed on the standard ouput.
119 These are the strings that
120 are subject to language translation when the current locale
121 is not \fBC\fP or \fBPOSIX\fP.
122 This implies the \fB\-n\fP option; no commands will be executed.
124 .B [\-+]O [\fIshopt_option\fP]
125 \fIshopt_option\fP is one of the shell options accepted by the
126 \fBshopt\fP builtin (see
128 .B SHELL BUILTIN COMMANDS
130 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
132 If \fIshopt_option\fP is not supplied, the names and values of the shell
133 options accepted by \fBshopt\fP are printed on the standard output.
134 If the invocation option is \fB+O\fP, the output is displayed in a format
135 that may be reused as input.
140 signals the end of options and disables further option processing.
141 Any arguments after the
143 are treated as filenames and arguments. An argument of
145 is equivalent to \fB\-\-\fP.
149 also interprets a number of multi-character options.
150 These options must appear on the command line before the
151 single-character options to be recognized.
156 Arrange for the debugger profile to be executed before the shell
157 starts. Turns on extended debugging mode (see the description of the
161 builtin below) and shell function tracing (see the description of the
162 \fB\-o functrace\fP option to the
166 .B \-\-dump\-po\-strings
167 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
168 \fBpo\fP (portable object) file format.
171 Equivalent to \fB\-D\fP.
174 Display a usage message on standard output and exit successfully.
176 \fB\-\-init\-file\fP \fIfile\fP
179 \fB\-\-rcfile\fP \fIfile\fP
181 Execute commands from
183 instead of the standard personal initialization file
185 if the shell is interactive (see
191 Equivalent to \fB\-l\fP.
196 library to read command lines when the shell is interactive.
199 Do not read either the system-wide startup file
201 or any of the personal initialization files
202 .IR ~/.bash_profile ,
208 reads these files when it is invoked as a login shell (see
214 Do not read and execute the personal initialization file
216 if the shell is interactive.
217 This option is on by default if the shell is invoked as
221 Change the behavior of \fBbash\fP where the default operation differs
222 from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
225 The shell becomes restricted (see
227 .B "RESTRICTED SHELL"
231 Equivalent to \fB\-v\fP.
234 Show version information for this instance of
236 on the standard output and exit successfully.
239 If arguments remain after option processing, and neither the
243 option has been supplied, the first argument is assumed to
244 be the name of a file containing shell commands.
247 is invoked in this fashion,
249 is set to the name of the file, and the positional parameters
250 are set to the remaining arguments.
252 reads and executes commands from this file, then exits.
253 \fBBash\fP's exit status is the exit status of the last command
254 executed in the script.
255 If no commands are executed, the exit status is 0.
256 An attempt is first made to open the file in the current directory, and,
257 if no file is found, then the shell searches the directories in
262 A \fIlogin shell\fP is one whose first character of argument zero is a
264 or one started with the
268 An \fIinteractive\fP shell is one started without non-option arguments
272 whose standard input and error are
273 both connected to terminals (as determined by
275 or one started with the
287 allowing a shell script or a startup file to test this state.
289 The following paragraphs describe how
291 executes its startup files.
292 If any of the files exist but cannot be read,
295 Tildes are expanded in file names as described below under
304 is invoked as an interactive login shell, or as a non-interactive shell
305 with the \fB\-\-login\fP option, it first reads and
306 executes commands from the file \fI/etc/profile\fP, if that
308 After reading that file, it looks for \fI~/.bash_profile\fP,
309 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
310 and executes commands from the first one that exists and is readable.
313 option may be used when the shell is started to inhibit this behavior.
315 When a login shell exits,
317 reads and executes commands from the file \fI~/.bash_logout\fP, if it
320 When an interactive shell that is not a login shell is started,
322 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
323 This may be inhibited by using the
326 The \fB\-\-rcfile\fP \fIfile\fP option will force
328 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
332 is started non-interactively, to run a shell script, for example, it
333 looks for the variable
336 in the environment, expands its value if it appears there, and uses the
337 expanded value as the name of a file to read and execute.
339 behaves as if the following command were executed:
342 .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
343 .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
349 variable is not used to search for the file name.
353 is invoked with the name
355 it tries to mimic the startup behavior of historical versions of
357 as closely as possible,
358 while conforming to the POSIX standard as well.
359 When invoked as an interactive login shell, or a non-interactive
360 shell with the \fB\-\-login\fP option, it first attempts to
361 read and execute commands from
368 option may be used to inhibit this behavior.
369 When invoked as an interactive shell with the name
372 looks for the variable
375 expands its value if it is defined, and uses the
376 expanded value as the name of a file to read and execute.
377 Since a shell invoked as
379 does not attempt to read and execute commands from any other startup
382 option has no effect.
383 A non-interactive shell invoked with the name
385 does not attempt to read any other startup files.
391 mode after the startup files are read.
399 command line option, it follows the POSIX standard for startup files.
400 In this mode, interactive shells expand the
403 variable and commands are read and executed from the file
404 whose name is the expanded value.
405 No other startup files are read.
408 attempts to determine when it is being run by the remote shell
409 daemon, usually \fIrshd\fP.
412 determines it is being run by \fIrshd\fP, it reads and executes
413 commands from \fI~/.bashrc\fP, if that file exists and is readable.
414 It will not do this if invoked as \fBsh\fP.
417 option may be used to inhibit this behavior, and the
419 option may be used to force another file to be read, but
420 \fIrshd\fP does not generally invoke the shell with those options
421 or allow them to be specified.
423 If the shell is started with the effective user (group) id not equal to the
424 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
425 files are read, shell functions are not inherited from the environment, the
428 variable, if it appears in the environment, is ignored,
429 and the effective user id is set to the real user id.
430 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
431 the same, but the effective user id is not reset.
434 The following definitions are used throughout the rest of this
442 A sequence of characters considered as a single unit by the shell.
449 consisting only of alphanumeric characters and underscores, and
450 beginning with an alphabetic character or an underscore. Also
455 A character that, when unquoted, separates words. One of the following:
459 .if t \fB| & ; ( ) < > space tab\fP
460 .if n \fB| & ; ( ) < > space tab\fP
465 A \fItoken\fP that performs a control function. It is one of the following
469 .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
470 .if n \fB|| & && ; ;; ( ) | <newline>\fP
474 \fIReserved words\fP are words that have a special meaning to the shell.
475 The following words are recognized as reserved when unquoted and either
476 the first word of a simple command (see
479 below) or the third word of a
487 .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
488 .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
493 A \fIsimple command\fP is a sequence of optional variable assignments
494 followed by \fBblank\fP-separated words and redirections, and
495 terminated by a \fIcontrol operator\fP. The first word
496 specifies the command to be executed, and is passed as argument zero.
497 The remaining words are passed as arguments to the invoked command.
499 The return value of a \fIsimple command\fP is its exit status, or
500 128+\fIn\^\fP if the command is terminated by signal
504 A \fIpipeline\fP is a sequence of one or more commands separated by
507 The format for a pipeline is:
510 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
513 The standard output of
515 is connected via a pipe to the standard input of
517 This connection is performed before any redirections specified by the
523 The return status of a pipeline is the exit status of the last
524 command, unless the \fBpipefail\fP option is enabled.
525 If \fBpipefail\fP is enabled, the pipeline's return status is the
526 value of the last (rightmost) command to exit with a non-zero status,
527 or zero if all commands exit successfully.
530 precedes a pipeline, the exit status of that pipeline is the logical
531 negation of the exit status as described above.
532 The shell waits for all commands in the pipeline to
533 terminate before returning a value.
537 reserved word precedes a pipeline, the elapsed as well as user and
538 system time consumed by its execution are reported when the pipeline
540 The \fB\-p\fP option changes the output format to that specified by POSIX.
544 variable may be set to a format string that specifies how the timing
545 information should be displayed; see the description of
552 Each command in a pipeline is executed as a separate process (i.e., in a
556 A \fIlist\fP is a sequence of one or more pipelines separated by one
563 and optionally terminated by one of
569 Of these list operators,
573 have equal precedence, followed by
577 which have equal precedence.
579 A sequence of one or more newlines may appear in a \fIlist\fP instead
580 of a semicolon to delimit commands.
582 If a command is terminated by the control operator
584 the shell executes the command in the \fIbackground\fP
585 in a subshell. The shell does not wait for the command to
586 finish, and the return status is 0. Commands separated by a
588 are executed sequentially; the shell waits for each
589 command to terminate in turn. The return status is the
590 exit status of the last command executed.
592 The control operators
596 denote AND lists and OR lists, respectively.
597 An AND list has the form
600 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
604 is executed if, and only if,
606 returns an exit status of zero.
608 An OR list has the form
611 \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
616 is executed if and only if
618 returns a non-zero exit status. The return status of
619 AND and OR lists is the exit status of the last command
620 executed in the list.
621 .SS Compound Commands
623 A \fIcompound command\fP is one of the following:
626 \fIlist\fP is executed in a subshell environment (see
628 \fBCOMMAND EXECUTION ENVIRONMENT\fP
630 Variable assignments and builtin
631 commands that affect the shell's environment do not remain in effect
632 after the command completes. The return status is the exit status of
636 \fIlist\fP is simply executed in the current shell environment.
637 \fIlist\fP must be terminated with a newline or semicolon.
638 This is known as a \fIgroup command\fP.
639 The return status is the exit status of
641 Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
642 \fB}\fP are \fIreserved words\fP and must occur where a reserved
643 word is permitted to be recognized. Since they do not cause a word
644 break, they must be separated from \fIlist\fP by whitespace.
647 The \fIexpression\fP is evaluated according to the rules described
650 .BR "ARITHMETIC EVALUATION" .
651 If the value of the expression is non-zero, the return status is 0;
652 otherwise the return status is 1. This is exactly equivalent to
653 \fBlet "\fIexpression\fP"\fR.
655 \fB[[\fP \fIexpression\fP \fB]]\fP
656 Return a status of 0 or 1 depending on the evaluation of
657 the conditional expression \fIexpression\fP.
658 Expressions are composed of the primaries described below under
660 .BR "CONDITIONAL EXPRESSIONS" .
661 Word splitting and pathname expansion are not performed on the words
662 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
663 variable expansion, arithmetic expansion, command substitution, process
664 substitution, and quote removal are performed.
665 Conditional operators such as \fB\-f\fP must be unquoted to be recognized
669 When the \fB==\fP and \fB!=\fP operators are used, the string to the
670 right of the operator is considered a pattern and matched according
671 to the rules described below under \fBPattern Matching\fP.
672 The return value is 0 if the string matches or does not match
673 the pattern, respectively, and 1 otherwise.
674 Any part of the pattern may be quoted to force it to be matched as a
678 An additional binary operator, \fB=~\fP, is available, with the same
679 precedence as \fB==\fP and \fB!=\fP.
680 When it is used, the string to the right of the operator is considered
681 an extended regular expression and matched accordingly (as in \fIregex\fP(3)).
682 The return value is 0 if the string matches
683 the pattern, and 1 otherwise.
684 If the regular expression is syntactically incorrect, the conditional
685 expression's return value is 2.
688 is enabled, the match is performed without regard to the case
689 of alphabetic characters.
690 Substrings matched by parenthesized subexpressions within the regular
691 expression are saved in the array variable \fBBASH_REMATCH\fP.
692 The element of \fBBASH_REMATCH\fP with index 0 is the portion of the string
693 matching the entire regular expression.
694 The element of \fBBASH_REMATCH\fP with index \fIn\fP is the portion of the
695 string matching the \fIn\fPth parenthesized subexpression.
698 Expressions may be combined using the following operators, listed
699 in decreasing order of precedence:
705 .B ( \fIexpression\fP )
706 Returns the value of \fIexpression\fP.
707 This may be used to override the normal precedence of operators.
709 .B ! \fIexpression\fP
714 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
721 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
722 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
733 operators do not evaluate \fIexpression2\fP if the value of
734 \fIexpression1\fP is sufficient to determine the return value of
735 the entire conditional expression.
738 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
739 The list of words following \fBin\fP is expanded, generating a list
741 The variable \fIname\fP is set to each element of this list
742 in turn, and \fIlist\fP is executed each time.
743 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
744 \fIlist\fP once for each positional parameter that is set (see
748 The return status is the exit status of the last command that executes.
749 If the expansion of the items following \fBin\fP results in an empty
750 list, no commands are executed, and the return status is 0.
752 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
753 First, the arithmetic expression \fIexpr1\fP is evaluated according
754 to the rules described below under
756 .BR "ARITHMETIC EVALUATION" .
757 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
758 until it evaluates to zero.
759 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
760 executed and the arithmetic expression \fIexpr3\fP is evaluated.
761 If any expression is omitted, it behaves as if it evaluates to 1.
762 The return value is the exit status of the last command in \fIlist\fP
763 that is executed, or false if any of the expressions is invalid.
765 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
766 The list of words following \fBin\fP is expanded, generating a list
767 of items. The set of expanded words is printed on the standard
768 error, each preceded by a number. If the \fBin\fP
769 \fIword\fP is omitted, the positional parameters are printed (see
774 prompt is then displayed and a line read from the standard input.
775 If the line consists of a number corresponding to one of
776 the displayed words, then the value of
778 is set to that word. If the line is empty, the words and prompt
779 are displayed again. If EOF is read, the command completes. Any
780 other value read causes
782 to be set to null. The line read is saved in the variable
786 is executed after each selection until a
791 is the exit status of the last command executed in
793 or zero if no commands were executed.
795 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
796 ... ) \fIlist\fP ;; ] ... \fBesac\fP
797 A \fBcase\fP command first expands \fIword\fP, and tries to match
798 it against each \fIpattern\fP in turn, using the same matching rules
799 as for pathname expansion (see
800 .B Pathname Expansion
801 below). When a match is found, the
802 corresponding \fIlist\fP is executed. After the first match, no
803 subsequent matches are attempted. The exit status is zero if no
804 pattern matches. Otherwise, it is the exit status of the
805 last command executed in \fIlist\fP.
807 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
808 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
809 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
813 is executed. If its exit status is zero, the
814 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
815 \fIlist\fP is executed in turn, and if its exit status is zero,
816 the corresponding \fBthen\fP \fIlist\fP is executed and the
817 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
818 executed, if present. The exit status is the exit status of the
819 last command executed, or zero if no condition tested true.
821 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
824 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
826 The \fBwhile\fP command continuously executes the \fBdo\fP
827 \fIlist\fP as long as the last command in \fIlist\fP returns
828 an exit status of zero. The \fBuntil\fP command is identical
829 to the \fBwhile\fP command, except that the test is negated;
833 is executed as long as the last command in
835 returns a non-zero exit status.
836 The exit status of the \fBwhile\fP and \fBuntil\fP commands
838 of the last \fBdo\fP \fIlist\fP command executed, or zero if
840 .SS Shell Function Definitions
842 A shell function is an object that is called like a simple command and
843 executes a compound command with a new set of positional parameters.
844 Shell functions are declared as follows:
846 [ \fBfunction\fP ] \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP]
847 This defines a function named \fIname\fP.
848 The reserved word \fBfunction\fP is optional.
849 If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
850 The \fIbody\fP of the function is the compound command
852 (see \fBCompound Commands\fP above).
853 That command is usually a \fIlist\fP of commands between { and }, but
854 may be any command listed under \fBCompound Commands\fP above.
855 \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the
856 name of a simple command.
857 Any redirections (see
860 below) specified when a function is defined are performed
861 when the function is executed.
862 The exit status of a function definition is zero unless a syntax error
863 occurs or a readonly function with the same name already exists.
864 When executed, the exit status of a function is the exit status of the
865 last command executed in the body. (See
870 In a non-interactive shell, or an interactive shell in which the
871 .B interactive_comments
874 builtin is enabled (see
876 .B "SHELL BUILTIN COMMANDS"
877 below), a word beginning with
879 causes that word and all remaining characters on that line to
880 be ignored. An interactive shell without the
881 .B interactive_comments
882 option enabled does not allow comments. The
883 .B interactive_comments
884 option is on by default in interactive shells.
886 \fIQuoting\fP is used to remove the special meaning of certain
887 characters or words to the shell. Quoting can be used to
888 disable special treatment for special characters, to prevent
889 reserved words from being recognized as such, and to prevent
892 Each of the \fImetacharacters\fP listed above under
895 has special meaning to the shell and must be quoted if it is to
898 When the command history expansion facilities are being used, the
899 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
900 to prevent history expansion.
902 There are three quoting mechanisms: the
903 .IR "escape character" ,
904 single quotes, and double quotes.
906 A non-quoted backslash (\fB\e\fP) is the
907 .IR "escape character" .
908 It preserves the literal value of the next character that follows,
909 with the exception of <newline>. If a \fB\e\fP<newline> pair
910 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
911 is treated as a line continuation (that is, it is removed from the
912 input stream and effectively ignored).
914 Enclosing characters in single quotes preserves the literal value
915 of each character within the quotes. A single quote may not occur
916 between single quotes, even when preceded by a backslash.
918 Enclosing characters in double quotes preserves the literal value
919 of all characters within the quotes, with the exception of
928 retain their special meaning within double quotes. The backslash
929 retains its special meaning only when followed by one of the following
937 A double quote may be quoted within double quotes by preceding it with
939 When command history is being used, the double quote may not be used to
940 quote the history expansion character.
942 The special parameters
946 have special meaning when in double
952 Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
953 word expands to \fIstring\fP, with backslash-escaped characters replaced
954 as specifed by the ANSI C standard. Backslash escape sequences, if
955 present, are decoded as follows:
990 the eight-bit character whose value is the octal value \fInnn\fP
991 (one to three digits)
994 the eight-bit character whose value is the hexadecimal value \fIHH\fP
995 (one or two hex digits)
998 a control-\fIx\fP character
1002 The expanded result is single-quoted, as if the dollar sign had
1005 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
1006 the string to be translated according to the current locale.
1007 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
1009 If the string is translated and replaced, the replacement is
1014 is an entity that stores values.
1017 a number, or one of the special characters listed below under
1018 .BR "Special Parameters" .
1021 is a parameter denoted by a
1023 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
1024 Attributes are assigned using the
1026 builtin command (see
1030 .BR "SHELL BUILTIN COMMANDS" ).
1032 A parameter is set if it has been assigned a value. The null string is
1033 a valid value. Once a variable is set, it may be unset only by using
1036 builtin command (see
1038 .B SHELL BUILTIN COMMANDS
1043 may be assigned to by a statement of the form
1046 \fIname\fP=[\fIvalue\fP]
1051 is not given, the variable is assigned the null string. All
1053 undergo tilde expansion, parameter and variable expansion,
1054 command substitution, arithmetic expansion, and quote
1058 below). If the variable has its
1062 is evaluated as an arithmetic expression even if the $((...)) expansion is
1064 .B "Arithmetic Expansion"
1066 Word splitting is not performed, with the exception
1067 of \fB"$@"\fP as explained below under
1068 .BR "Special Parameters" .
1069 Pathname expansion is not performed.
1070 Assignment statements may also appear as arguments to the
1079 .SS Positional Parameters
1082 .I positional parameter
1083 is a parameter denoted by one or more
1084 digits, other than the single digit 0. Positional parameters are
1085 assigned from the shell's arguments when it is invoked,
1086 and may be reassigned using the
1088 builtin command. Positional parameters may not be assigned to
1089 with assignment statements. The positional parameters are
1090 temporarily replaced when a shell function is executed (see
1095 When a positional parameter consisting of more than a single
1096 digit is expanded, it must be enclosed in braces (see
1100 .SS Special Parameters
1102 The shell treats several parameters specially. These parameters may
1103 only be referenced; assignment to them is not allowed.
1107 Expands to the positional parameters, starting from one. When the
1108 expansion occurs within double quotes, it expands to a single word
1109 with the value of each parameter separated by the first character
1113 special variable. That is, "\fB$*\fP" is equivalent
1114 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1116 is the first character of the value of the
1122 is unset, the parameters are separated by spaces.
1126 is null, the parameters are joined without intervening separators.
1129 Expands to the positional parameters, starting from one. When the
1130 expansion occurs within double quotes, each parameter expands to a
1131 separate word. That is, "\fB$@\fP" is equivalent to
1132 "\fB$1\fP" "\fB$2\fP" ...
1133 When there are no positional parameters, "\fB$@\fP" and
1135 expand to nothing (i.e., they are removed).
1138 Expands to the number of positional parameters in decimal.
1141 Expands to the status of the most recently executed foreground
1145 Expands to the current option flags as specified upon invocation,
1148 builtin command, or those set by the shell itself
1154 Expands to the process ID of the shell. In a () subshell, it
1155 expands to the process ID of the current shell, not the
1159 Expands to the process ID of the most recently executed background
1160 (asynchronous) command.
1163 Expands to the name of the shell or shell script. This is set at
1164 shell initialization. If
1166 is invoked with a file of commands,
1168 is set to the name of that file. If
1174 is set to the first argument after the string to be
1175 executed, if one is present. Otherwise, it is set
1176 to the file name used to invoke
1178 as given by argument zero.
1181 At shell startup, set to the absolute file name of the shell or shell
1182 script being executed as passed in the argument list.
1183 Subsequently, expands to the last argument to the previous command,
1185 Also set to the full file name of each command executed and placed in
1186 the environment exported to that command.
1187 When checking mail, this parameter holds the name of the mail file
1188 currently being checked.
1192 The following variables are set by the shell:
1197 Expands to the full file name used to invoke this instance of
1201 An array variable whose values are the number of parameters in each
1202 frame of the current bash execution call stack. The number of
1203 parameters to the current subroutine (shell function or script executed
1204 with \fB.\fP or \fBsource\fP) is at the top of the stack. When a
1205 subroutine is executed, the number of parameters passed is pushed onto
1209 An array variable containing all of the parameters in the current bash
1210 execution call stack. The final parameter of the last subroutine call
1211 is at the top of the stack; the first parameter of the initial call is
1212 at the bottom. When a subroutine is executed, the parameters supplied
1213 are pushed onto \fBBASH_ARGV\fP.
1216 The command currently being executed or about to be executed, unless the
1217 shell is executing a command as the result of a trap,
1218 in which case it is the command executing at the time of the trap.
1220 .B BASH_EXECUTION_STRING
1221 The command argument to the \fB\-c\fP invocation option.
1224 An array variable whose members are the line numbers in source files
1225 corresponding to each member of @var{FUNCNAME}.
1226 \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
1227 file where \fB${FUNCNAME[\fP\fI$i + 1\fP\fB]}\fP was called.
1228 The corresponding source file name is \fB${BASH_SOURCE[\fP\fI$i + 1\fP\fB]}\fB.
1229 Use \fBLINENO\fP to obtain the current line number.
1232 An array variable whose members are assigned by the \fB=~\fP binary
1233 operator to the \fB[[\fP conditional command.
1234 The element with index 0 is the portion of the string
1235 matching the entire regular expression.
1236 The element with index \fIn\fP is the portion of the
1237 string matching the \fIn\fPth parenthesized subexpression.
1238 This variable is read-only.
1241 An array variable whose members are the source filenames corresponding
1242 to the elements in the \fBFUNCNAME\fP array variable.
1245 Incremented by one each time a subshell or subshell environment is spawned.
1246 The initial value is 0.
1249 A readonly array variable whose members hold version information for
1252 The values assigned to the array members are as follows:
1257 .B BASH_VERSINFO[\fR0\fP]
1258 The major version number (the \fIrelease\fP).
1260 .B BASH_VERSINFO[\fR1\fP]
1261 The minor version number (the \fIversion\fP).
1263 .B BASH_VERSINFO[\fR2\fP]
1266 .B BASH_VERSINFO[\fR3\fP]
1269 .B BASH_VERSINFO[\fR4\fP]
1270 The release status (e.g., \fIbeta1\fP).
1272 .B BASH_VERSINFO[\fR5\fP]
1273 The value of \fBMACHTYPE\fP.
1278 Expands to a string describing the version of this instance of
1282 An index into \fB${COMP_WORDS}\fP of the word containing the current
1284 This variable is available only in shell functions invoked by the
1285 programmable completion facilities (see \fBProgrammable Completion\fP
1289 The current command line.
1290 This variable is available only in shell functions and external
1291 commands invoked by the
1292 programmable completion facilities (see \fBProgrammable Completion\fP
1296 The index of the current cursor position relative to the beginning of
1297 the current command.
1298 If the current cursor position is at the end of the current command,
1299 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1300 This variable is available only in shell functions and external
1301 commands invoked by the
1302 programmable completion facilities (see \fBProgrammable Completion\fP
1306 The set of characters that the Readline library treats as word
1307 separators when performing word completion.
1311 is unset, it loses its special properties, even if it is
1315 An array variable (see \fBArrays\fP below) consisting of the individual
1316 words in the current command line.
1317 This variable is available only in shell functions invoked by the
1318 programmable completion facilities (see \fBProgrammable Completion\fP
1322 An array variable (see
1324 below) containing the current contents of the directory stack.
1325 Directories appear in the stack in the order they are displayed by the
1328 Assigning to members of this array variable may be used to modify
1329 directories already in the stack, but the
1333 builtins must be used to add and remove directories.
1334 Assignment to this variable will not change the current directory.
1338 is unset, it loses its special properties, even if it is
1342 Expands to the effective user ID of the current user, initialized at
1343 shell startup. This variable is readonly.
1346 An array variable containing the names of all shell functions
1347 currently in the execution call stack.
1348 The element with index 0 is the name of any currently-executing
1350 The bottom-most element is "main".
1351 This variable exists only when a shell function is executing.
1355 have no effect and return an error status.
1359 is unset, it loses its special properties, even if it is
1363 An array variable containing the list of groups of which the current
1368 have no effect and return an error status.
1372 is unset, it loses its special properties, even if it is
1376 The history number, or index in the history list, of the current
1381 is unset, it loses its special properties, even if it is
1385 Automatically set to the name of the current host.
1388 Automatically set to a string that uniquely
1389 describes the type of machine on which
1392 The default is system-dependent.
1395 Each time this parameter is referenced, the shell substitutes
1396 a decimal number representing the current sequential line number
1397 (starting with 1) within a script or function. When not in a
1398 script or function, the value substituted is not guaranteed to
1403 is unset, it loses its special properties, even if it is
1407 Automatically set to a string that fully describes the system
1410 is executing, in the standard GNU \fIcpu-company-system\fP format.
1411 The default is system-dependent.
1414 The previous working directory as set by the
1419 The value of the last option argument processed by the
1421 builtin command (see
1423 .B SHELL BUILTIN COMMANDS
1427 The index of the next argument to be processed by the
1429 builtin command (see
1431 .B SHELL BUILTIN COMMANDS
1435 Automatically set to a string that
1436 describes the operating system on which
1439 The default is system-dependent.
1442 An array variable (see
1444 below) containing a list of exit status values from the processes
1445 in the most-recently-executed foreground pipeline (which may
1446 contain only a single command).
1449 The process ID of the shell's parent. This variable is readonly.
1452 The current working directory as set by the
1457 Each time this parameter is referenced, a random integer between
1459 generated. The sequence of random numbers may be initialized by assigning
1466 is unset, it loses its special properties, even if it is
1470 Set to the line of input read by the
1472 builtin command when no arguments are supplied.
1475 Each time this parameter is
1476 referenced, the number of seconds since shell invocation is returned. If a
1477 value is assigned to
1480 the value returned upon subsequent
1482 the number of seconds since the assignment plus the value assigned.
1486 is unset, it loses its special properties, even if it is
1490 A colon-separated list of enabled shell options. Each word in
1491 the list is a valid argument for the
1495 builtin command (see
1497 .B "SHELL BUILTIN COMMANDS"
1498 below). The options appearing in
1501 are those reported as
1504 If this variable is in the environment when
1506 starts up, each shell option in the list will be enabled before
1507 reading any startup files.
1508 This variable is read-only.
1511 Incremented by one each time an instance of
1516 Expands to the user ID of the current user, initialized at shell startup.
1517 This variable is readonly.
1520 The following variables are used by the shell. In some cases,
1522 assigns a default value to a variable; these cases are noted
1528 If this parameter is set when \fBbash\fP is executing a shell script,
1529 its value is interpreted as a filename containing commands to
1530 initialize the shell, as in
1535 is subjected to parameter expansion, command substitution, and arithmetic
1536 expansion before being interpreted as a file name.
1539 is not used to search for the resultant file name.
1542 The search path for the
1545 This is a colon-separated list of directories in which the shell looks
1546 for destination directories specified by the
1550 .if t \f(CW".:~:/usr"\fP.
1554 Used by the \fBselect\fP builtin command to determine the terminal width
1555 when printing selection lists. Automatically set upon receipt of a SIGWINCH.
1558 An array variable from which \fBbash\fP reads the possible completions
1559 generated by a shell function invoked by the programmable completion
1560 facility (see \fBProgrammable Completion\fP below).
1563 If \fBbash\fP finds this variable in the environment when the shell starts
1567 it assumes that the shell is running in an emacs shell buffer and disables
1571 The default editor for the
1576 A colon-separated list of suffixes to ignore when performing
1577 filename completion (see
1581 A filename whose suffix matches one of the entries in
1584 is excluded from the list of matched filenames.
1586 .if t \f(CW".o:~"\fP.
1590 A colon-separated list of patterns defining the set of filenames to
1591 be ignored by pathname expansion.
1592 If a filename matched by a pathname expansion pattern also matches one
1596 it is removed from the list of matches.
1599 A colon-separated list of values controlling how commands are saved on
1601 If the list of values includes
1603 lines which begin with a
1605 character are not saved in the history list.
1608 causes lines matching the previous history entry to not be saved.
1611 is shorthand for \fIignorespace\fP and \fIignoredups\fP.
1614 causes all previous lines matching the current line to be removed from
1615 the history list before that line is saved.
1616 Any value not in the above list is ignored.
1617 If \fBHISTCONTROL\fP is unset, or does not include a valid value,
1618 all lines read by the shell parser are saved on the history list,
1619 subject to the value of
1621 The second and subsequent lines of a multi-line compound command are
1622 not tested, and are added to the history regardless of the value of
1626 The name of the file in which command history is saved (see
1629 below). The default value is \fI~/.bash_history\fP. If unset, the
1630 command history is not saved when an interactive shell exits.
1633 The maximum number of lines contained in the history file. When this
1634 variable is assigned a value, the history file is truncated, if
1635 necessary, to contain no more than that number of lines. The default
1636 value is 500. The history file is also truncated to this size after
1637 writing it when an interactive shell exits.
1640 A colon-separated list of patterns used to decide which command lines
1641 should be saved on the history list. Each pattern is anchored at the
1642 beginning of the line and must match the complete line (no implicit
1643 `\fB*\fP' is appended). Each pattern is tested against the line
1644 after the checks specified by
1647 In addition to the normal shell pattern matching characters, `\fB&\fP'
1648 matches the previous history line. `\fB&\fP' may be escaped using a
1649 backslash; the backslash is removed before attempting a match.
1650 The second and subsequent lines of a multi-line compound command are
1651 not tested, and are added to the history regardless of the value of
1655 The number of commands to remember in the command history (see
1658 below). The default value is 500.
1661 If this variable is set and not null, its value is used as a format string
1662 for \fIstrftime\fP(3) to print the time stamp associated with each history
1663 entry displayed by the \fBhistory\fP builtin.
1664 If this variable is set, time stamps are written to the history file so
1665 they may be preserved across shell sessions.
1668 The home directory of the current user; the default argument for the
1669 \fBcd\fP builtin command.
1670 The value of this variable is also used when performing tilde expansion.
1673 Contains the name of a file in the same format as
1675 that should be read when the shell needs to complete a
1677 The list of possible hostname completions may be changed while the
1679 the next time hostname completion is attempted after the
1682 adds the contents of the new file to the existing list.
1686 is set, but has no value, \fBbash\fP attempts to read
1688 to obtain the list of possible hostname completions.
1692 is unset, the hostname list is cleared.
1696 .I Internal Field Separator
1698 for word splitting after expansion and to
1699 split lines into words with the
1701 builtin command. The default value is
1702 ``<space><tab><newline>''.
1706 action of an interactive shell on receipt of an
1709 character as the sole input. If set, the value is the number of
1713 characters which must be
1714 typed as the first characters on an input line before
1716 exits. If the variable exists but does not have a numeric value, or
1717 has no value, the default value is 10. If it does not exist,
1720 signifies the end of input to the shell.
1723 The filename for the
1725 startup file, overriding the default of
1733 Used to determine the locale category for any category not specifically
1734 selected with a variable starting with \fBLC_\fP.
1737 This variable overrides the value of \fBLANG\fP and any other
1738 \fBLC_\fP variable specifying a locale category.
1741 This variable determines the collation order used when sorting the
1742 results of pathname expansion, and determines the behavior of range
1743 expressions, equivalence classes, and collating sequences within
1744 pathname expansion and pattern matching.
1747 This variable determines the interpretation of characters and the
1748 behavior of character classes within pathname expansion and pattern
1752 This variable determines the locale used to translate double-quoted
1753 strings preceded by a \fB$\fP.
1756 This variable determines the locale category used for number formatting.
1759 Used by the \fBselect\fP builtin command to determine the column length
1760 for printing selection lists. Automatically set upon receipt of a SIGWINCH.
1763 If this parameter is set to a file name and the
1766 variable is not set,
1768 informs the user of the arrival of mail in the specified file.
1774 checks for mail. The default is 60 seconds. When it is time to check
1775 for mail, the shell does so before displaying the primary prompt.
1776 If this variable is unset, or set to a value that is not a number
1777 greater than or equal to zero, the shell disables mail checking.
1780 A colon-separated list of file names to be checked for mail.
1781 The message to be printed when mail arrives in a particular file
1782 may be specified by separating the file name from the message with a `?'.
1783 When used in the text of the message, \fB$_\fP expands to the name of
1784 the current mailfile.
1788 \fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1791 supplies a default value for this variable, but the location of the user
1792 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
1796 If set to the value 1,
1798 displays error messages generated by the
1800 builtin command (see
1802 .B SHELL BUILTIN COMMANDS
1806 is initialized to 1 each time the shell is invoked or a shell
1810 The search path for commands. It
1811 is a colon-separated list of directories in which
1812 the shell looks for commands (see
1814 .B COMMAND EXECUTION
1816 A zero-length (null) directory name in the value of \fBPATH\fP indicates the
1818 A null directory name may appear as two adjacent colons, or as an initial
1820 The default path is system-dependent,
1821 and is set by the administrator who installs
1824 .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin\fP.
1825 .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
1828 If this variable is in the environment when \fBbash\fP starts, the shell
1829 enters \fIposix mode\fP before reading the startup files, as if the
1831 invocation option had been supplied. If it is set while the shell is
1832 running, \fBbash\fP enables \fIposix mode\fP, as if the command
1833 .if t \f(CWset -o posix\fP
1834 .if n \fIset -o posix\fP
1838 If set, the value is executed as a command prior to issuing each primary
1842 The value of this parameter is expanded (see
1845 below) and used as the primary prompt string. The default value is
1846 ``\fB\es\-\ev\e$ \fP''.
1849 The value of this parameter is expanded as with
1851 and used as the secondary prompt string. The default is
1855 The value of this parameter is used as the prompt for the
1863 The value of this parameter is expanded as with
1865 and the value is printed before each command
1867 displays during an execution trace. The first character of
1870 is replicated multiple times, as necessary, to indicate multiple
1871 levels of indirection. The default is ``\fB+ \fP''.
1874 The full pathname to the shell is kept in this environment variable.
1875 If it is not set when the shell starts,
1877 assigns to it the full pathname of the current user's login shell.
1880 The value of this parameter is used as a format string specifying
1881 how the timing information for pipelines prefixed with the
1883 reserved word should be displayed.
1884 The \fB%\fP character introduces an escape sequence that is
1885 expanded to a time value or other information.
1886 The escape sequences and their meanings are as follows; the
1887 braces denote optional portions.
1896 The elapsed time in seconds.
1899 The number of CPU seconds spent in user mode.
1902 The number of CPU seconds spent in system mode.
1905 The CPU percentage, computed as (%U + %S) / %R.
1909 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1910 the number of fractional digits after a decimal point.
1911 A value of 0 causes no decimal point or fraction to be output.
1912 At most three places after the decimal point may be specified;
1913 values of \fIp\fP greater than 3 are changed to 3.
1914 If \fIp\fP is not specified, the value 3 is used.
1916 The optional \fBl\fP specifies a longer format, including
1917 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1918 The value of \fIp\fP determines whether or not the fraction is
1921 If this variable is not set, \fBbash\fP acts as if it had the
1922 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1923 If the value is null, no timing information is displayed.
1924 A trailing newline is added when the format string is displayed.
1927 If set to a value greater than zero, \fBTMOUT\fP is treated as the
1928 default timeout for the \fBread\fP builtin.
1929 The \fBselect\fP command terminates if input does not arrive
1930 after \fBTMOUT\fP seconds when input is coming from a terminal.
1931 In an interactive shell, the value is interpreted as the
1932 number of seconds to wait for input after issuing the primary prompt.
1934 terminates after waiting for that number of seconds if input does
1938 This variable controls how the shell interacts with the user and
1939 job control. If this variable is set, single word simple
1940 commands without redirections are treated as candidates for resumption
1941 of an existing stopped job. There is no ambiguity allowed; if there is
1942 more than one job beginning with the string typed, the job most recently
1943 accessed is selected. The
1945 of a stopped job, in this context, is the command line used to
1949 the string supplied must match the name of a stopped job exactly;
1952 the string supplied needs to match a substring of the name of a
1955 value provides functionality analogous to the
1960 below). If set to any other value, the supplied string must
1961 be a prefix of a stopped job's name; this provides functionality
1967 The two or three characters which control history expansion
1968 and tokenization (see
1970 .B HISTORY EXPANSION
1971 below). The first character is the \fIhistory expansion\fP character,
1972 the character which signals the start of a history
1973 expansion, normally `\fB!\fP'.
1974 The second character is the \fIquick substitution\fP
1975 character, which is used as shorthand for re-running the previous
1976 command entered, substituting one string for another in the command.
1977 The default is `\fB^\fP'.
1978 The optional third character is the character
1979 which indicates that the remainder of the line is a comment when found
1980 as the first character of a word, normally `\fB#\fP'. The history
1981 comment character causes history substitution to be skipped for the
1982 remaining words on the line. It does not necessarily cause the shell
1983 parser to treat the rest of the line as a comment.
1987 provides one-dimensional array variables. Any variable may be used as
1990 builtin will explicitly declare an array. There is no maximum
1991 limit on the size of an array, nor any requirement that members
1992 be indexed or assigned contiguously. Arrays are indexed using
1993 integers and are zero-based.
1995 An array is created automatically if any variable is assigned to using
1996 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
1998 is treated as an arithmetic expression that must evaluate to a number
1999 greater than or equal to zero. To explicitly declare an array, use
2000 .B declare \-a \fIname\fP
2003 .B SHELL BUILTIN COMMANDS
2005 .B declare \-a \fIname\fP[\fIsubscript\fP]
2006 is also accepted; the \fIsubscript\fP is ignored. Attributes may be
2007 specified for an array variable using the
2011 builtins. Each attribute applies to all members of an array.
2013 Arrays are assigned to using compound assignments of the form
2014 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
2015 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
2016 \fIstring\fP is required. If
2017 the optional brackets and subscript are supplied, that index is assigned to;
2018 otherwise the index of the element assigned is the last index assigned
2019 to by the statement plus one. Indexing starts at zero.
2020 This syntax is also accepted by the
2022 builtin. Individual array elements may be assigned to using the
2023 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
2025 Any element of an array may be referenced using
2026 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
2027 conflicts with pathname expansion. If
2028 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
2029 all members of \fIname\fP. These subscripts differ only when the
2030 word appears within double quotes. If the word is double-quoted,
2031 ${\fIname\fP[*]} expands to a single
2032 word with the value of each array member separated by the first
2036 special variable, and ${\fIname\fP[@]} expands each element of
2037 \fIname\fP to a separate word. When there are no array members,
2038 ${\fIname\fP[@]} expands to nothing. This is analogous to the expansion
2039 of the special parameters \fB*\fP and \fB@\fP (see
2040 .B Special Parameters
2041 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
2042 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
2043 \fB@\fP, the expansion is the number of elements in the array.
2044 Referencing an array variable without a subscript is equivalent to
2045 referencing element zero.
2049 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
2050 destroys the array element at index \fIsubscript\fP.
2051 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
2052 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
2053 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
2060 builtins each accept a
2062 option to specify an array. The
2066 option to assign a list of words read from the standard input
2071 builtins display array values in a way that allows them to be
2072 reused as assignments.
2074 Expansion is performed on the command line after it has been split into
2075 words. There are seven kinds of expansion performed:
2076 .IR "brace expansion" ,
2077 .IR "tilde expansion" ,
2078 .IR "parameter and variable expansion" ,
2079 .IR "command substitution" ,
2080 .IR "arithmetic expansion" ,
2081 .IR "word splitting" ,
2083 .IR "pathname expansion" .
2085 The order of expansions is: brace expansion, tilde expansion,
2086 parameter, variable and arithmetic expansion and
2087 command substitution
2088 (done in a left-to-right fashion), word splitting, and pathname
2091 On systems that can support it, there is an additional expansion
2092 available: \fIprocess substitution\fP.
2094 Only brace expansion, word splitting, and pathname expansion
2095 can change the number of words of the expansion; other expansions
2096 expand a single word to a single word.
2097 The only exceptions to this are the expansions of
2098 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
2099 as explained above (see
2104 .I "Brace expansion"
2105 is a mechanism by which arbitrary strings
2106 may be generated. This mechanism is similar to
2107 \fIpathname expansion\fP, but the filenames generated
2108 need not exist. Patterns to be brace expanded take
2109 the form of an optional
2111 followed by either a series of comma-separated strings or
2112 a sequence expression between a pair of braces, followed by
2115 The preamble is prefixed to each string contained
2116 within the braces, and the postscript is then appended
2117 to each resulting string, expanding left to right.
2119 Brace expansions may be nested. The results of each expanded
2120 string are not sorted; left to right order is preserved.
2121 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
2123 A sequence expression takes the form \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB}\fP,
2124 where \fIx\fP and \fIy\fP are either integers or single characters.
2125 When integers are supplied, the expression expands to each number between
2126 \fIx\fP and \fIy\fP, inclusive.
2127 When characters are supplied, the expression expands to each character
2128 lexicographically between \fIx\fP and \fIy\fP, inclusive. Note that
2129 both \fIx\fP and \fIy\fP must be of the same type.
2131 Brace expansion is performed before any other expansions,
2132 and any characters special to other expansions are preserved
2133 in the result. It is strictly textual.
2135 does not apply any syntactic interpretation to the context of the
2136 expansion or the text between the braces.
2138 A correctly-formed brace expansion must contain unquoted opening
2139 and closing braces, and at least one unquoted comma or a valid
2140 sequence expression.
2141 Any incorrectly formed brace expansion is left unchanged.
2142 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
2143 being considered part of a brace expression.
2144 To avoid conflicts with parameter expansion, the string \fB${\fP
2145 is not considered eligible for brace expansion.
2147 This construct is typically used as shorthand when the common
2148 prefix of the strings to be generated is longer than in the
2152 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2156 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2159 Brace expansion introduces a slight incompatibility with
2160 historical versions of
2163 does not treat opening or closing braces specially when they
2164 appear as part of a word, and preserves them in the output.
2166 removes braces from words as a consequence of brace
2167 expansion. For example, a word entered to
2170 appears identically in the output. The same word is
2175 If strict compatibility with
2181 option or disable brace expansion with the
2187 .B SHELL BUILTIN COMMANDS
2191 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2192 the characters preceding the first unquoted slash (or all characters,
2193 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2194 If none of the characters in the tilde-prefix are quoted, the
2195 characters in the tilde-prefix following the tilde are treated as a
2196 possible \fIlogin name\fP.
2197 If this login name is the null string, the tilde is replaced with the
2198 value of the shell parameter
2204 is unset, the home directory of the user executing the shell is
2205 substituted instead.
2206 Otherwise, the tilde-prefix is replaced with the home directory
2207 associated with the specified login name.
2209 If the tilde-prefix is a `~+', the value of the shell variable
2212 replaces the tilde-prefix.
2213 If the tilde-prefix is a `~\-', the value of the shell variable
2216 if it is set, is substituted.
2217 If the characters following the tilde in the tilde-prefix consist
2218 of a number \fIN\fP, optionally prefixed
2219 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2220 element from the directory stack, as it would be displayed by the
2222 builtin invoked with the tilde-prefix as an argument.
2223 If the characters following the tilde in the tilde-prefix consist of a
2224 number without a leading `+' or `\-', `+' is assumed.
2226 If the login name is invalid, or the tilde expansion fails, the word
2229 Each variable assignment is checked for unquoted tilde-prefixes immediately
2234 In these cases, tilde expansion is also performed.
2235 Consequently, one may use file names with tildes in assignments to
2243 and the shell assigns the expanded value.
2244 .SS Parameter Expansion
2246 The `\fB$\fP' character introduces parameter expansion,
2247 command substitution, or arithmetic expansion. The parameter name
2248 or symbol to be expanded may be enclosed in braces, which
2249 are optional but serve to protect the variable to be expanded from
2250 characters immediately following it which could be
2251 interpreted as part of the name.
2253 When braces are used, the matching ending brace is the first `\fB}\fP'
2254 not escaped by a backslash or within a quoted string, and not within an
2255 embedded arithmetic expansion, command substitution, or paramter
2261 The value of \fIparameter\fP is substituted. The braces are required
2264 is a positional parameter with more than one digit,
2267 is followed by a character which is not to be
2268 interpreted as part of its name.
2271 If the first character of \fIparameter\fP is an exclamation point,
2272 a level of variable indirection is introduced.
2273 \fBBash\fP uses the value of the variable formed from the rest of
2274 \fIparameter\fP as the name of the variable; this variable is then
2275 expanded and that value is used in the rest of the substitution, rather
2276 than the value of \fIparameter\fP itself.
2277 This is known as \fIindirect expansion\fP.
2278 The exceptions to this are the expansions of ${!\fIprefix\fP*} and
2279 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
2280 The exclamation point must immediately follow the left brace in order to
2281 introduce indirection.
2283 In each of the cases below, \fIword\fP is subject to tilde expansion,
2284 parameter expansion, command substitution, and arithmetic expansion.
2285 When not performing substring expansion, \fBbash\fP tests for a parameter
2286 that is unset or null; omitting the colon results in a test only for a
2287 parameter that is unset.
2291 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
2292 \fBUse Default Values\fP. If
2294 is unset or null, the expansion of
2296 is substituted. Otherwise, the value of
2300 ${\fIparameter\fP\fB:=\fP\fIword\fP}
2301 \fBAssign Default Values\fP.
2304 is unset or null, the expansion of
2310 is then substituted. Positional parameters and special parameters may
2311 not be assigned to in this way.
2313 ${\fIparameter\fP\fB:?\fP\fIword\fP}
2314 \fBDisplay Error if Null or Unset\fP.
2317 is null or unset, the expansion of \fIword\fP (or a message to that effect
2320 is not present) is written to the standard error and the shell, if it
2321 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
2324 ${\fIparameter\fP\fB:+\fP\fIword\fP}
2325 \fBUse Alternate Value\fP.
2328 is null or unset, nothing is substituted, otherwise the expansion of
2332 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
2335 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
2337 \fBSubstring Expansion.\fP
2338 Expands to up to \fIlength\fP characters of \fIparameter\fP
2339 starting at the character specified by \fIoffset\fP.
2340 If \fIlength\fP is omitted, expands to the substring of
2341 \fIparameter\fP starting at the character specified by \fIoffset\fP.
2342 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2345 ARITHMETIC EVALUATION
2347 \fIlength\fP must evaluate to a number greater than or equal to zero.
2348 If \fIoffset\fP evaluates to a number less than zero, the value
2349 is used as an offset from the end of the value of \fIparameter\fP.
2350 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2351 parameters beginning at \fIoffset\fP.
2352 If \fIparameter\fP is an array name indexed by @ or *,
2353 the result is the \fIlength\fP
2354 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2355 Substring indexing is zero-based unless the positional parameters
2356 are used, in which case the indexing starts at 1.
2358 ${\fB!\fP\fIprefix\fP\fB*\fP}
2361 ${\fB!\fP\fIprefix\fP\fB@\fP}
2363 Expands to the names of variables whose names begin with \fIprefix\fP,
2364 separated by the first character of the
2369 ${\fB!\fP\fIname\fP[\fI@\fP]}
2372 ${\fB!\fP\fIname\fP[\fI*\fP]}
2374 If \fIname\fP is an array variable, expands to the list of array indices
2375 (keys) assigned in \fIname\fP.
2376 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
2378 When \fI@\fP is used and the expansion appears within double quotes, each
2379 key expands to a separate word.
2381 ${\fB#\fP\fIparameter\fP}
2382 The length in characters of the value of \fIparameter\fP is substituted.
2389 the value substituted is the number of positional parameters.
2392 is an array name subscripted by
2396 the value substituted is the number of elements in the array.
2398 ${\fIparameter\fP\fB#\fP\fIword\fP}
2401 ${\fIparameter\fP\fB##\fP\fIword\fP}
2405 is expanded to produce a pattern just as in pathname
2406 expansion. If the pattern matches the beginning of
2409 then the result of the expansion is the expanded value of
2411 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2412 longest matching pattern (the ``\fB##\fP'' case) deleted.
2419 the pattern removal operation is applied to each positional
2420 parameter in turn, and the expansion is the resultant list.
2423 is an array variable subscripted with
2427 the pattern removal operation is applied to each member of the
2428 array in turn, and the expansion is the resultant list.
2430 ${\fIparameter\fP\fB%\fP\fIword\fP}
2433 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2435 The \fIword\fP is expanded to produce a pattern just as in
2437 If the pattern matches a trailing portion of the expanded value of
2439 then the result of the expansion is the expanded value of
2441 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2442 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2449 the pattern removal operation is applied to each positional
2450 parameter in turn, and the expansion is the resultant list.
2453 is an array variable subscripted with
2457 the pattern removal operation is applied to each member of the
2458 array in turn, and the expansion is the resultant list.
2460 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2463 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2465 The \fIpattern\fP is expanded to produce a pattern just as in
2467 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2468 against its value is replaced with \fIstring\fP.
2469 In the first form, only the first match is replaced.
2470 The second form causes all matches of \fIpattern\fP to be
2471 replaced with \fIstring\fP.
2472 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2473 of the expanded value of \fIparameter\fP.
2474 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2475 of the expanded value of \fIparameter\fP.
2476 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2477 and the \fB/\fP following \fIpattern\fP may be omitted.
2484 the substitution operation is applied to each positional
2485 parameter in turn, and the expansion is the resultant list.
2488 is an array variable subscripted with
2492 the substitution operation is applied to each member of the
2493 array in turn, and the expansion is the resultant list.
2494 .SS Command Substitution
2496 \fICommand substitution\fP allows the output of a command to replace
2497 the command name. There are two forms:
2501 \fB$(\fP\fIcommand\fP\|\fB)\fP
2505 \fB`\fP\fIcommand\fP\fB`\fP
2509 performs the expansion by executing \fIcommand\fP and
2510 replacing the command substitution with the standard output of the
2511 command, with any trailing newlines deleted.
2512 Embedded newlines are not deleted, but they may be removed during
2514 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2515 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2517 When the old-style backquote form of substitution is used,
2518 backslash retains its literal meaning except when followed by
2523 The first backquote not preceded by a backslash terminates the
2524 command substitution.
2525 When using the $(\^\fIcommand\fP\|) form, all characters between the
2526 parentheses make up the command; none are treated specially.
2528 Command substitutions may be nested. To nest when using the backquoted form,
2529 escape the inner backquotes with backslashes.
2531 If the substitution appears within double quotes, word splitting and
2532 pathname expansion are not performed on the results.
2533 .SS Arithmetic Expansion
2535 Arithmetic expansion allows the evaluation of an arithmetic expression
2536 and the substitution of the result. The format for arithmetic expansion is:
2539 \fB$((\fP\fIexpression\fP\fB))\fP
2544 is treated as if it were within double quotes, but a double quote
2545 inside the parentheses is not treated specially.
2546 All tokens in the expression undergo parameter expansion, string
2547 expansion, command substitution, and quote removal.
2548 Arithmetic expansions may be nested.
2550 The evaluation is performed according to the rules listed below under
2552 .BR "ARITHMETIC EVALUATION" .
2557 prints a message indicating failure and no substitution occurs.
2558 .SS Process Substitution
2560 \fIProcess substitution\fP is supported on systems that support named
2561 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2562 It takes the form of
2563 \fB<(\fP\fIlist\^\fP\fB)\fP
2565 \fB>(\fP\fIlist\^\fP\fB)\fP.
2566 The process \fIlist\fP is run with its input or output connected to a
2567 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2568 passed as an argument to the current command as the result of the
2569 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2570 the file will provide input for \fIlist\fP. If the
2571 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2572 argument should be read to obtain the output of \fIlist\fP.
2574 When available, process substitution is performed
2575 simultaneously with parameter and variable expansion,
2576 command substitution,
2577 and arithmetic expansion.
2580 The shell scans the results of
2581 parameter expansion,
2582 command substitution,
2584 arithmetic expansion
2585 that did not occur within double quotes for
2586 .IR "word splitting" .
2588 The shell treats each character of
2591 as a delimiter, and splits the results of the other
2592 expansions into words on these characters. If
2597 .BR <space><tab><newline> ,
2602 characters serves to delimit words. If
2605 has a value other than the default, then sequences of
2606 the whitespace characters
2610 are ignored at the beginning and end of the
2611 word, as long as the whitespace character is in the
2618 whitespace character).
2625 whitespace, along with any adjacent
2628 whitespace characters, delimits a field.
2632 whitespace characters is also treated as a delimiter.
2636 is null, no word splitting occurs.
2638 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2639 Unquoted implicit null arguments, resulting from the expansion of
2640 parameters that have no values, are removed.
2641 If a parameter with no value is expanded within double quotes, a
2642 null argument results and is retained.
2644 Note that if no expansion occurs, no splitting
2646 .SS Pathname Expansion
2648 After word splitting,
2651 option has been set,
2653 scans each word for the characters
2658 If one of these characters appears, then the word is
2661 and replaced with an alphabetically sorted list of
2662 file names matching the pattern.
2663 If no matching file names are found,
2664 and the shell option
2666 is disabled, the word is left unchanged.
2669 option is set, and no matches are found,
2670 the word is removed.
2673 shell option is set, and no matches are found, an error message
2674 is printed and the command is not executed.
2677 is enabled, the match is performed without regard to the case
2678 of alphabetic characters.
2679 When a pattern is used for pathname expansion,
2682 at the start of a name or immediately following a slash
2683 must be matched explicitly, unless the shell option
2686 When matching a pathname, the slash character must always be
2690 character is not treated specially.
2691 See the description of
2695 .B SHELL BUILTIN COMMANDS
2696 for a description of the
2707 shell variable may be used to restrict the set of file names matching a
2712 is set, each matching file name that also matches one of the patterns in
2715 is removed from the list of matches.
2720 are always ignored when
2723 is set and not null. However, setting
2726 to a non-null value has the effect of enabling the
2728 shell option, so all other file names beginning with a
2731 To get the old behavior of ignoring file names beginning with a
2735 one of the patterns in
2740 option is disabled when
2745 \fBPattern Matching\fP
2747 Any character that appears in a pattern, other than the special pattern
2748 characters described below, matches itself. The NUL character may not
2749 occur in a pattern. A backslash escapes the following character; the
2750 escaping backslash is discarded when matching.
2751 The special pattern characters must be quoted if
2752 they are to be matched literally.
2754 The special pattern characters have the following meanings:
2759 Matches any string, including the null string.
2762 Matches any single character.
2765 Matches any one of the enclosed characters. A pair of characters
2766 separated by a hyphen denotes a
2767 \fIrange expression\fP;
2768 any character that sorts between those two characters, inclusive,
2769 using the current locale's collating sequence and character set,
2770 is matched. If the first character following the
2776 then any character not enclosed is matched.
2777 The sorting order of characters in range expressions is determined by
2778 the current locale and the value of the \fBLC_COLLATE\fP shell variable,
2782 may be matched by including it as the first or last character
2786 may be matched by including it as the first character
2795 \fIcharacter classes\fP can be specified using the syntax
2796 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
2797 following classes defined in the POSIX.2 standard:
2801 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
2802 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
2804 A character class matches any character belonging to that class.
2805 The \fBword\fP character class matches letters, digits, and the character _.
2813 an \fIequivalence class\fP can be specified using the syntax
2814 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
2815 same collation weight (as defined by the current locale) as
2816 the character \fIc\fP.
2824 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
2829 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
2830 builtin, several extended pattern matching operators are recognized.
2831 In the following description, a \fIpattern-list\fP is a list of one
2832 or more patterns separated by a \fB|\fP.
2833 Composite patterns may be formed using one or more of the following
2839 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
2840 Matches zero or one occurrence of the given patterns
2842 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
2843 Matches zero or more occurrences of the given patterns
2845 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
2846 Matches one or more occurrences of the given patterns
2848 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
2849 Matches exactly one of the given patterns
2851 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
2852 Matches anything except one of the given patterns
2857 After the preceding expansions, all unquoted occurrences of the
2861 and \^\f3"\fP\^ that did not result from one of the above
2862 expansions are removed.
2864 Before a command is executed, its input and output
2867 using a special notation interpreted by the shell.
2868 Redirection may also be used to open and close files for the
2869 current shell execution environment. The following redirection
2870 operators may precede or appear anywhere within a
2874 Redirections are processed in the order they appear, from
2877 In the following descriptions, if the file descriptor number is
2878 omitted, and the first character of the redirection operator is
2880 the redirection refers to the standard input (file descriptor
2881 0). If the first character of the redirection operator is
2883 the redirection refers to the standard output (file descriptor
2886 The word following the redirection operator in the following
2887 descriptions, unless otherwise noted, is subjected to brace expansion,
2888 tilde expansion, parameter expansion, command substitution, arithmetic
2889 expansion, quote removal, pathname expansion, and word splitting.
2890 If it expands to more than one word,
2894 Note that the order of redirections is significant. For example,
2898 ls \fB>\fP dirlist 2\fB>&\fP1
2901 directs both standard output and standard error to the file
2906 ls 2\fB>&\fP1 \fB>\fP dirlist
2909 directs only the standard output to file
2911 because the standard error was duplicated as standard output
2912 before the standard output was redirected to
2915 \fBBash\fP handles several filenames specially when they are used in
2916 redirections, as described in the following table:
2922 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
2925 File descriptor 0 is duplicated.
2928 File descriptor 1 is duplicated.
2931 File descriptor 2 is duplicated.
2933 .B /dev/tcp/\fIhost\fP/\fIport\fP
2934 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
2935 is an integer port number or service name, \fBbash\fP attempts to open
2936 a TCP connection to the corresponding socket.
2938 .B /dev/udp/\fIhost\fP/\fIport\fP
2939 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
2940 is an integer port number or service name, \fBbash\fP attempts to open
2941 a UDP connection to the corresponding socket.
2945 A failure to open or create a file causes the redirection to fail.
2946 .SS Redirecting Input
2948 Redirection of input causes the file whose name results from
2951 to be opened for reading on file descriptor
2953 or the standard input (file descriptor 0) if
2957 The general format for redirecting input is:
2960 [\fIn\fP]\fB<\fP\fIword\fP
2962 .SS Redirecting Output
2964 Redirection of output causes the file whose name results from
2967 to be opened for writing on file descriptor
2969 or the standard output (file descriptor 1) if
2971 is not specified. If the file does not exist it is created;
2972 if it does exist it is truncated to zero size.
2974 The general format for redirecting output is:
2977 [\fIn\fP]\fB>\fP\fIword\fP
2980 If the redirection operator is
2986 builtin has been enabled, the redirection will fail if the file
2987 whose name results from the expansion of \fIword\fP exists and is
2989 If the redirection operator is
2991 or the redirection operator is
2997 builtin command is not enabled, the redirection is attempted even
2998 if the file named by \fIword\fP exists.
2999 .SS Appending Redirected Output
3001 Redirection of output in this fashion
3002 causes the file whose name results from
3005 to be opened for appending on file descriptor
3007 or the standard output (file descriptor 1) if
3009 is not specified. If the file does not exist it is created.
3011 The general format for appending output is:
3014 [\fIn\fP]\fB>>\fP\fIword\fP
3017 .SS Redirecting Standard Output and Standard Error
3021 standard output (file descriptor 1) and
3022 the standard error output (file descriptor 2)
3023 to be redirected to the file whose name is the
3026 with this construct.
3028 There are two formats for redirecting standard output and
3039 Of the two forms, the first is preferred.
3040 This is semantically equivalent to
3043 \fB>\fP\fIword\fP 2\fB>&\fP1
3047 This type of redirection instructs the shell to read input from the
3048 current source until a line containing only
3050 (with no trailing blanks)
3052 the lines read up to that point are then used as the standard
3053 input for a command.
3055 The format of here-documents is:
3059 \fB<<\fP[\fB\-\fP]\fIword\fP
3065 No parameter expansion, command substitution, arithmetic expansion,
3066 or pathname expansion is performed on
3068 If any characters in
3072 is the result of quote removal on
3074 and the lines in the here-document are not expanded.
3075 If \fIword\fP is unquoted,
3076 all lines of the here-document are subjected to parameter expansion,
3077 command substitution, and arithmetic expansion. In the latter
3078 case, the character sequence
3082 must be used to quote the characters
3088 If the redirection operator is
3090 then all leading tab characters are stripped from input lines and the
3094 here-documents within shell scripts to be indented in a
3097 A variant of here documents, the format is:
3105 The \fIword\fP is expanded and supplied to the command on its standard
3107 .SS "Duplicating File Descriptors"
3109 The redirection operator
3112 [\fIn\fP]\fB<&\fP\fIword\fP
3115 is used to duplicate input file descriptors.
3118 expands to one or more digits, the file descriptor denoted by
3120 is made to be a copy of that file descriptor.
3123 do not specify a file descriptor open for input, a redirection error occurs.
3132 is not specified, the standard input (file descriptor 0) is used.
3137 [\fIn\fP]\fB>&\fP\fIword\fP
3140 is used similarly to duplicate output file descriptors. If
3142 is not specified, the standard output (file descriptor 1) is used.
3145 do not specify a file descriptor open for output, a redirection error occurs.
3146 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
3147 expand to one or more digits, the standard output and standard
3148 error are redirected as described previously.
3149 .SS "Moving File Descriptors"
3151 The redirection operator
3154 [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
3157 moves the file descriptor \fIdigit\fP to file descriptor
3159 or the standard input (file descriptor 0) if \fIn\fP is not specified.
3160 \fIdigit\fP is closed after being duplicated to \fIn\fP.
3162 Similarly, the redirection operator
3165 [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
3168 moves the file descriptor \fIdigit\fP to file descriptor
3170 or the standard output (file descriptor 1) if \fIn\fP is not specified.
3171 .SS "Opening File Descriptors for Reading and Writing"
3173 The redirection operator
3176 [\fIn\fP]\fB<>\fP\fIword\fP
3179 causes the file whose name is the expansion of
3181 to be opened for both reading and writing on file descriptor
3183 or on file descriptor 0 if
3185 is not specified. If the file does not exist, it is created.
3187 \fIAliases\fP allow a string to be substituted for a word when it is used
3188 as the first word of a simple command.
3189 The shell maintains a list of aliases that may be set and unset with the
3193 builtin commands (see
3195 .B SHELL BUILTIN COMMANDS
3197 The first word of each simple command, if unquoted,
3198 is checked to see if it has an
3199 alias. If so, that word is replaced by the text of the alias.
3200 The characters \fB/\fP, \fB$\fP, \fB`\fP, and \fB=\fP and
3201 any of the shell \fImetacharacters\fP or quoting characters
3202 listed above may not appear in an alias name.
3203 The replacement text may contain any valid shell input,
3204 including shell metacharacters.
3205 The first word of the replacement text is tested
3206 for aliases, but a word that is identical to an alias being expanded
3207 is not expanded a second time.
3208 This means that one may alias
3214 does not try to recursively expand the replacement text.
3215 If the last character of the alias value is a
3217 then the next command
3218 word following the alias is also checked for alias expansion.
3220 Aliases are created and listed with the
3222 command, and removed with the
3226 There is no mechanism for using arguments in the replacement text.
3227 If arguments are needed, a shell function should be used (see
3232 Aliases are not expanded when the shell is not interactive, unless
3235 shell option is set using
3237 (see the description of
3241 \fBSHELL BUILTIN COMMANDS\fP
3244 The rules concerning the definition and use of aliases are
3247 always reads at least one complete line
3248 of input before executing any
3249 of the commands on that line. Aliases are expanded when a
3250 command is read, not when it is executed. Therefore, an
3251 alias definition appearing on the same line as another
3252 command does not take effect until the next line of input is read.
3253 The commands following the alias definition
3254 on that line are not affected by the new alias.
3255 This behavior is also an issue when functions are executed.
3256 Aliases are expanded when a function definition is read,
3257 not when the function is executed, because a function definition
3258 is itself a compound command. As a consequence, aliases
3259 defined in a function are not available until after that
3260 function is executed. To be safe, always put
3261 alias definitions on a separate line, and do not use
3263 in compound commands.
3265 For almost every purpose, aliases are superseded by
3268 A shell function, defined as described above under
3270 .BR "SHELL GRAMMAR" ,
3271 stores a series of commands for later execution.
3272 When the name of a shell function is used as a simple command name,
3273 the list of commands associated with that function name is executed.
3274 Functions are executed in the context of the
3275 current shell; no new process is created to interpret
3276 them (contrast this with the execution of a shell script).
3277 When a function is executed, the arguments to the
3278 function become the positional parameters
3279 during its execution.
3280 The special parameter
3282 is updated to reflect the change. Special parameter 0
3284 The first element of the
3287 variable is set to the name of the function while the function
3289 All other aspects of the shell execution
3290 environment are identical between a function and its caller
3291 with the exception that the
3294 trap (see the description of the
3298 .B SHELL BUILTIN COMMANDS
3299 below) is not inherited unless the function has been given the
3300 \fBtrace\fP attribute (see the description of the
3303 builtin below) or the
3304 \fB\-o functrace\fP shell option has been enabled with
3305 the \fBset\fP builtin
3306 (in which case all functions inherit the \fBDEBUG\fP trap).
3308 Variables local to the function may be declared with the
3310 builtin command. Ordinarily, variables and their values
3311 are shared between the function and its caller.
3313 If the builtin command
3315 is executed in a function, the function completes and
3316 execution resumes with the next command after the function
3318 Any command associated with the \fBRETURN\fP trap is executed
3319 before execution resumes.
3320 When a function completes, the values of the
3321 positional parameters and the special parameter
3323 are restored to the values they had prior to the function's
3326 Function names and definitions may be listed with the
3332 builtin commands. The
3338 will list the function names only
3339 (and optionally the source file and line number, if the \fBextdebug\fP
3340 shell option is enabled).
3341 Functions may be exported so that subshells
3342 automatically have them defined with the
3347 Note that shell functions and variables with the same name may result
3348 in multiple identically-named entries in the environment passed to the
3350 Care should be taken in cases where this may cause a problem.
3352 Functions may be recursive. No limit is imposed on the number
3354 .SH "ARITHMETIC EVALUATION"
3355 The shell allows arithmetic expressions to be evaluated, under
3356 certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
3357 commands and \fBArithmetic Expansion\fP).
3358 Evaluation is done in fixed-width integers with no check for overflow,
3359 though division by 0 is trapped and flagged as an error.
3360 The operators and their precedence, associativity, and values
3361 are the same as in the C language.
3362 The following list of operators is grouped into levels of
3363 equal-precedence operators.
3364 The levels are listed in order of decreasing precedence.
3368 .B \fIid\fP++ \fIid\fP\-\-
3369 variable post-increment and post-decrement
3371 .B ++\fIid\fP \-\-\fIid\fP
3372 variable pre-increment and pre-decrement
3375 unary minus and plus
3378 logical and bitwise negation
3384 multiplication, division, remainder
3387 addition, subtraction
3390 left and right bitwise shifts
3396 equality and inequality
3402 bitwise exclusive OR
3413 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
3414 conditional operator
3416 .B = *= /= %= += \-= <<= >>= &= ^= |=
3419 .B \fIexpr1\fP , \fIexpr2\fP
3423 Shell variables are allowed as operands; parameter expansion is
3424 performed before the expression is evaluated.
3425 Within an expression, shell variables may also be referenced by name
3426 without using the parameter expansion syntax.
3427 A shell variable that is null or unset evaluates to 0 when referenced
3428 by name without using the parameter expansion syntax.
3429 The value of a variable is evaluated as an arithmetic expression
3430 when it is referenced, or when a variable which has been given the
3431 \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
3432 A null value evaluates to 0.
3433 A shell variable need not have its integer attribute
3434 turned on to be used in an expression.
3436 Constants with a leading 0 are interpreted as octal numbers.
3437 A leading 0x or 0X denotes hexadecimal.
3438 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
3439 is a decimal number between 2 and 64 representing the arithmetic
3440 base, and \fIn\fP is a number in that base.
3441 If \fIbase#\fP is omitted, then base 10 is used.
3442 The digits greater than 9 are represented by the lowercase letters,
3443 the uppercase letters, @, and _, in that order.
3444 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
3445 letters may be used interchangably to represent numbers between 10
3448 Operators are evaluated in order of precedence. Sub-expressions in
3449 parentheses are evaluated first and may override the precedence
3451 .SH "CONDITIONAL EXPRESSIONS"
3452 Conditional expressions are used by the \fB[[\fP compound command and
3453 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
3454 and perform string and arithmetic comparisons.
3455 Expressions are formed from the following unary or binary primaries.
3456 If any \fIfile\fP argument to one of the primaries is of the form
3457 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
3458 If the \fIfile\fP argument to one of the primaries is one of
3459 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
3460 descriptor 0, 1, or 2, respectively, is checked.
3465 True if \fIfile\fP exists.
3468 True if \fIfile\fP exists and is a block special file.
3471 True if \fIfile\fP exists and is a character special file.
3474 True if \fIfile\fP exists and is a directory.
3477 True if \fIfile\fP exists.
3480 True if \fIfile\fP exists and is a regular file.
3483 True if \fIfile\fP exists and is set-group-id.
3486 True if \fIfile\fP exists and is a symbolic link.
3489 True if \fIfile\fP exists and its ``sticky'' bit is set.
3492 True if \fIfile\fP exists and is a named pipe (FIFO).
3495 True if \fIfile\fP exists and is readable.
3498 True if \fIfile\fP exists and has a size greater than zero.
3501 True if file descriptor
3503 is open and refers to a terminal.
3506 True if \fIfile\fP exists and its set-user-id bit is set.
3509 True if \fIfile\fP exists and is writable.
3512 True if \fIfile\fP exists and is executable.
3515 True if \fIfile\fP exists and is owned by the effective user id.
3518 True if \fIfile\fP exists and is owned by the effective group id.
3521 True if \fIfile\fP exists and is a symbolic link.
3524 True if \fIfile\fP exists and is a socket.
3527 True if \fIfile\fP exists and has been modified since it was last read.
3529 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3530 True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
3531 or if \fIfile1\fP exists and \fPfile2\fP does not.
3533 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3534 True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
3535 and \fIfile1\fP does not.
3537 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3538 True if \fIfile1\fP and \fIfile2\fP refer to the same device and
3541 .B \-o \fIoptname\fP
3542 True if shell option
3545 See the list of options under the description of the
3552 True if the length of \fIstring\fP is zero.
3559 True if the length of
3563 \fIstring1\fP \fB==\fP \fIstring2\fP
3564 True if the strings are equal. \fB=\fP may be used in place of
3565 \fB==\fP for strict POSIX compliance.
3567 \fIstring1\fP \fB!=\fP \fIstring2\fP
3568 True if the strings are not equal.
3570 \fIstring1\fP \fB<\fP \fIstring2\fP
3571 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
3572 in the current locale.
3574 \fIstring1\fP \fB>\fP \fIstring2\fP
3575 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
3576 in the current locale.
3578 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
3589 These arithmetic binary operators return true if \fIarg1\fP
3590 is equal to, not equal to, less than, less than or equal to,
3591 greater than, or greater than or equal to \fIarg2\fP, respectively.
3595 may be positive or negative integers.
3597 .SH "SIMPLE COMMAND EXPANSION"
3598 When a simple command is executed, the shell performs the following
3599 expansions, assignments, and redirections, from left to right.
3601 The words that the parser has marked as variable assignments (those
3602 preceding the command name) and redirections are saved for later
3605 The words that are not variable assignments or redirections are
3606 expanded. If any words remain after expansion, the first word
3607 is taken to be the name of the command and the remaining words are
3610 Redirections are performed as described above under
3614 The text after the \fB=\fP in each variable assignment undergoes tilde
3615 expansion, parameter expansion, command substitution, arithmetic expansion,
3616 and quote removal before being assigned to the variable.
3618 If no command name results, the variable assignments affect the current
3619 shell environment. Otherwise, the variables are added to the environment
3620 of the executed command and do not affect the current shell environment.
3621 If any of the assignments attempts to assign a value to a readonly variable,
3622 an error occurs, and the command exits with a non-zero status.
3624 If no command name results, redirections are performed, but do not
3625 affect the current shell environment. A redirection error causes the
3626 command to exit with a non-zero status.
3628 If there is a command name left after expansion, execution proceeds as
3629 described below. Otherwise, the command exits. If one of the expansions
3630 contained a command substitution, the exit status of the command is
3631 the exit status of the last command substitution performed. If there
3632 were no command substitutions, the command exits with a status of zero.
3633 .SH "COMMAND EXECUTION"
3634 After a command has been split into words, if it results in a
3635 simple command and an optional list of arguments, the following
3638 If the command name contains no slashes, the shell attempts to
3639 locate it. If there exists a shell function by that name, that
3640 function is invoked as described above in
3643 If the name does not match a function, the shell searches for
3644 it in the list of shell builtins. If a match is found, that
3647 If the name is neither a shell function nor a builtin,
3648 and contains no slashes,
3650 searches each element of the
3653 for a directory containing an executable file by that name.
3655 uses a hash table to remember the full pathnames of executable
3660 .B "SHELL BUILTIN COMMANDS"
3662 A full search of the directories in
3665 is performed only if the command is not found in the hash table.
3666 If the search is unsuccessful, the shell prints an error
3667 message and returns an exit status of 127.
3669 If the search is successful, or if the command name contains
3670 one or more slashes, the shell executes the named program in a
3671 separate execution environment.
3672 Argument 0 is set to the name given, and the remaining arguments
3673 to the command are set to the arguments given, if any.
3675 If this execution fails because the file is not in executable
3676 format, and the file is not a directory, it is assumed to be
3677 a \fIshell script\fP, a file
3678 containing shell commands. A subshell is spawned to execute
3679 it. This subshell reinitializes itself, so
3680 that the effect is as if a new shell had been invoked
3681 to handle the script, with the exception that the locations of
3682 commands remembered by the parent (see
3686 \fBSHELL BUILTIN COMMANDS\fP)
3687 are retained by the child.
3689 If the program is a file beginning with
3691 the remainder of the first line specifies an interpreter
3692 for the program. The shell executes the
3693 specified interpreter on operating systems that do not
3694 handle this executable format themselves. The arguments to the
3695 interpreter consist of a single optional argument following the
3696 interpreter name on the first line of the program, followed
3697 by the name of the program, followed by the command
3699 .SH COMMAND EXECUTION ENVIRONMENT
3700 The shell has an \fIexecution environment\fP, which consists of the
3704 open files inherited by the shell at invocation, as modified by
3705 redirections supplied to the \fBexec\fP builtin
3707 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
3708 \fBpopd\fP, or inherited by the shell at invocation
3710 the file creation mode mask as set by \fBumask\fP or inherited from
3713 current traps set by \fBtrap\fP
3715 shell parameters that are set by variable assignment or with \fBset\fP
3716 or inherited from the shell's parent in the environment
3718 shell functions defined during execution or inherited from the shell's
3719 parent in the environment
3721 options enabled at invocation (either by default or with command-line
3722 arguments) or by \fBset\fP
3724 options enabled by \fBshopt\fP
3726 shell aliases defined with \fBalias\fP
3728 various process IDs, including those of background jobs, the value
3729 of \fB$$\fP, and the value of \fB$PPID\fP
3731 When a simple command other than a builtin or shell function
3732 is to be executed, it
3733 is invoked in a separate execution environment that consists of
3734 the following. Unless otherwise noted, the values are inherited
3738 the shell's open files, plus any modifications and additions specified
3739 by redirections to the command
3741 the current working directory
3743 the file creation mode mask
3745 shell variables and functions marked for export, along with variables
3746 exported for the command, passed in the environment
3748 traps caught by the shell are reset to the values inherited from the
3749 shell's parent, and traps ignored by the shell are ignored
3751 A command invoked in this separate environment cannot affect the
3752 shell's execution environment.
3754 Command substitution, commands grouped with parentheses,
3755 and asynchronous commands are invoked in a
3756 subshell environment that is a duplicate of the shell environment,
3757 except that traps caught by the shell are reset to the values
3758 that the shell inherited from its parent at invocation. Builtin
3759 commands that are invoked as part of a pipeline are also executed in a
3760 subshell environment. Changes made to the subshell environment
3761 cannot affect the shell's execution environment.
3763 If a command is followed by a \fB&\fP and job control is not active, the
3764 default standard input for the command is the empty file \fI/dev/null\fP.
3765 Otherwise, the invoked command inherits the file descriptors of the calling
3766 shell as modified by redirections.
3768 When a program is invoked it is given an array of strings
3772 \fIname\fP\-\fIvalue\fP pairs, of the form
3773 .IR "name\fR=\fPvalue" .
3775 The shell provides several ways to manipulate the environment.
3776 On invocation, the shell scans its own environment and
3777 creates a parameter for each name found, automatically marking
3780 to child processes. Executed commands inherit the environment.
3785 commands allow parameters and functions to be added to and
3786 deleted from the environment. If the value of a parameter
3787 in the environment is modified, the new value becomes part
3788 of the environment, replacing the old. The environment
3789 inherited by any executed command consists of the shell's
3790 initial environment, whose values may be modified in the shell,
3791 less any pairs removed by the
3793 command, plus any additions via the
3799 The environment for any
3801 or function may be augmented temporarily by prefixing it with
3802 parameter assignments, as described above in
3805 These assignment statements affect only the environment seen
3810 option is set (see the
3812 builtin command below), then
3814 parameter assignments are placed in the environment for a command,
3815 not just those that precede the command name.
3819 invokes an external command, the variable
3821 is set to the full file name of the command and passed to that
3822 command in its environment.
3824 For the shell's purposes, a command which exits with a
3825 zero exit status has succeeded. An exit status of zero
3826 indicates success. A non-zero exit status indicates failure.
3827 When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
3828 the value of 128+\fIN\fP as the exit status.
3830 If a command is not found, the child process created to
3831 execute it returns a status of 127. If a command is found
3832 but is not executable, the return status is 126.
3834 If a command fails because of an error during expansion or redirection,
3835 the exit status is greater than zero.
3837 Shell builtin commands return a status of 0 (\fItrue\fP) if
3838 successful, and non-zero (\fIfalse\fP) if an error occurs
3840 All builtins return an exit status of 2 to indicate incorrect usage.
3842 \fBBash\fP itself returns the exit status of the last command
3843 executed, unless a syntax error occurs, in which case it exits
3844 with a non-zero value. See also the \fBexit\fP builtin
3847 When \fBbash\fP is interactive, in the absence of any traps, it ignores
3850 (so that \fBkill 0\fP does not kill an interactive shell),
3854 is caught and handled (so that the \fBwait\fP builtin is interruptible).
3855 In all cases, \fBbash\fP ignores
3858 If job control is in effect,
3869 Non-builtin commands run by \fBbash\fP have signal handlers
3870 set to the values inherited by the shell from its parent.
3871 When job control is not in effect, asynchronous commands
3878 in addition to these inherited handlers.
3879 Commands run as a result of command substitution ignore the
3880 keyboard-generated job control signals
3889 The shell exits by default upon receipt of a
3892 Before exiting, an interactive shell resends the
3895 to all jobs, running or stopped.
3896 Stopped jobs are sent
3899 to ensure that they receive the
3902 To prevent the shell from
3903 sending the signal to a particular job, it should be removed from the
3908 .B "SHELL BUILTIN COMMANDS"
3918 shell option has been set with
3924 to all jobs when an interactive login shell exits.
3926 If \Bbash\fP is waiting for a command to complete and receives a signal
3927 for which a trap has been set, the trap will not be executed until
3928 the command completes.
3929 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
3930 builtin, the reception of a signal for which a trap has been set will
3931 cause the \fBwait\fP builtin to return immediately with an exit status
3932 greater than 128, immediately after which the trap is executed.
3935 refers to the ability to selectively stop (\fIsuspend\fP)
3936 the execution of processes and continue (\fIresume\fP)
3937 their execution at a later point. A user typically employs
3938 this facility via an interactive interface supplied jointly
3939 by the system's terminal driver and
3942 The shell associates a
3944 with each pipeline. It keeps a table of currently executing
3945 jobs, which may be listed with the
3949 starts a job asynchronously (in the
3951 it prints a line that looks like:
3957 indicating that this job is job number 1 and that the process ID
3958 of the last process in the pipeline associated with this job is 25647.
3959 All of the processes in a single pipeline are members of the same job.
3963 abstraction as the basis for job control.
3965 To facilitate the implementation of the user interface to job
3966 control, the operating system maintains the notion of a \fIcurrent terminal
3967 process group ID\fP. Members of this process group (processes whose
3968 process group ID is equal to the current terminal process group ID)
3969 receive keyboard-generated signals such as
3972 These processes are said to be in the
3975 processes are those whose process group ID differs from the terminal's;
3976 such processes are immune to keyboard-generated signals.
3977 Only foreground processes are allowed to read from or write to the
3978 terminal. Background processes which attempt to read from (write to) the
3981 .B SIGTTIN (SIGTTOU)
3982 signal by the terminal driver,
3983 which, unless caught, suspends the process.
3985 If the operating system on which
3990 contains facilities to use it.
3993 character (typically
3995 Control-Z) while a process is running
3996 causes that process to be stopped and returns control to
3999 .I "delayed suspend"
4000 character (typically
4002 Control-Y) causes the process to be stopped when it
4003 attempts to read input from the terminal, and control to
4006 The user may then manipulate the state of this job, using the
4008 command to continue it in the background, the
4010 command to continue it in the foreground, or
4013 command to kill it. A \fB^Z\fP takes effect immediately,
4014 and has the additional side effect of causing pending output
4015 and typeahead to be discarded.
4017 There are a number of ways to refer to a job in the shell.
4020 introduces a job name. Job number
4022 may be referred to as
4024 A job may also be referred to using a prefix of the name used to
4025 start it, or using a substring that appears in its command line.
4030 job. If a prefix matches more than one job,
4032 reports an error. Using
4034 on the other hand, refers to any job containing the string
4036 in its command line. If the substring matches more than one job,
4038 reports an error. The symbols
4042 refer to the shell's notion of the
4044 which is the last job stopped while it was in
4045 the foreground or started in the background.
4048 may be referenced using
4050 In output pertaining to jobs (e.g., the output of the
4052 command), the current job is always flagged with a
4054 and the previous job with a
4057 Simply naming a job can be used to bring it into the
4062 bringing job 1 from the background into the foreground.
4065 resumes job 1 in the background, equivalent to
4068 The shell learns immediately whenever a job changes state.
4071 waits until it is about to print a prompt before reporting
4072 changes in a job's status so as to not interrupt
4073 any other output. If the
4080 reports such changes immediately.
4084 is executed for each child that exits.
4086 If an attempt to exit
4088 is made while jobs are stopped, the shell prints a warning message. The
4090 command may then be used to inspect their status.
4091 If a second attempt to exit is made without an intervening command,
4092 the shell does not print another warning, and the stopped
4093 jobs are terminated.
4095 When executing interactively,
4097 displays the primary prompt
4100 when it is ready to read a command, and the secondary prompt
4103 when it needs more input to complete a command.
4105 allows these prompt strings to be customized by inserting a number of
4106 backslash-escaped special characters that are decoded as follows:
4111 an ASCII bell character (07)
4114 the date in "Weekday Month Date" format (e.g., "Tue May 26")
4116 .B \eD{\fIformat\fP}
4117 the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
4118 into the prompt string; an empty \fIformat\fP results in a locale-specific
4119 time representation. The braces are required
4122 an ASCII escape character (033)
4125 the hostname up to the first `.'
4131 the number of jobs currently managed by the shell
4134 the basename of the shell's terminal device name
4143 the name of the shell, the basename of
4145 (the portion following the final slash)
4148 the current time in 24-hour HH:MM:SS format
4151 the current time in 12-hour HH:MM:SS format
4154 the current time in 12-hour am/pm format
4157 the current time in 24-hour HH:MM format
4160 the username of the current user
4163 the version of \fBbash\fP (e.g., 2.00)
4166 the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
4169 the current working directory, with \fB$HOME\fP abbreviated with a tilde
4172 the basename of the current working directory, with \fB$HOME\fP
4173 abbreviated with a tilde
4176 the history number of this command
4179 the command number of this command
4182 if the effective UID is 0, a
4188 the character corresponding to the octal number \fInnn\fP
4194 begin a sequence of non-printing characters, which could be used to
4195 embed a terminal control sequence into the prompt
4198 end a sequence of non-printing characters
4202 The command number and the history number are usually different:
4203 the history number of a command is its position in the history
4204 list, which may include commands restored from the history file
4208 below), while the command number is the position in the sequence
4209 of commands executed during the current shell session.
4210 After the string is decoded, it is expanded via
4211 parameter expansion, command substitution, arithmetic
4212 expansion, and quote removal, subject to the value of the
4214 shell option (see the description of the
4218 .B "SHELL BUILTIN COMMANDS"
4221 This is the library that handles reading input when using an interactive
4224 option is given at shell invocation.
4225 By default, the line editing commands are similar to those of emacs.
4226 A vi-style line editing interface is also available.
4227 To turn off line editing after the shell is running, use the
4235 .B SHELL BUILTIN COMMANDS
4237 .SS "Readline Notation"
4239 In this section, the emacs-style notation is used to denote
4240 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
4241 means Control\-N. Similarly,
4243 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
4246 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
4249 key. This makes ESC the \fImeta prefix\fP.
4250 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
4251 or press the Escape key
4252 then hold the Control key while pressing the
4256 Readline commands may be given numeric
4258 which normally act as a repeat count.
4259 Sometimes, however, it is the sign of the argument that is significant.
4260 Passing a negative argument to a command that acts in the forward
4261 direction (e.g., \fBkill\-line\fP) causes that command to act in a
4263 Commands whose behavior with arguments deviates from this are noted
4266 When a command is described as \fIkilling\fP text, the text
4267 deleted is saved for possible future retrieval
4268 (\fIyanking\fP). The killed text is saved in a
4269 \fIkill ring\fP. Consecutive kills cause the text to be
4270 accumulated into one unit, which can be yanked all at once.
4271 Commands which do not kill text separate the chunks of text
4273 .SS "Readline Initialization"
4275 Readline is customized by putting commands in an initialization
4276 file (the \fIinputrc\fP file).
4277 The name of this file is taken from the value of the
4280 variable. If that variable is unset, the default is
4282 When a program which uses the readline library starts up, the
4283 initialization file is read, and the key bindings and variables
4285 There are only a few basic constructs allowed in the
4286 readline initialization file.
4287 Blank lines are ignored.
4288 Lines beginning with a \fB#\fP are comments.
4289 Lines beginning with a \fB$\fP indicate conditional constructs.
4290 Other lines denote key bindings and variable settings.
4292 The default key-bindings may be changed with an
4295 Other programs that use this library may add their own commands
4298 For example, placing
4301 M\-Control\-u: universal\-argument
4305 C\-Meta\-u: universal\-argument
4309 would make M\-C\-u execute the readline command
4310 .IR universal\-argument .
4312 The following symbolic character names are recognized:
4325 In addition to command names, readline allows keys to be bound
4326 to a string that is inserted when the key is pressed (a \fImacro\fP).
4327 .SS "Readline Key Bindings"
4329 The syntax for controlling key bindings in the
4331 file is simple. All that is required is the name of the
4332 command or the text of a macro and a key sequence to which
4333 it should be bound. The name may be specified in one of two ways:
4334 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
4335 prefixes, or as a key sequence.
4337 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4339 is the name of a key spelled out in English. For example:
4342 Control-u: universal\-argument
4344 Meta-Rubout: backward-kill-word
4346 Control-o: "> output"
4349 In the above example,
4351 is bound to the function
4352 .BR universal\-argument ,
4354 is bound to the function
4355 .BR backward\-kill\-word ,
4358 is bound to run the macro
4359 expressed on the right hand side (that is, to insert the text
4360 .if t \f(CW> output\fP
4364 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4368 above in that strings denoting
4369 an entire key sequence may be specified by placing the sequence
4370 within double quotes. Some GNU Emacs style key escapes can be
4371 used, as in the following example, but the symbolic character names
4375 "\eC\-u": universal\-argument
4377 "\eC\-x\eC\-r": re\-read\-init\-file
4379 "\ee[11~": "Function Key 1"
4384 is again bound to the function
4385 .BR universal\-argument .
4387 is bound to the function
4388 .BR re\-read\-init\-file ,
4391 is bound to insert the text
4392 .if t \f(CWFunction Key 1\fP.
4393 .if n ``Function Key 1''.
4395 The full set of GNU Emacs style escape sequences is
4419 In addition to the GNU Emacs style escape sequences, a second
4420 set of backslash escapes is available:
4449 the eight-bit character whose value is the octal value \fInnn\fP
4450 (one to three digits)
4453 the eight-bit character whose value is the hexadecimal value \fIHH\fP
4454 (one or two hex digits)
4458 When entering the text of a macro, single or double quotes must
4459 be used to indicate a macro definition.
4460 Unquoted text is assumed to be a function name.
4461 In the macro body, the backslash escapes described above are expanded.
4462 Backslash will quote any other character in the macro text,
4466 allows the current readline key bindings to be displayed or modified
4469 builtin command. The editing mode may be switched during interactive
4474 builtin command (see
4476 .B SHELL BUILTIN COMMANDS
4478 .SS "Readline Variables"
4480 Readline has variables that can be used to further customize its
4481 behavior. A variable may be set in the
4483 file with a statement of the form
4486 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
4489 Except where noted, readline variables can take the values
4493 The variables and their default values are:
4497 .B bell\-style (audible)
4498 Controls what happens when readline wants to ring the terminal bell.
4499 If set to \fBnone\fP, readline never rings the bell. If set to
4500 \fBvisible\fP, readline uses a visible bell if one is available.
4501 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
4503 .B comment\-begin (``#'')
4504 The string that is inserted when the readline
4506 command is executed.
4507 This command is bound to
4509 in emacs mode and to
4513 .B completion\-ignore\-case (Off)
4514 If set to \fBOn\fP, readline performs filename matching and completion
4515 in a case\-insensitive fashion.
4517 .B completion\-query\-items (100)
4518 This determines when the user is queried about viewing
4519 the number of possible completions
4520 generated by the \fBpossible\-completions\fP command.
4521 It may be set to any integer value greater than or equal to
4522 zero. If the number of possible completions is greater than
4523 or equal to the value of this variable, the user is asked whether
4524 or not he wishes to view them; otherwise they are simply listed
4527 .B convert\-meta (On)
4528 If set to \fBOn\fP, readline will convert characters with the
4529 eighth bit set to an ASCII key sequence
4530 by stripping the eighth bit and prefixing an
4531 escape character (in effect, using escape as the \fImeta prefix\fP).
4533 .B disable\-completion (Off)
4534 If set to \fBOn\fP, readline will inhibit word completion. Completion
4535 characters will be inserted into the line as if they had been
4536 mapped to \fBself-insert\fP.
4538 .B editing\-mode (emacs)
4539 Controls whether readline begins with a set of key bindings similar
4540 to \fIemacs\fP or \fIvi\fP.
4542 can be set to either
4547 .B enable\-keypad (Off)
4548 When set to \fBOn\fP, readline will try to enable the application
4549 keypad when it is called. Some systems need this to enable the
4552 .B expand\-tilde (Off)
4553 If set to \fBon\fP, tilde expansion is performed when readline
4554 attempts word completion.
4556 .B history-preserve-point
4557 If set to \fBon\fP, the history code attempts to place point at the
4558 same location on each history line retrived with \fBprevious-history\fP
4559 or \fBnext-history\fP.
4561 .B horizontal\-scroll\-mode (Off)
4562 When set to \fBOn\fP, makes readline use a single line for display,
4563 scrolling the input horizontally on a single screen line when it
4564 becomes longer than the screen width rather than wrapping to a new line.
4566 .B input\-meta (Off)
4567 If set to \fBOn\fP, readline will enable eight-bit input (that is,
4568 it will not strip the high bit from the characters it reads),
4569 regardless of what the terminal claims it can support. The name
4571 is a synonym for this variable.
4573 .B isearch\-terminators (``C\-[C\-J'')
4574 The string of characters that should terminate an incremental
4575 search without subsequently executing the character as a command.
4576 If this variable has not been given a value, the characters
4577 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
4580 Set the current readline keymap. The set of valid keymap names is
4581 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4584 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4585 equivalent to \fIemacs\-standard\fP. The default value is
4589 also affects the default keymap.
4591 .B mark\-directories (On)
4592 If set to \fBOn\fP, completed directory names have a slash
4595 .B mark\-modified\-lines (Off)
4596 If set to \fBOn\fP, history lines that have been modified are displayed
4597 with a preceding asterisk (\fB*\fP).
4599 .B mark\-symlinked\-directories (Off)
4600 If set to \fBOn\fP, completed names which are symbolic links to directories
4601 have a slash appended (subject to the value of
4602 \fBmark\-directories\fP).
4604 .B match\-hidden\-files (On)
4605 This variable, when set to \fBOn\fP, causes readline to match files whose
4606 names begin with a `.' (hidden files) when performing filename
4607 completion, unless the leading `.' is
4608 supplied by the user in the filename to be completed.
4610 .B output\-meta (Off)
4611 If set to \fBOn\fP, readline will display characters with the
4612 eighth bit set directly rather than as a meta-prefixed escape
4615 .B page\-completions (On)
4616 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
4617 to display a screenful of possible completions at a time.
4619 .B print\-completions\-horizontally (Off)
4620 If set to \fBOn\fP, readline will display completions with matches
4621 sorted horizontally in alphabetical order, rather than down the screen.
4623 .B show\-all\-if\-ambiguous (Off)
4624 This alters the default behavior of the completion functions. If
4627 words which have more than one possible completion cause the
4628 matches to be listed immediately instead of ringing the bell.
4630 .B show\-all\-if\-unmodified (Off)
4631 This alters the default behavior of the completion functions in
4632 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
4635 words which have more than one possible completion without any
4636 possible partial completion (the possible completions don't share
4637 a common prefix) cause the matches to be listed immediately instead
4638 of ringing the bell.
4640 .B visible\-stats (Off)
4641 If set to \fBOn\fP, a character denoting a file's type as reported
4642 by \fIstat\fP(2) is appended to the filename when listing possible
4645 .SS "Readline Conditional Constructs"
4647 Readline implements a facility similar in spirit to the conditional
4648 compilation features of the C preprocessor which allows key
4649 bindings and variable settings to be performed as the result
4650 of tests. There are four parser directives used.
4654 construct allows bindings to be made based on the
4655 editing mode, the terminal being used, or the application using
4656 readline. The text of the test extends to the end of the line;
4657 no characters are required to isolate it.
4660 The \fBmode=\fP form of the \fB$if\fP directive is used to test
4661 whether readline is in emacs or vi mode.
4662 This may be used in conjunction
4663 with the \fBset keymap\fP command, for instance, to set bindings in
4664 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
4665 readline is starting out in emacs mode.
4667 The \fBterm=\fP form may be used to include terminal-specific
4668 key bindings, perhaps to bind the key sequences output by the
4669 terminal's function keys. The word on the right side of the
4671 is tested against the both full name of the terminal and the portion
4672 of the terminal name before the first \fB\-\fP. This allows
4679 .IP \fBapplication\fP
4680 The \fBapplication\fP construct is used to include
4681 application-specific settings. Each program using the readline
4682 library sets the \fIapplication name\fP, and an initialization
4683 file can test for a particular value.
4684 This could be used to bind key sequences to functions useful for
4685 a specific program. For instance, the following command adds a
4686 key sequence that quotes the current or previous word in Bash:
4691 # Quote the current or previous word
4692 "\eC\-xq": "\eeb\e"\eef\e""
4698 This command, as seen in the previous example, terminates an
4701 Commands in this branch of the \fB$if\fP directive are executed if
4704 This directive takes a single filename as an argument and reads commands
4705 and bindings from that file. For example, the following directive
4706 would read \fI/etc/inputrc\fP:
4710 \fB$include\fP \^ \fI/etc/inputrc\fP
4715 Readline provides commands for searching through the command history
4719 below) for lines containing a specified string.
4720 There are two search modes:
4723 .IR non-incremental .
4725 Incremental searches begin before the user has finished typing the
4727 As each character of the search string is typed, readline displays
4728 the next entry from the history matching the string typed so far.
4729 An incremental search requires only as many characters as needed to
4730 find the desired history entry.
4731 The characters present in the value of the \fBisearch-terminators\fP
4732 variable are used to terminate an incremental search.
4733 If that variable has not been assigned a value the Escape and
4734 Control-J characters will terminate an incremental search.
4735 Control-G will abort an incremental search and restore the original
4737 When the search is terminated, the history entry containing the
4738 search string becomes the current line.
4740 To find other matching entries in the history list, type Control-S or
4741 Control-R as appropriate.
4742 This will search backward or forward in the history for the next
4743 entry matching the search string typed so far.
4744 Any other key sequence bound to a readline command will terminate
4745 the search and execute that command.
4746 For instance, a \fInewline\fP will terminate the search and accept
4747 the line, thereby executing the command from the history list.
4749 Readline remembers the last incremental search string. If two
4750 Control-Rs are typed without any intervening characters defining a
4751 new search string, any remembered search string is used.
4753 Non-incremental searches read the entire search string before starting
4754 to search for matching history lines. The search string may be
4755 typed by the user or be part of the contents of the current line.
4756 .SS "Readline Command Names"
4758 The following is a list of the names of the commands and the default
4759 key sequences to which they are bound.
4760 Command names without an accompanying key sequence are unbound by default.
4761 In the following descriptions, \fIpoint\fP refers to the current cursor
4762 position, and \fImark\fP refers to a cursor position saved by the
4763 \fBset\-mark\fP command.
4764 The text between the point and mark is referred to as the \fIregion\fP.
4765 .SS Commands for Moving
4769 .B beginning\-of\-line (C\-a)
4770 Move to the start of the current line.
4772 .B end\-of\-line (C\-e)
4773 Move to the end of the line.
4775 .B forward\-char (C\-f)
4776 Move forward a character.
4778 .B backward\-char (C\-b)
4779 Move back a character.
4781 .B forward\-word (M\-f)
4782 Move forward to the end of the next word. Words are composed of
4783 alphanumeric characters (letters and digits).
4785 .B backward\-word (M\-b)
4786 Move back to the start of the current or previous word. Words are
4787 composed of alphanumeric characters (letters and digits).
4789 .B clear\-screen (C\-l)
4790 Clear the screen leaving the current line at the top of the screen.
4791 With an argument, refresh the current line without clearing the
4794 .B redraw\-current\-line
4795 Refresh the current line.
4797 .SS Commands for Manipulating the History
4801 .B accept\-line (Newline, Return)
4802 Accept the line regardless of where the cursor is. If this line is
4803 non-empty, add it to the history list according to the state of the
4806 variable. If the line is a modified history
4807 line, then restore the history line to its original state.
4809 .B previous\-history (C\-p)
4810 Fetch the previous command from the history list, moving back in
4813 .B next\-history (C\-n)
4814 Fetch the next command from the history list, moving forward in the
4817 .B beginning\-of\-history (M\-<)
4818 Move to the first line in the history.
4820 .B end\-of\-history (M\->)
4821 Move to the end of the input history, i.e., the line currently being
4824 .B reverse\-search\-history (C\-r)
4825 Search backward starting at the current line and moving `up' through
4826 the history as necessary. This is an incremental search.
4828 .B forward\-search\-history (C\-s)
4829 Search forward starting at the current line and moving `down' through
4830 the history as necessary. This is an incremental search.
4832 .B non\-incremental\-reverse\-search\-history (M\-p)
4833 Search backward through the history starting at the current line
4834 using a non-incremental search for a string supplied by the user.
4836 .B non\-incremental\-forward\-search\-history (M\-n)
4837 Search forward through the history using a non-incremental search for
4838 a string supplied by the user.
4840 .B history\-search\-forward
4841 Search forward through the history for the string of characters
4842 between the start of the current line and the point.
4843 This is a non-incremental search.
4845 .B history\-search\-backward
4846 Search backward through the history for the string of characters
4847 between the start of the current line and the point.
4848 This is a non-incremental search.
4850 .B yank\-nth\-arg (M\-C\-y)
4851 Insert the first argument to the previous command (usually
4852 the second word on the previous line) at point.
4855 insert the \fIn\fPth word from the previous command (the words
4856 in the previous command begin with word 0). A negative argument
4857 inserts the \fIn\fPth word from the end of the previous command.
4860 yank\-last\-arg (M\-.\^, M\-_\^)
4861 Insert the last argument to the previous command (the last word of
4862 the previous history entry). With an argument,
4863 behave exactly like \fByank\-nth\-arg\fP.
4864 Successive calls to \fByank\-last\-arg\fP move back through the history
4865 list, inserting the last argument of each line in turn.
4867 .B shell\-expand\-line (M\-C\-e)
4868 Expand the line as the shell does. This
4869 performs alias and history expansion as well as all of the shell
4870 word expansions. See
4872 .B HISTORY EXPANSION
4873 below for a description of history expansion.
4875 .B history\-expand\-line (M\-^)
4876 Perform history expansion on the current line.
4879 .B HISTORY EXPANSION
4880 below for a description of history expansion.
4883 Perform history expansion on the current line and insert a space.
4886 .B HISTORY EXPANSION
4887 below for a description of history expansion.
4889 .B alias\-expand\-line
4890 Perform alias expansion on the current line.
4894 above for a description of alias expansion.
4896 .B history\-and\-alias\-expand\-line
4897 Perform history and alias expansion on the current line.
4899 .B insert\-last\-argument (M\-.\^, M\-_\^)
4900 A synonym for \fByank\-last\-arg\fP.
4902 .B operate\-and\-get\-next (C\-o)
4903 Accept the current line for execution and fetch the next line
4904 relative to the current line from the history for editing. Any
4905 argument is ignored.
4907 .B edit\-and\-execute\-command (C\-xC\-e)
4908 Invoke an editor on the current command line, and execute the result as shell
4910 \fBBash\fP attempts to invoke
4915 and \fIemacs\fP as the editor, in that order.
4917 .SS Commands for Changing Text
4921 .B delete\-char (C\-d)
4922 Delete the character at point. If point is at the
4923 beginning of the line, there are no characters in the line, and
4924 the last character typed was not bound to \fBdelete\-char\fP,
4929 .B backward\-delete\-char (Rubout)
4930 Delete the character behind the cursor. When given a numeric argument,
4931 save the deleted text on the kill ring.
4933 .B forward\-backward\-delete\-char
4934 Delete the character under the cursor, unless the cursor is at the
4935 end of the line, in which case the character behind the cursor is
4938 .B quoted\-insert (C\-q, C\-v)
4939 Add the next character typed to the line verbatim. This is
4940 how to insert characters like \fBC\-q\fP, for example.
4942 .B tab\-insert (C\-v TAB)
4943 Insert a tab character.
4945 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
4946 Insert the character typed.
4948 .B transpose\-chars (C\-t)
4949 Drag the character before point forward over the character at point,
4950 moving point forward as well.
4951 If point is at the end of the line, then this transposes
4952 the two characters before point.
4953 Negative arguments have no effect.
4955 .B transpose\-words (M\-t)
4956 Drag the word before point past the word after point,
4957 moving point over that word as well.
4958 If point is at the end of the line, this transposes
4959 the last two words on the line.
4961 .B upcase\-word (M\-u)
4962 Uppercase the current (or following) word. With a negative argument,
4963 uppercase the previous word, but do not move point.
4965 .B downcase\-word (M\-l)
4966 Lowercase the current (or following) word. With a negative argument,
4967 lowercase the previous word, but do not move point.
4969 .B capitalize\-word (M\-c)
4970 Capitalize the current (or following) word. With a negative argument,
4971 capitalize the previous word, but do not move point.
4974 Toggle overwrite mode. With an explicit positive numeric argument,
4975 switches to overwrite mode. With an explicit non-positive numeric
4976 argument, switches to insert mode. This command affects only
4977 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
4978 Each call to \fIreadline()\fP starts in insert mode.
4979 In overwrite mode, characters bound to \fBself\-insert\fP replace
4980 the text at point rather than pushing the text to the right.
4981 Characters bound to \fBbackward\-delete\-char\fP replace the character
4982 before point with a space. By default, this command is unbound.
4984 .SS Killing and Yanking
4988 .B kill\-line (C\-k)
4989 Kill the text from point to the end of the line.
4991 .B backward\-kill\-line (C\-x Rubout)
4992 Kill backward to the beginning of the line.
4994 .B unix\-line\-discard (C\-u)
4995 Kill backward from point to the beginning of the line.
4996 The killed text is saved on the kill-ring.
4997 .\" There is no real difference between this and backward-kill-line
4999 .B kill\-whole\-line
5000 Kill all characters on the current line, no matter where point is.
5002 .B kill\-word (M\-d)
5003 Kill from point to the end of the current word, or if between
5004 words, to the end of the next word.
5005 Word boundaries are the same as those used by \fBforward\-word\fP.
5007 .B backward\-kill\-word (M\-Rubout)
5008 Kill the word behind point.
5009 Word boundaries are the same as those used by \fBbackward\-word\fP.
5011 .B unix\-word\-rubout (C\-w)
5012 Kill the word behind point, using white space as a word boundary.
5013 The killed text is saved on the kill-ring.
5015 .B unix\-filename\-rubout
5016 Kill the word behind point, using white space and the slash character
5017 as the word boundaries.
5018 The killed text is saved on the kill-ring.
5020 .B delete\-horizontal\-space (M\-\e)
5021 Delete all spaces and tabs around point.
5024 Kill the text in the current region.
5026 .B copy\-region\-as\-kill
5027 Copy the text in the region to the kill buffer.
5029 .B copy\-backward\-word
5030 Copy the word before point to the kill buffer.
5031 The word boundaries are the same as \fBbackward\-word\fP.
5033 .B copy\-forward\-word
5034 Copy the word following point to the kill buffer.
5035 The word boundaries are the same as \fBforward\-word\fP.
5038 Yank the top of the kill ring into the buffer at point.
5041 Rotate the kill ring, and yank the new top. Only works following
5046 .SS Numeric Arguments
5050 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
5051 Add this digit to the argument already accumulating, or start a new
5052 argument. M\-\- starts a negative argument.
5054 .B universal\-argument
5055 This is another way to specify an argument.
5056 If this command is followed by one or more digits, optionally with a
5057 leading minus sign, those digits define the argument.
5058 If the command is followed by digits, executing
5059 .B universal\-argument
5060 again ends the numeric argument, but is otherwise ignored.
5061 As a special case, if this command is immediately followed by a
5062 character that is neither a digit or minus sign, the argument count
5063 for the next command is multiplied by four.
5064 The argument count is initially one, so executing this function the
5065 first time makes the argument count four, a second time makes the
5066 argument count sixteen, and so on.
5073 Attempt to perform completion on the text before point.
5075 attempts completion treating the text as a variable (if the
5076 text begins with \fB$\fP), username (if the text begins with
5077 \fB~\fP), hostname (if the text begins with \fB@\fP), or
5078 command (including aliases and functions) in turn. If none
5079 of these produces a match, filename completion is attempted.
5081 .B possible\-completions (M\-?)
5082 List the possible completions of the text before point.
5084 .B insert\-completions (M\-*)
5085 Insert all completions of the text before point
5086 that would have been generated by
5087 \fBpossible\-completions\fP.
5090 Similar to \fBcomplete\fP, but replaces the word to be completed
5091 with a single match from the list of possible completions.
5092 Repeated execution of \fBmenu\-complete\fP steps through the list
5093 of possible completions, inserting each match in turn.
5094 At the end of the list of completions, the bell is rung
5095 (subject to the setting of \fBbell\-style\fP)
5096 and the original text is restored.
5097 An argument of \fIn\fP moves \fIn\fP positions forward in the list
5098 of matches; a negative argument may be used to move backward
5100 This command is intended to be bound to \fBTAB\fP, but is unbound
5103 .B delete\-char\-or\-list
5104 Deletes the character under the cursor if not at the beginning or
5105 end of the line (like \fBdelete\-char\fP).
5106 If at the end of the line, behaves identically to
5107 \fBpossible\-completions\fP.
5108 This command is unbound by default.
5110 .B complete\-filename (M\-/)
5111 Attempt filename completion on the text before point.
5113 .B possible\-filename\-completions (C\-x /)
5114 List the possible completions of the text before point,
5115 treating it as a filename.
5117 .B complete\-username (M\-~)
5118 Attempt completion on the text before point, treating
5121 .B possible\-username\-completions (C\-x ~)
5122 List the possible completions of the text before point,
5123 treating it as a username.
5125 .B complete\-variable (M\-$)
5126 Attempt completion on the text before point, treating
5127 it as a shell variable.
5129 .B possible\-variable\-completions (C\-x $)
5130 List the possible completions of the text before point,
5131 treating it as a shell variable.
5133 .B complete\-hostname (M\-@)
5134 Attempt completion on the text before point, treating
5137 .B possible\-hostname\-completions (C\-x @)
5138 List the possible completions of the text before point,
5139 treating it as a hostname.
5141 .B complete\-command (M\-!)
5142 Attempt completion on the text before point, treating
5143 it as a command name. Command completion attempts to
5144 match the text against aliases, reserved words, shell
5145 functions, shell builtins, and finally executable filenames,
5148 .B possible\-command\-completions (C\-x !)
5149 List the possible completions of the text before point,
5150 treating it as a command name.
5152 .B dynamic\-complete\-history (M\-TAB)
5153 Attempt completion on the text before point, comparing
5154 the text against lines from the history list for possible
5157 .B complete\-into\-braces (M\-{)
5158 Perform filename completion and insert the list of possible completions
5159 enclosed within braces so the list is available to the shell (see
5167 .B start\-kbd\-macro (C\-x (\^)
5168 Begin saving the characters typed into the current keyboard macro.
5170 .B end\-kbd\-macro (C\-x )\^)
5171 Stop saving the characters typed into the current keyboard macro
5172 and store the definition.
5174 .B call\-last\-kbd\-macro (C\-x e)
5175 Re-execute the last keyboard macro defined, by making the characters
5176 in the macro appear as if typed at the keyboard.
5182 .B re\-read\-init\-file (C\-x C\-r)
5183 Read in the contents of the \fIinputrc\fP file, and incorporate
5184 any bindings or variable assignments found there.
5187 Abort the current editing command and
5188 ring the terminal's bell (subject to the setting of
5191 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
5192 If the metafied character \fIx\fP is lowercase, run the command
5193 that is bound to the corresponding uppercase character.
5195 .B prefix\-meta (ESC)
5196 Metafy the next character typed.
5203 .B undo (C\-_, C\-x C\-u)
5204 Incremental undo, separately remembered for each line.
5206 .B revert\-line (M\-r)
5207 Undo all changes made to this line. This is like executing the
5209 command enough times to return the line to its initial state.
5211 .B tilde\-expand (M\-&)
5212 Perform tilde expansion on the current word.
5214 .B set\-mark (C\-@, M\-<space>)
5215 Set the mark to the point. If a
5216 numeric argument is supplied, the mark is set to that position.
5218 .B exchange\-point\-and\-mark (C\-x C\-x)
5219 Swap the point with the mark. The current cursor position is set to
5220 the saved position, and the old cursor position is saved as the mark.
5222 .B character\-search (C\-])
5223 A character is read and point is moved to the next occurrence of that
5224 character. A negative count searches for previous occurrences.
5226 .B character\-search\-backward (M\-C\-])
5227 A character is read and point is moved to the previous occurrence of that
5228 character. A negative count searches for subsequent occurrences.
5230 .B insert\-comment (M\-#)
5231 Without a numeric argument, the value of the readline
5233 variable is inserted at the beginning of the current line.
5234 If a numeric argument is supplied, this command acts as a toggle: if
5235 the characters at the beginning of the line do not match the value
5236 of \fBcomment\-begin\fP, the value is inserted, otherwise
5237 the characters in \fBcomment-begin\fP are deleted from the beginning of
5239 In either case, the line is accepted as if a newline had been typed.
5240 The default value of
5241 \fBcomment\-begin\fP causes this command to make the current line
5243 If a numeric argument causes the comment character to be removed, the line
5244 will be executed by the shell.
5246 .B glob\-complete\-word (M\-g)
5247 The word before point is treated as a pattern for pathname expansion,
5248 with an asterisk implicitly appended. This pattern is used to
5249 generate a list of matching file names for possible completions.
5251 .B glob\-expand\-word (C\-x *)
5252 The word before point is treated as a pattern for pathname expansion,
5253 and the list of matching file names is inserted, replacing the word.
5254 If a numeric argument is supplied, an asterisk is appended before
5257 .B glob\-list\-expansions (C\-x g)
5258 The list of expansions that would have been generated by
5259 .B glob\-expand\-word
5260 is displayed, and the line is redrawn.
5261 If a numeric argument is supplied, an asterisk is appended before
5265 Print all of the functions and their key bindings to the
5266 readline output stream. If a numeric argument is supplied,
5267 the output is formatted in such a way that it can be made part
5268 of an \fIinputrc\fP file.
5271 Print all of the settable readline variables and their values to the
5272 readline output stream. If a numeric argument is supplied,
5273 the output is formatted in such a way that it can be made part
5274 of an \fIinputrc\fP file.
5277 Print all of the readline key sequences bound to macros and the
5278 strings they ouput. If a numeric argument is supplied,
5279 the output is formatted in such a way that it can be made part
5280 of an \fIinputrc\fP file.
5282 .B display\-shell\-version (C\-x C\-v)
5283 Display version information about the current instance of
5286 .SS Programmable Completion
5288 When word completion is attempted for an argument to a command for
5289 which a completion specification (a \fIcompspec\fP) has been defined
5290 using the \fBcomplete\fP builtin (see
5292 .B "SHELL BUILTIN COMMANDS"
5293 below), the programmable completion facilities are invoked.
5295 First, the command name is identified.
5296 If a compspec has been defined for that command, the
5297 compspec is used to generate the list of possible completions for the word.
5298 If the command word is a full pathname, a compspec for the full
5299 pathname is searched for first.
5300 If no compspec is found for the full pathname, an attempt is made to
5301 find a compspec for the portion following the final slash.
5303 Once a compspec has been found, it is used to generate the list of
5305 If a compspec is not found, the default \fBbash\fP completion as
5306 described above under \fBCompleting\fP is performed.
5308 First, the actions specified by the compspec are used.
5309 Only matches which are prefixed by the word being completed are
5315 option is used for filename or directory name completion, the shell
5319 is used to filter the matches.
5321 Any completions specified by a filename expansion pattern to the
5322 \fB\-G\fP option are generated next.
5323 The words generated by the pattern need not match the word
5328 shell variable is not used to filter the matches, but the
5333 Next, the string specified as the argument to the \fB\-W\fP option
5335 The string is first split using the characters in the
5338 special variable as delimiters.
5339 Shell quoting is honored.
5340 Each word is then expanded using
5341 brace expansion, tilde expansion, parameter and variable expansion,
5342 command substitution, arithmetic expansion, and pathname expansion,
5343 as described above under
5346 The results are split using the rules described above under
5347 \fBWord Splitting\fP.
5348 The results of the expansion are prefix-matched against the word being
5349 completed, and the matching words become the possible completions.
5351 After these matches have been generated, any shell function or command
5352 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
5353 When the command or function is invoked, the
5359 variables are assigned values as described above under
5360 \fBShell Variables\fP.
5361 If a shell function is being invoked, the
5367 variables are also set.
5368 When the function or command is invoked, the first argument is the
5369 name of the command whose arguments are being completed, the
5370 second argument is the word being completed, and the third argument
5371 is the word preceding the word being completed on the current command line.
5372 No filtering of the generated completions against the word being completed
5373 is performed; the function or command has complete freedom in generating
5376 Any function specified with \fB\-F\fP is invoked first.
5377 The function may use any of the shell facilities, including the
5378 \fBcompgen\fP builtin described below, to generate the matches.
5379 It must put the possible completions in the
5384 Next, any command specified with the \fB\-C\fP option is invoked
5385 in an environment equivalent to command substitution.
5386 It should print a list of completions, one per line, to the
5388 Backslash may be used to escape a newline, if necessary.
5390 After all of the possible completions are generated, any filter
5391 specified with the \fB\-X\fP option is applied to the list.
5392 The filter is a pattern as used for pathname expansion; a \fB&\fP
5393 in the pattern is replaced with the text of the word being completed.
5394 A literal \fB&\fP may be escaped with a backslash; the backslash
5395 is removed before attempting a match.
5396 Any completion that matches the pattern will be removed from the list.
5397 A leading \fB!\fP negates the pattern; in this case any completion
5398 not matching the pattern will be removed.
5400 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
5401 options are added to each member of the completion list, and the result is
5402 returned to the readline completion code as the list of possible
5405 If the previously-applied actions do not generate any matches, and the
5406 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
5407 compspec was defined, directory name completion is attempted.
5409 If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
5410 compspec was defined, directory name completion is attempted and any
5411 matches are added to the results of the other actions.
5413 By default, if a compspec is found, whatever it generates is returned
5414 to the completion code as the full set of possible completions.
5415 The default \fBbash\fP completions are not attempted, and the readline
5416 default of filename completion is disabled.
5417 If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when
5418 the compspec was defined, the \fBbash\fP default completions are attempted
5419 if the compspec generates no matches.
5420 If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
5421 compspec was defined, readline's default completion will be performed
5422 if the compspec (and, if attempted, the default \fBbash\fP completions)
5423 generate no matches.
5425 When a compspec indicates that directory name completion is desired,
5426 the programmable completion functions force readline to append a slash
5427 to completed names which are symbolic links to directories, subject to
5428 the value of the \fBmark\-directories\fP readline variable, regardless
5429 of the setting of the \fBmark-symlinked\-directories\fP readline variable.
5435 builtin is enabled, the shell provides access to the
5436 \fIcommand history\fP,
5437 the list of commands previously typed.
5438 The value of the \fBHISTSIZE\fP variable is used as the
5439 number of commands to save in a history list.
5440 The text of the last
5443 commands (default 500) is saved. The shell
5444 stores each command in the history list prior to parameter and
5445 variable expansion (see
5448 above) but after history expansion is performed, subject to the
5449 values of the shell variables
5456 On startup, the history is initialized from the file named by
5460 (default \fI~/.bash_history\fP).
5461 The file named by the value of
5464 is truncated, if necessary, to contain no more than
5465 the number of lines specified by the value of
5468 When an interactive shell exits, the last
5471 lines are copied from the history list to
5476 shell option is enabled
5477 (see the description of
5481 .B "SHELL BUILTIN COMMANDS"
5482 below), the lines are appended to the history file,
5483 otherwise the history file is overwritten.
5487 is unset, or if the history file is unwritable, the history is
5488 not saved. After saving the history, the history file is truncated
5489 to contain no more than
5495 is not set, no truncation is performed.
5501 .B SHELL BUILTIN COMMANDS
5502 below) may be used to list or edit and re-execute a portion of
5506 builtin may be used to display or modify the history list and
5507 manipulate the history file.
5508 When using command-line editing, search commands
5509 are available in each editing mode that provide access to the
5512 The shell allows control over which commands are saved on the history
5519 variables may be set to cause the shell to save only a subset of the
5523 shell option, if enabled, causes the shell to attempt to save each
5524 line of a multi-line command in the same history entry, adding
5525 semicolons where necessary to preserve syntactic correctness.
5528 shell option causes the shell to save the command with embedded newlines
5529 instead of semicolons. See the description of the
5533 .B "SHELL BUILTIN COMMANDS"
5534 for information on setting and unsetting shell options.
5535 .SH "HISTORY EXPANSION"
5537 The shell supports a history expansion feature that
5538 is similar to the history expansion in
5540 This section describes what syntax features are available. This
5541 feature is enabled by default for interactive shells, and can be
5546 builtin command (see
5548 .B SHELL BUILTIN COMMANDS
5549 below). Non-interactive shells do not perform history expansion
5552 History expansions introduce words from the history list into
5553 the input stream, making it easy to repeat commands, insert the
5554 arguments to a previous command into the current input line, or
5555 fix errors in previous commands quickly.
5557 History expansion is performed immediately after a complete line
5558 is read, before the shell breaks it into words.
5559 It takes place in two parts.
5560 The first is to determine which line from the history list
5561 to use during substitution.
5562 The second is to select portions of that line for inclusion into
5564 The line selected from the history is the \fIevent\fP,
5565 and the portions of that line that are acted upon are \fIwords\fP.
5566 Various \fImodifiers\fP are available to manipulate the selected words.
5567 The line is broken into words in the same fashion as when reading input,
5568 so that several \fImetacharacter\fP-separated words surrounded by
5569 quotes are considered one word.
5570 History expansions are introduced by the appearance of the
5571 history expansion character, which is \^\fB!\fP\^ by default.
5572 Only backslash (\^\fB\e\fP\^) and single quotes can quote
5573 the history expansion character.
5575 Several characters inhibit history expansion if found immediately
5576 following the history expansion character, even if it is unquoted:
5577 space, tab, newline, carriage return, and \fB=\fP.
5578 If the \fBextglob\fP shell option is enabled, \fB(\fP will also
5581 Several shell options settable with the
5583 builtin may be used to tailor the behavior of history expansion.
5586 shell option is enabled (see the description of the
5590 is being used, history substitutions are not immediately passed to
5592 Instead, the expanded line is reloaded into the
5594 editing buffer for further modification.
5597 is being used, and the
5599 shell option is enabled, a failed history substitution will be reloaded
5602 editing buffer for correction.
5607 builtin command may be used to see what a history expansion will
5613 builtin may be used to add commands to the end of the history list
5614 without actually executing them, so that they are available for
5617 The shell allows control of the various characters used by the
5618 history expansion mechanism (see the description of
5621 .BR "Shell Variables" ).
5622 .SS Event Designators
5624 An event designator is a reference to a command line entry in the
5630 Start a history substitution, except when followed by a
5632 newline, carriage return, =
5633 or ( (when the \fBextglob\fP shell option is enabled using
5634 the \fBshopt\fP builtin).
5637 Refer to command line
5641 Refer to the current command line minus
5645 Refer to the previous command. This is a synonym for `!\-1'.
5648 Refer to the most recent command starting with
5651 .B !?\fIstring\fR\fB[?]\fR
5652 Refer to the most recent command containing
5654 The trailing \fB?\fP may be omitted if
5656 is followed immediately by a newline.
5658 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
5659 Quick substitution. Repeat the last command, replacing
5664 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
5665 (see \fBModifiers\fP below).
5668 The entire command line typed so far.
5670 .SS Word Designators
5672 Word designators are used to select desired words from the event.
5675 separates the event specification from the word designator.
5676 It may be omitted if the word designator begins with a
5683 Words are numbered from the beginning of the line,
5684 with the first word being denoted by 0 (zero).
5685 Words are inserted into the current line separated by single spaces.
5690 The zeroth word. For the shell, this is the command
5697 The first argument. That is, word 1.
5703 The word matched by the most recent `?\fIstring\fR?' search.
5706 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
5709 All of the words but the zeroth. This is a synonym
5710 for `\fI1\-$\fP'. It is not an error to use
5712 if there is just one
5713 word in the event; the empty string is returned in that case.
5716 Abbreviates \fIx\-$\fP.
5719 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
5722 If a word designator is supplied without an event specification, the
5723 previous command is used as the event.
5726 After the optional word designator, there may appear a sequence of
5727 one or more of the following modifiers, each preceded by a `:'.
5733 Remove a trailing file name component, leaving only the head.
5736 Remove all leading file name components, leaving the tail.
5739 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
5743 Remove all but the trailing suffix.
5746 Print the new command but do not execute it.
5749 Quote the substituted words, escaping further substitutions.
5752 Quote the substituted words as with
5754 but break into words at
5758 .B s/\fIold\fP/\fInew\fP/
5761 for the first occurrence of
5763 in the event line. Any delimiter can be used in place of /. The
5764 final delimiter is optional if it is the last character of the
5765 event line. The delimiter may be quoted in
5769 with a single backslash. If & appears in
5773 A single backslash will quote the &. If
5775 is null, it is set to the last
5777 substituted, or, if no previous history substitutions took place,
5781 .B !?\fIstring\fR\fB[?]\fR
5785 Repeat the previous substitution.
5788 Cause changes to be applied over the entire event line. This is
5789 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
5790 or `\fB:&\fP'. If used with
5791 `\fB:s\fP', any delimiter can be used
5792 in place of /, and the final delimiter is optional
5793 if it is the last character of the event line.
5794 An \fBa\fP may be used as a synonym for \fBg\fP.
5797 Apply the following `\fBs\fP' modifier once to each word in the event line.
5799 .SH "SHELL BUILTIN COMMANDS"
5800 .\" start of bash_builtins
5803 Unless otherwise noted, each builtin command documented in this
5804 section as accepting options preceded by
5808 to signify the end of the options.
5812 \fB:\fP [\fIarguments\fP]
5814 No effect; the command does nothing beyond expanding
5816 and performing any specified
5817 redirections. A zero exit code is returned.
5819 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
5822 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
5824 Read and execute commands from
5827 shell environment and return the exit status of the last command
5832 does not contain a slash, file names in
5835 are used to find the directory containing
5837 The file searched for in
5840 need not be executable.
5841 When \fBbash\fP is not in \fIposix mode\fP, the current directory is
5842 searched if no file is found in
5849 builtin command is turned off, the
5853 If any \fIarguments\fP are supplied, they become the positional
5854 parameters when \fIfilename\fP is executed. Otherwise the positional
5855 parameters are unchanged.
5856 The return status is the status of the last command exited within
5857 the script (0 if no commands are executed), and false if
5859 is not found or cannot be read.
5861 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
5862 \fBAlias\fP with no arguments or with the
5864 option prints the list of aliases in the form
5865 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
5866 When arguments are supplied, an alias is defined for
5867 each \fIname\fP whose \fIvalue\fP is given.
5868 A trailing space in \fIvalue\fP causes the next word to be
5869 checked for alias substitution when the alias is expanded.
5870 For each \fIname\fP in the argument list for which no \fIvalue\fP
5871 is supplied, the name and value of the alias is printed.
5872 \fBAlias\fP returns true unless a \fIname\fP is given for which
5873 no alias has been defined.
5875 \fBbg\fP [\fIjobspec\fP]
5876 Resume the suspended job \fIjobspec\fP in the background, as if it
5877 had been started with
5879 If \fIjobspec\fP is not present, the shell's notion of the
5880 \fIcurrent job\fP is used.
5883 returns 0 unless run when job control is disabled or, when run with
5884 job control enabled, if \fIjobspec\fP was not found or started without
5887 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
5890 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
5892 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
5894 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
5896 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
5898 \fBbind\fP \fIreadline\-command\fP
5902 key and function bindings, bind a key sequence to a
5904 function or macro, or set a
5907 Each non-option argument is a command as it would appear in
5909 but each binding or command must be passed as a separate argument;
5910 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
5911 Options, if supplied, have the following meanings:
5918 as the keymap to be affected by the subsequent bindings.
5922 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
5923 vi\-move, vi\-command\fP, and
5925 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
5926 equivalent to \fIemacs\-standard\fP.
5929 List the names of all \fBreadline\fP functions.
5932 Display \fBreadline\fP function names and bindings in such a way
5933 that they can be re-read.
5936 List current \fBreadline\fP function names and bindings.
5939 Display \fBreadline\fP variable names and values in such a way that they
5943 List current \fBreadline\fP variable names and values.
5946 Display \fBreadline\fP key sequences bound to macros and the strings
5947 they output in such a way that they can be re-read.
5950 Display \fBreadline\fP key sequences bound to macros and the strings
5953 .B \-f \fIfilename\fP
5954 Read key bindings from \fIfilename\fP.
5956 .B \-q \fIfunction\fP
5957 Query about which keys invoke the named \fIfunction\fP.
5959 .B \-u \fIfunction\fP
5960 Unbind all keys bound to the named \fIfunction\fP.
5963 Remove any current binding for \fIkeyseq\fP.
5965 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
5966 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
5970 The return value is 0 unless an unrecognized option is given or an
5974 \fBbreak\fP [\fIn\fP]
5981 loop. If \fIn\fP is specified, break \fIn\fP levels.
5985 is greater than the number of enclosing loops, all enclosing loops
5986 are exited. The return value is 0 unless the shell is not executing
5991 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
5992 Execute the specified shell builtin, passing it
5994 and return its exit status.
5995 This is useful when defining a
5996 function whose name is the same as a shell builtin,
5997 retaining the functionality of the builtin within the function.
5998 The \fBcd\fP builtin is commonly redefined this way.
5999 The return status is false if
6001 is not a shell builtin command.
6003 \fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
6004 Change the current directory to \fIdir\fP. The variable
6013 defines the search path for the directory containing
6015 Alternative directory names in
6018 are separated by a colon (:). A null directory name in
6021 is the same as the current directory, i.e., ``\fB.\fP''. If
6023 begins with a slash (/),
6029 option says to use the physical directory structure instead of
6030 following symbolic links (see also the
6034 builtin command); the
6036 option forces symbolic links to be followed. An argument of
6041 If a non-empty directory name from \fBCDPATH\fP is used, or if
6042 \fB\-\fP is the first argument, and the directory change is
6043 successful, the absolute pathname of the new working directory is
6044 written to the standard output.
6045 The return value is true if the directory was successfully changed;
6048 \fBcaller\fP [\fIexpr\fP]
6049 Returns the context of any active subroutine call (a shell function or
6050 a script executed with the \fB.\fP or \fBsource\fP builtins.
6051 Without \fIexpr\fP, \fBcaller\fP displays the line number and source
6052 filename of the current subroutine call.
6053 If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP
6054 displays the line number, subroutine name, and source file corresponding
6055 to that position in the current execution call stack. This extra
6056 information may be used, for example, to print a stack trace. The
6057 current frame is frame 0.
6058 The return value is 0 unless the shell is not executing a subroutine
6059 call or \fIexpr\fP does not correspond to a valid position in the
6062 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
6067 suppressing the normal shell function lookup. Only builtin
6068 commands or commands found in the
6071 are executed. If the
6073 option is given, the search for
6075 is performed using a default value for
6077 that is guaranteed to find all of the standard utilities.
6082 option is supplied, a description of
6086 option causes a single word indicating the command or file name
6089 to be displayed; the
6091 option produces a more verbose description.
6096 option is supplied, the exit status is 0 if
6098 was found, and 1 if not. If neither option is supplied and
6099 an error occurred or
6101 cannot be found, the exit status is 127. Otherwise, the exit status of the
6103 builtin is the exit status of
6106 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
6107 Generate possible completion matches for \fIword\fP according to
6108 the \fIoption\fPs, which may be any option accepted by the
6110 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
6111 the matches to the standard output.
6112 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
6113 set by the programmable completion facilities, while available, will not
6116 The matches will be generated in the same way as if the programmable
6117 completion code had generated them directly from a completion specification
6118 with the same flags.
6119 If \fIword\fP is specified, only those completions matching \fIword\fP
6122 The return value is true unless an invalid option is supplied, or no
6123 matches were generated.
6125 \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
6127 [\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
6130 \fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
6132 Specify how arguments to each \fIname\fP should be completed.
6133 If the \fB\-p\fP option is supplied, or if no options are supplied,
6134 existing completion specifications are printed in a way that allows
6135 them to be reused as input.
6136 The \fB\-r\fP option removes a completion specification for
6137 each \fIname\fP, or, if no \fIname\fPs are supplied, all
6138 completion specifications.
6140 The process of applying these completion specifications when word completion
6141 is attempted is described above under \fBProgrammable Completion\fP.
6143 Other options, if specified, have the following meanings.
6144 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
6145 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
6146 should be quoted to protect them from expansion before the
6152 \fB\-o\fP \fIcomp-option\fP
6153 The \fIcomp-option\fP controls several aspects of the compspec's behavior
6154 beyond the simple generation of completions.
6155 \fIcomp-option\fP may be one of:
6159 Perform the rest of the default \fBbash\fP completions if the compspec
6160 generates no matches.
6163 Use readline's default filename completion if the compspec generates
6167 Perform directory name completion if the compspec generates no matches.
6170 Tell readline that the compspec generates filenames, so it can perform any
6171 filename\-specific processing (like adding a slash to directory names or
6172 suppressing trailing spaces). Intended to be used with shell functions.
6175 Tell readline not to append a space (the default) to words completed at
6176 the end of the line.
6179 \fB\-A\fP \fIaction\fP
6180 The \fIaction\fP may be one of the following to generate a list of possible
6185 Alias names. May also be specified as \fB\-a\fP.
6188 Array variable names.
6191 \fBReadline\fP key binding names.
6194 Names of shell builtin commands. May also be specified as \fB\-b\fP.
6197 Command names. May also be specified as \fB\-c\fP.
6200 Directory names. May also be specified as \fB\-d\fP.
6203 Names of disabled shell builtins.
6206 Names of enabled shell builtins.
6209 Names of exported shell variables. May also be specified as \fB\-e\fP.
6212 File names. May also be specified as \fB\-f\fP.
6215 Names of shell functions.
6218 Group names. May also be specified as \fB\-g\fP.
6221 Help topics as accepted by the \fBhelp\fP builtin.
6224 Hostnames, as taken from the file specified by the
6230 Job names, if job control is active. May also be specified as \fB\-j\fP.
6233 Shell reserved words. May also be specified as \fB\-k\fP.
6236 Names of running jobs, if job control is active.
6239 Service names. May also be specified as \fB\-s\fP.
6242 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
6245 Shell option names as accepted by the \fBshopt\fP builtin.
6251 Names of stopped jobs, if job control is active.
6254 User names. May also be specified as \fB\-u\fP.
6257 Names of all shell variables. May also be specified as \fB\-v\fP.
6260 \fB\-G\fP \fIglobpat\fP
6261 The filename expansion pattern \fIglobpat\fP is expanded to generate
6262 the possible completions.
6264 \fB\-W\fP \fIwordlist\fP
6265 The \fIwordlist\fP is split using the characters in the
6268 special variable as delimiters, and each resultant word is expanded.
6269 The possible completions are the members of the resultant list which
6270 match the word being completed.
6272 \fB\-C\fP \fIcommand\fP
6273 \fIcommand\fP is executed in a subshell environment, and its output is
6274 used as the possible completions.
6276 \fB\-F\fP \fIfunction\fP
6277 The shell function \fIfunction\fP is executed in the current shell
6279 When it finishes, the possible completions are retrieved from the value
6285 \fB\-X\fP \fIfilterpat\fP
6286 \fIfilterpat\fP is a pattern as used for filename expansion.
6287 It is applied to the list of possible completions generated by the
6288 preceding options and arguments, and each completion matching
6289 \fIfilterpat\fP is removed from the list.
6290 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
6291 case, any completion not matching \fIfilterpat\fP is removed.
6293 \fB\-P\fP \fIprefix\fP
6294 \fIprefix\fP is added at the beginning of each possible completion
6295 after all other options have been applied.
6297 \fB\-S\fP \fIsuffix\fP
6298 \fIsuffix\fP is appended to each possible completion
6299 after all other options have been applied.
6302 The return value is true unless an invalid option is supplied, an option
6303 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
6304 argument, an attempt is made to remove a completion specification for
6305 a \fIname\fP for which no specification exists, or
6306 an error occurs adding a completion specification.
6309 \fBcontinue\fP [\fIn\fP]
6310 Resume the next iteration of the enclosing
6319 is specified, resume at the \fIn\fPth enclosing loop.
6323 is greater than the number of enclosing loops, the last enclosing loop
6324 (the ``top-level'' loop) is resumed. The return value is 0 unless the
6325 shell is not executing a loop when
6329 \fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6332 \fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6334 Declare variables and/or give them attributes.
6335 If no \fIname\fPs are given then display the values of variables.
6338 option will display the attributes and values of each
6342 is used, additional options are ignored.
6345 option inhibits the display of function definitions; only the
6346 function name and attributes are printed.
6347 If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
6348 the source file name and line number where the function is defined
6349 are displayed as well. The
6353 The following options can
6354 be used to restrict output to variables with the specified attribute or
6355 to give variables attributes:
6360 Each \fIname\fP is an array variable (see
6365 Use function names only.
6368 The variable is treated as an integer; arithmetic evaluation (see
6370 .B "ARITHMETIC EVALUATION" ") "
6371 is performed when the variable is assigned a value.
6374 Make \fIname\fPs readonly. These names cannot then be assigned values
6375 by subsequent assignment statements or unset.
6378 Give each \fIname\fP the \fItrace\fP attribute.
6379 Traced functions inherit the \fBDEBUG\fP trap from the calling shell.
6380 The trace attribute has no special meaning for variables.
6383 Mark \fIname\fPs for export to subsequent commands via the environment.
6386 Using `+' instead of `\-'
6387 turns off the attribute instead, with the exception that \fB+a\fP
6388 may not be used to destroy an array variable. When used in a function,
6390 \fIname\fP local, as with the
6393 If a variable name is followed by =\fIvalue\fP, the value of
6394 the variable is set to \fIvalue\fP.
6395 The return value is 0 unless an invalid option is encountered,
6396 an attempt is made to define a function using
6397 .if n ``\-f foo=bar'',
6398 .if t \f(CW\-f foo=bar\fP,
6399 an attempt is made to assign a value to a readonly variable,
6400 an attempt is made to assign a value to an array variable without
6401 using the compound assignment syntax (see
6403 above), one of the \fInames\fP is not a valid shell variable name,
6404 an attempt is made to turn off readonly status for a readonly variable,
6405 an attempt is made to turn off array status for an array variable,
6406 or an attempt is made to display a non-existent function with \fB\-f\fP.
6409 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
6410 Without options, displays the list of currently remembered directories.
6411 The default display is on a single line with directory names separated
6413 Directories are added to the list with the
6417 command removes entries from the list.
6422 Displays the \fIn\fPth entry counting from the left of the list
6425 when invoked without options, starting with zero.
6428 Displays the \fIn\fPth entry counting from the right of the list
6431 when invoked without options, starting with zero.
6434 Clears the directory stack by deleting all of the entries.
6437 Produces a longer listing; the default listing format uses a
6438 tilde to denote the home directory.
6441 Print the directory stack with one entry per line.
6444 Print the directory stack with one entry per line,
6445 prefixing each entry with its index in the stack.
6448 The return value is 0 unless an
6449 invalid option is supplied or \fIn\fP indexes beyond the end
6450 of the directory stack.
6453 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
6454 Without options, each
6456 is removed from the table of active jobs.
6457 If the \fB\-h\fP option is given, each
6459 is not removed from the table, but is marked so that
6462 is not sent to the job if the shell receives a
6467 is present, and neither the
6471 option is supplied, the \fIcurrent job\fP is used.
6476 option means to remove or mark all jobs; the
6480 argument restricts operation to running jobs.
6481 The return value is 0 unless a
6483 does not specify a valid job.
6485 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
6486 Output the \fIarg\fPs, separated by spaces, followed by a newline.
6487 The return status is always 0.
6488 If \fB\-n\fP is specified, the trailing newline is
6489 suppressed. If the \fB\-e\fP option is given, interpretation of
6490 the following backslash-escaped characters is enabled. The
6492 option disables the interpretation of these escape characters,
6493 even on systems where they are interpreted by default.
6494 The \fBxpg_echo\fP shell option may be used to
6495 dynamically determine whether or not \fBecho\fP expands these
6496 escape characters by default.
6500 to mean the end of options.
6502 interprets the following escape sequences:
6513 suppress trailing newline
6537 the eight-bit character whose value is the octal value \fInnn\fP
6538 (zero to three octal digits)
6541 the eight-bit character whose value is the octal value \fInnn\fP
6542 (one to three octal digits)
6545 the eight-bit character whose value is the hexadecimal value \fIHH\fP
6546 (one or two hex digits)
6550 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
6551 Enable and disable builtin shell commands.
6552 Disabling a builtin allows a disk command which has the same name
6553 as a shell builtin to be executed without specifying a full pathname,
6554 even though the shell normally searches for builtins before disk commands.
6555 If \fB\-n\fP is used, each \fIname\fP
6556 is disabled; otherwise,
6557 \fInames\fP are enabled. For example, to use the
6559 binary found via the
6562 instead of the shell builtin version, run
6563 .if t \f(CWenable -n test\fP.
6564 .if n ``enable -n test''.
6567 option means to load the new builtin command
6571 on systems that support dynamic loading. The
6573 option will delete a builtin previously loaded with
6575 If no \fIname\fP arguments are given, or if the
6577 option is supplied, a list of shell builtins is printed.
6578 With no other option arguments, the list consists of all enabled
6580 If \fB\-n\fP is supplied, only disabled builtins are printed.
6581 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
6582 indication of whether or not each is enabled.
6583 If \fB\-s\fP is supplied, the output is restricted to the POSIX
6584 \fIspecial\fP builtins.
6585 The return value is 0 unless a
6587 is not a shell builtin or there is an error loading a new builtin
6588 from a shared object.
6590 \fBeval\fP [\fIarg\fP ...]
6591 The \fIarg\fPs are read and concatenated together into a single
6592 command. This command is then read and executed by the shell, and
6593 its exit status is returned as the value of
6597 or only null arguments,
6601 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
6604 is specified, it replaces the shell.
6605 No new process is created. The
6607 become the arguments to \fIcommand\fP.
6611 the shell places a dash at the beginning of the zeroth arg passed to
6619 to be executed with an empty environment. If
6621 is supplied, the shell passes
6623 as the zeroth argument to the executed command. If
6625 cannot be executed for some reason, a non-interactive shell exits,
6626 unless the shell option
6628 is enabled, in which case it returns failure.
6629 An interactive shell returns failure if the file cannot be executed.
6632 is not specified, any redirections take effect in the current shell,
6633 and the return status is 0. If there is a redirection error, the
6636 \fBexit\fP [\fIn\fP]
6637 Cause the shell to exit
6638 with a status of \fIn\fP. If
6640 is omitted, the exit status
6641 is that of the last command executed.
6645 is executed before the shell terminates.
6647 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
6654 are marked for automatic export to the environment of
6655 subsequently executed commands. If the
6663 are given, or if the
6665 option is supplied, a list
6666 of all names that are exported in this shell is printed.
6669 option causes the export property to be removed from each
6671 If a variable name is followed by =\fIword\fP, the value of
6672 the variable is set to \fIword\fP.
6674 returns an exit status of 0 unless an invalid option is
6676 one of the \fInames\fP is not a valid shell variable name, or
6680 that is not a function.
6682 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
6685 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
6687 Fix Command. In the first form, a range of commands from
6691 is selected from the history list.
6695 may be specified as a string (to locate the last command beginning
6696 with that string) or as a number (an index into the history list,
6697 where a negative number is used as an offset from the current
6700 is not specified it is set to
6701 the current command for listing (so that
6702 .if n ``fc \-l \-10''
6703 .if t \f(CWfc \-l \-10\fP
6704 prints the last 10 commands) and to
6709 is not specified it is set to the previous
6710 command for editing and \-16 for listing.
6715 the command numbers when listing. The
6717 option reverses the order of
6718 the commands. If the
6721 the commands are listed on
6722 standard output. Otherwise, the editor given by
6725 on a file containing those commands. If
6731 variable is used, and
6738 is not set. If neither variable is set,
6740 is used. When editing is complete, the edited commands are
6741 echoed and executed.
6743 In the second form, \fIcommand\fP is re-executed after each instance
6744 of \fIpat\fP is replaced by \fIrep\fP.
6745 A useful alias to use with this is
6746 .if n ``r="fc -s"'',
6747 .if t \f(CWr='fc \-s'\fP,
6751 runs the last command beginning with
6757 re-executes the last command.
6759 If the first form is used, the return value is 0 unless an invalid
6760 option is encountered or
6764 specify history lines out of range.
6767 option is supplied, the return value is the value of the last
6768 command executed or failure if an error occurs with the temporary
6769 file of commands. If the second form is used, the return status
6770 is that of the command re-executed, unless
6772 does not specify a valid history line, in which case
6776 \fBfg\fP [\fIjobspec\fP]
6779 in the foreground, and make it the current job.
6782 is not present, the shell's notion of the \fIcurrent job\fP is used.
6783 The return value is that of the command placed into the foreground,
6784 or failure if run when job control is disabled or, when run with
6785 job control enabled, if
6787 does not specify a valid job or
6789 specifies a job that was started without job control.
6791 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
6793 is used by shell procedures to parse positional parameters.
6795 contains the option characters to be recognized; if a character
6796 is followed by a colon, the option is expected to have an
6797 argument, which should be separated from it by white space.
6798 The colon and question mark characters may not be used as
6800 Each time it is invoked,
6802 places the next option in the shell variable
6806 if it does not exist,
6807 and the index of the next argument to be processed into the
6813 is initialized to 1 each time the shell or a shell script
6814 is invoked. When an option requires an argument,
6816 places that argument into the variable
6819 The shell does not reset
6822 automatically; it must be manually reset between multiple
6825 within the same shell invocation if a new set of parameters
6828 When the end of options is encountered, \fBgetopts\fP exits with a
6829 return value greater than zero.
6830 \fBOPTIND\fP is set to the index of the first non-option argument,
6831 and \fBname\fP is set to ?.
6834 normally parses the positional parameters, but if more arguments are
6838 parses those instead.
6841 can report errors in two ways. If the first character of
6845 error reporting is used. In normal operation diagnostic messages
6846 are printed when invalid options or missing option arguments are
6851 is set to 0, no error messages will be displayed, even if the first
6856 If an invalid option is seen,
6861 prints an error message and unsets
6867 the option character found is placed in
6870 and no diagnostic message is printed.
6872 If a required argument is not found, and
6875 a question mark (\^\fB?\fP\^) is placed in
6879 is unset, and a diagnostic message is printed.
6882 is silent, then a colon (\^\fB:\fP\^) is placed in
6887 is set to the option character found.
6890 returns true if an option, specified or unspecified, is found.
6891 It returns false if the end of options is encountered or an
6894 \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
6897 the full file name of the command is determined by searching
6903 option is supplied, no path search is performed, and
6905 is used as the full file name of the command.
6908 option causes the shell to forget all
6909 remembered locations.
6912 option causes the shell to forget the remembered location of each \fIname\fP.
6915 option is supplied, the full pathname to which each \fIname\fP corresponds
6916 is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
6917 the \fIname\fP is printed before the hashed full pathname.
6920 option causes output to be displayed in a format that may be reused as input.
6921 If no arguments are given, or if only \fB\-l\fP is supplied,
6922 information about remembered commands is printed.
6923 The return status is true unless a
6925 is not found or an invalid option is supplied.
6927 \fBhelp\fP [\fB\-s\fP] [\fIpattern\fP]
6928 Display helpful information about builtin commands. If
6932 gives detailed help on all commands matching
6934 otherwise help for all the builtins and shell control structures
6936 The \fB\-s\fP option restricts the information displayed to a short
6938 The return status is 0 unless no command matches
6941 \fBhistory [\fIn\fP]
6944 \fBhistory\fP \fB\-c\fP
6946 \fBhistory \-d\fP \fIoffset\fP
6948 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
6950 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
6952 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
6954 With no options, display the command
6955 history list with line numbers. Lines listed
6958 have been modified. An argument of
6963 If the shell variable \fBHISTTIMEFORMAT\fP is set and not null,
6964 it is used as a format string for \fIstrftime\fP(3) to display
6965 the time stamp associated with each displayed history entry.
6966 No intervening blank is printed between the formatted time stamp
6967 and the history line.
6968 If \fIfilename\fP is supplied, it is used as the
6969 name of the history file; if not, the value of
6972 is used. Options, if supplied, have the following meanings:
6977 Clear the history list by deleting all the entries.
6979 \fB\-d\fP \fIoffset\fP
6980 Delete the history entry at position \fIoffset\fP.
6983 Append the ``new'' history lines (history lines entered since the
6984 beginning of the current \fBbash\fP session) to the history file.
6987 Read the history lines not already read from the history
6988 file into the current history list. These are lines
6989 appended to the history file since the beginning of the
6990 current \fBbash\fP session.
6993 Read the contents of the history file
6994 and use them as the current history.
6997 Write the current history to the history file, overwriting the
6998 history file's contents.
7001 Perform history substitution on the following \fIargs\fP and display
7002 the result on the standard output.
7003 Does not store the results in the history list.
7004 Each \fIarg\fP must be quoted to disable normal history expansion.
7009 in the history list as a single entry. The last command in the
7010 history list is removed before the
7015 If the \fBHISTTIMEFORMAT\fP is set, the time stamp information
7016 associated with each history entry is written to the history file.
7017 The return value is 0 unless an invalid option is encountered, an
7018 error occurs while reading or writing the history file, an invalid
7019 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
7020 history expansion supplied as an argument to \fB\-p\fP fails.
7023 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
7026 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
7028 The first form lists the active jobs. The options have the following
7035 in addition to the normal information.
7038 List only the process ID of the job's process group
7042 Display information only about jobs that have changed status since
7043 the user was last notified of their status.
7046 Restrict output to running jobs.
7049 Restrict output to stopped jobs.
7054 is given, output is restricted to information about that job.
7055 The return status is 0 unless an invalid option is encountered
7070 with the corresponding process group ID, and executes
7074 returning its exit status.
7077 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
7080 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
7082 Send the signal named by
7086 to the processes named by
7091 is either a case-insensitive signal name such as
7094 (with or without the
7097 prefix) or a signal number;
7102 is not present, then
7108 lists the signal names.
7109 If any arguments are supplied when
7111 is given, the names of the signals corresponding to the arguments are
7112 listed, and the return status is 0.
7113 The \fIexit_status\fP argument to
7115 is a number specifying either a signal number or the exit status of
7116 a process terminated by a signal.
7118 returns true if at least one signal was successfully sent, or false
7119 if an error occurs or an invalid option is encountered.
7121 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
7124 is an arithmetic expression to be evaluated (see
7126 .BR "ARITHMETIC EVALUATION" ).
7131 returns 1; 0 is returned otherwise.
7133 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
7134 For each argument, a local variable named
7136 is created, and assigned
7138 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
7141 is used within a function, it causes the variable
7143 to have a visible scope restricted to that function and its children.
7146 writes a list of local variables to the standard output. It is
7149 when not within a function. The return status is 0 unless
7151 is used outside a function, an invalid
7154 \fIname\fP is a readonly variable.
7159 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
7160 Removes entries from the directory stack. With no arguments,
7161 removes the top directory from the stack, and performs a
7163 to the new top directory.
7164 Arguments, if supplied, have the following meanings:
7169 Removes the \fIn\fPth entry counting from the left of the list
7172 starting with zero. For example:
7174 .if t \f(CWpopd +0\fP
7175 removes the first directory,
7177 .if t \f(CWpopd +1\fP
7181 Removes the \fIn\fPth entry counting from the right of the list
7184 starting with zero. For example:
7186 .if t \f(CWpopd -0\fP
7187 removes the last directory,
7189 .if t \f(CWpopd -1\fP
7193 Suppresses the normal change of directory when removing directories
7194 from the stack, so that only the stack is manipulated.
7199 command is successful, a
7201 is performed as well, and the return status is 0.
7203 returns false if an invalid option is encountered, the directory stack
7204 is empty, a non-existent directory stack entry is specified, or the
7205 directory change fails.
7208 \fBprintf\fP \fIformat\fP [\fIarguments\fP]
7209 Write the formatted \fIarguments\fP to the standard output under the
7210 control of the \fIformat\fP.
7211 The \fIformat\fP is a character string which contains three types of objects:
7212 plain characters, which are simply copied to standard output, character
7213 escape sequences, which are converted and copied to the standard output, and
7214 format specifications, each of which causes printing of the next successive
7216 In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
7217 \fBprintf\fP to expand backslash escape sequences in the corresponding
7218 \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in
7219 \fB\e'\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes
7220 beginning with \fB\e0\fP may contain up to four digits),
7221 and \fB%q\fP causes \fBprintf\fP to output the corresponding
7222 \fIargument\fP in a format that can be reused as shell input.
7224 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
7225 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
7226 extra format specifications behave as if a zero value or null string, as
7227 appropriate, had been supplied. The return value is zero on success,
7228 non-zero on failure.
7230 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
7233 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
7235 Adds a directory to the top of the directory stack, or rotates
7236 the stack, making the new top of the stack the current working
7237 directory. With no arguments, exchanges the top two directories
7238 and returns 0, unless the directory stack is empty.
7239 Arguments, if supplied, have the following meanings:
7244 Rotates the stack so that the \fIn\fPth directory
7245 (counting from the left of the list shown by
7251 Rotates the stack so that the \fIn\fPth directory
7252 (counting from the right of the list shown by
7254 starting with zero) is at the top.
7257 Suppresses the normal change of directory when adding directories
7258 to the stack, so that only the stack is manipulated.
7263 to the directory stack at the top, making it the
7264 new current working directory.
7269 command is successful, a
7271 is performed as well.
7272 If the first form is used,
7274 returns 0 unless the cd to
7276 fails. With the second form,
7278 returns 0 unless the directory stack is empty,
7279 a non-existent directory stack element is specified,
7280 or the directory change to the specified new current directory
7284 \fBpwd\fP [\fB\-LP\fP]
7285 Print the absolute pathname of the current working directory.
7286 The pathname printed contains no symbolic links if the
7288 option is supplied or the
7292 builtin command is enabled.
7295 option is used, the pathname printed may contain symbolic links.
7296 The return status is 0 unless an error occurs while
7297 reading the name of the current directory or an
7298 invalid option is supplied.
7300 \fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
7301 One line is read from the standard input, or from the file descriptor
7302 \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
7303 is assigned to the first
7305 the second word to the second
7307 and so on, with leftover words and their intervening separators assigned
7310 If there are fewer words read from the input stream than names,
7311 the remaining names are assigned empty values.
7315 are used to split the line into words.
7316 The backslash character (\fB\e\fP) may be used to remove any special
7317 meaning for the next character read and for line continuation.
7318 Options, if supplied, have the following meanings:
7323 The words are assigned to sequential indices
7324 of the array variable
7328 is unset before any new values are assigned.
7329 Other \fIname\fP arguments are ignored.
7332 The first character of \fIdelim\fP is used to terminate the input line,
7333 rather than newline.
7336 If the standard input
7337 is coming from a terminal,
7342 above) is used to obtain the line.
7345 \fBread\fP returns after reading \fInchars\fP characters rather than
7346 waiting for a complete line of input.
7349 Display \fIprompt\fP on standard error, without a
7350 trailing newline, before attempting to read any input. The prompt
7351 is displayed only if input is coming from a terminal.
7354 Backslash does not act as an escape character.
7355 The backslash is considered to be part of the line.
7356 In particular, a backslash-newline pair may not be used as a line
7360 Silent mode. If input is coming from a terminal, characters are
7363 .B \-t \fItimeout\fP
7364 Cause \fBread\fP to time out and return failure if a complete line of
7365 input is not read within \fItimeout\fP seconds.
7366 This option has no effect if \fBread\fP is not reading input from the
7370 Read input from file descriptor \fIfd\fP.
7375 are supplied, the line read is assigned to the variable
7378 The return code is zero, unless end-of-file is encountered, \fBread\fP
7379 times out, or an invalid file descriptor is supplied as the argument to
7383 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP[=\fIword\fP] ...]
7386 \fInames\fP are marked readonly; the values of these
7388 may not be changed by subsequent assignment.
7391 option is supplied, the functions corresponding to the
7396 option restricts the variables to arrays.
7399 arguments are given, or if the
7401 option is supplied, a list of all readonly names is printed.
7404 option causes output to be displayed in a format that
7405 may be reused as input.
7406 If a variable name is followed by =\fIword\fP, the value of
7407 the variable is set to \fIword\fP.
7408 The return status is 0 unless an invalid option is encountered,
7411 is not a valid shell variable name, or
7415 that is not a function.
7417 \fBreturn\fP [\fIn\fP]
7418 Causes a function to exit with the return value specified by
7422 is omitted, the return status is that of the last command
7423 executed in the function body. If used outside a function,
7424 but during execution of a script by the
7426 (\fBsource\fP) command, it causes the shell to stop executing
7427 that script and return either
7429 or the exit status of the last command executed within the
7430 script as the exit status of the script. If used outside a
7431 function and not during execution of a script by \fB.\fP\^,
7432 the return status is false.
7433 Any command associated with the \fBRETURN\fP trap is executed
7434 before execution resumes after the function or script.
7436 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
7437 Without options, the name and value of each shell variable are displayed
7438 in a format that can be reused as input.
7439 The output is sorted according to the current locale.
7440 When options are specified, they set or unset shell attributes.
7441 Any arguments remaining after the options are processed are treated
7442 as values for the positional parameters and are assigned, in order, to
7447 Options, if specified, have the following meanings:
7452 Automatically mark variables and functions which are modified or
7453 created for export to the environment of subsequent commands.
7456 Report the status of terminated background jobs
7457 immediately, rather than before the next primary prompt. This is
7458 effective only when job control is enabled.
7461 Exit immediately if a \fIsimple command\fP (see
7464 above) exits with a non-zero status.
7465 The shell does not exit if the
7466 command that fails is part of the command list immediately following a
7471 part of the test in an
7473 statement, part of a
7477 list, or if the command's return value is
7480 A trap on \fBERR\fP, if set, is executed before the shell exits.
7483 Disable pathname expansion.
7486 Remember the location of commands as they are looked up for execution.
7487 This is enabled by default.
7490 All arguments in the form of assignment statements
7491 are placed in the environment for a command, not just
7492 those that precede the command name.
7495 Monitor mode. Job control is enabled. This option is on
7496 by default for interactive shells on systems that support
7500 above). Background processes run in a separate process
7501 group and a line containing their exit status is printed
7502 upon their completion.
7505 Read commands but do not execute them. This may be used to
7506 check a shell script for syntax errors. This is ignored by
7509 .B \-o \fIoption\-name\fP
7510 The \fIoption\-name\fP can be one of the following:
7522 Use an emacs-style command line editing interface. This is enabled
7523 by default when the shell is interactive, unless the shell is started
7549 Enable command history, as described above under
7552 This option is on by default in interactive shells.
7555 The effect is as if the shell command
7556 .if t \f(CWIGNOREEOF=10\fP
7557 .if n ``IGNOREEOF=10''
7602 If set, the return value of a pipeline is the value of the last
7603 (rightmost) command to exit with a non-zero status, or zero if all
7604 commands in the pipeline exit successfully.
7605 This option is disabled by default.
7608 Change the behavior of
7610 where the default operation differs
7611 from the POSIX 1003.2 standard to match the standard (\fI`posix mode\fP).
7622 Use a vi-style command line editing interface.
7631 is supplied with no \fIoption\-name\fP, the values of the current options are
7635 is supplied with no \fIoption\-name\fP, a series of
7637 commands to recreate the current option settings is displayed on
7638 the standard output.
7644 mode. In this mode, the
7650 files are not processed, shell functions are not inherited from the
7651 environment, and the
7654 variable, if it appears in the environment, is ignored.
7655 If the shell is started with the effective user (group) id not equal to the
7656 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
7657 are taken and the effective user id is set to the real user id.
7658 If the \fB\-p\fP option is supplied at startup, the effective user id is
7660 Turning this option off causes the effective user
7661 and group ids to be set to the real user and group ids.
7664 Exit after reading and executing one command.
7667 Treat unset variables as an error when performing
7668 parameter expansion. If expansion is attempted on an
7669 unset variable, the shell prints an error message, and,
7670 if not interactive, exits with a non-zero status.
7673 Print shell input lines as they are read.
7676 After expanding each \fIsimple command\fP,
7677 \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
7678 arithmetic \fBfor\fP command, display the expanded value of
7681 followed by the command and its expanded arguments
7682 or associated word list.
7685 The shell performs brace expansion (see
7687 above). This is on by default.
7692 does not overwrite an existing file with the
7697 redirection operators. This may be overridden when
7698 creating output files by using the redirection operator
7704 If set, any trap on \fBERR\fP is inherited by shell functions, command
7705 substitutions, and commands executed in a subshell environment.
7706 The \fBERR\fP trap is normally not inherited in such cases.
7711 style history substitution. This option is on by
7712 default when the shell is interactive.
7715 If set, the shell does not follow symbolic links when executing
7718 that change the current working directory. It uses the
7719 physical directory structure instead. By default,
7721 follows the logical chain of directories when performing commands
7722 which change the current directory.
7725 If set, any trap on \fBDEBUG\fP is inherited by shell functions, command
7726 substitutions, and commands executed in a subshell environment.
7727 The \fBDEBUG\fP trap is normally not inherited in such cases.
7730 If no arguments follow this option, then the positional parameters are
7731 unset. Otherwise, the positional parameters are set to the
7732 \fIarg\fPs, even if some of them begin with a
7736 Signal the end of options, cause all remaining \fIarg\fPs to be
7737 assigned to the positional parameters. The
7741 options are turned off.
7742 If there are no \fIarg\fPs,
7743 the positional parameters remain unchanged.
7746 The options are off by default unless otherwise noted.
7747 Using + rather than \- causes these options to be turned off.
7748 The options can also be specified as arguments to an invocation of
7750 The current set of options may be found in
7752 The return status is always true unless an invalid option is encountered.
7755 \fBshift\fP [\fIn\fP]
7756 The positional parameters from \fIn\fP+1 ... are renamed to
7759 Parameters represented by the numbers \fB$#\fP
7760 down to \fB$#\fP\-\fIn\fP+1 are unset.
7762 must be a non-negative number less than or equal to \fB$#\fP.
7765 is 0, no parameters are changed.
7768 is not given, it is assumed to be 1.
7771 is greater than \fB$#\fP, the positional parameters are not changed.
7772 The return status is greater than zero if
7776 or less than zero; otherwise 0.
7778 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
7779 Toggle the values of variables controlling optional shell behavior.
7780 With no options, or with the
7782 option, a list of all settable options is displayed, with
7783 an indication of whether or not each is set.
7784 The \fB\-p\fP option causes output to be displayed in a form that
7785 may be reused as input.
7786 Other options have the following meanings:
7791 Enable (set) each \fIoptname\fP.
7794 Disable (unset) each \fIoptname\fP.
7797 Suppresses normal output (quiet mode); the return status indicates
7798 whether the \fIoptname\fP is set or unset.
7799 If multiple \fIoptname\fP arguments are given with
7801 the return status is zero if all \fIoptnames\fP are enabled; non-zero
7805 Restricts the values of \fIoptname\fP to be those defined for the
7816 is used with no \fIoptname\fP arguments, the display is limited to
7817 those options which are set or unset, respectively.
7818 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
7821 The return status when listing options is zero if all \fIoptnames\fP
7822 are enabled, non-zero otherwise. When setting or unsetting options,
7823 the return status is zero unless an \fIoptname\fP is not a valid shell
7826 The list of \fBshopt\fP options is:
7832 If set, an argument to the
7834 builtin command that
7835 is not a directory is assumed to be the name of a variable whose
7836 value is the directory to change to.
7839 If set, minor errors in the spelling of a directory component in a
7841 command will be corrected.
7842 The errors checked for are transposed characters,
7843 a missing character, and one character too many.
7844 If a correction is found, the corrected file name is printed,
7845 and the command proceeds.
7846 This option is only used by interactive shells.
7849 If set, \fBbash\fP checks that a command found in the hash
7850 table exists before trying to execute it. If a hashed command no
7851 longer exists, a normal path search is performed.
7854 If set, \fBbash\fP checks the window size after each command
7855 and, if necessary, updates the values of
7865 attempts to save all lines of a multiple-line
7866 command in the same history entry. This allows
7867 easy re-editing of multi-line commands.
7872 includes filenames beginning with a `.' in the results of pathname
7876 If set, a non-interactive shell will not exit if
7877 it cannot execute the file specified as an argument to the
7879 builtin command. An interactive shell does not exit if
7884 If set, aliases are expanded as described above under
7887 This option is enabled by default for interactive shells.
7890 If set, behavior intended for use by debuggers is enabled:
7894 The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
7895 file name and line number corresponding to each function name supplied
7899 If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
7900 next command is skipped and not executed.
7903 If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
7904 shell is executing in a subroutine (a shell function or a shell script
7905 executed by the \fB.\fP or \fBsource\fP builtins), a call to
7906 \fBreturn\fP is simulated.
7910 If set, the extended pattern matching features described above under
7911 \fBPathname Expansion\fP are enabled.
7914 If set, \fB$\fP'\fIstring\fP' and \fB$\fP"\fIstring\fP" quoting is
7915 performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
7916 enclosed in double quotes. This option is enabled by default.
7919 If set, patterns which fail to match filenames during pathname expansion
7920 result in an expansion error.
7923 If set, the suffixes specified by the \fBFIGNORE\fP shell variable
7924 cause words to be ignored when performing word completion even if
7925 the ignored words are the only possible completions.
7928 \fBSHELL VARIABLES\fP
7929 above for a description of \fBFIGNORE\fP.
7930 This option is enabled by default.
7933 If set, shell error messages are written in the standard GNU error
7937 If set, the history list is appended to the file named by the value
7940 variable when the shell exits, rather than overwriting the file.
7945 is being used, a user is given the opportunity to re-edit a
7946 failed history substitution.
7951 is being used, the results of history substitution are not immediately
7952 passed to the shell parser. Instead, the resulting line is loaded into
7953 the \fBreadline\fP editing buffer, allowing further modification.
7958 is being used, \fBbash\fP will attempt to perform hostname completion when a
7959 word containing a \fB@\fP is being completed (see
7965 This is enabled by default.
7968 If set, \fBbash\fP will send
7971 to all jobs when an interactive login shell exits.
7973 .B interactive_comments
7974 If set, allow a word beginning with
7976 to cause that word and all remaining characters on that
7977 line to be ignored in an interactive shell (see
7980 above). This option is enabled by default.
7985 option is enabled, multi-line commands are saved to the history with
7986 embedded newlines rather than using semicolon separators where possible.
7989 The shell sets this option if it is started as a login shell (see
7993 The value may not be changed.
7996 If set, and a file that \fBbash\fP is checking for mail has been
7997 accessed since the last time it was checked, the message ``The mail in
7998 \fImailfile\fP has been read'' is displayed.
8000 .B no_empty_cmd_completion
8005 will not attempt to search the \fBPATH\fP for possible completions when
8006 completion is attempted on an empty line.
8011 matches filenames in a case\-insensitive fashion when performing pathname
8013 .B Pathname Expansion
8019 allows patterns which match no
8021 .B Pathname Expansion
8023 to expand to a null string, rather than themselves.
8026 If set, the programmable completion facilities (see
8027 \fBProgrammable Completion\fP above) are enabled.
8028 This option is enabled by default.
8031 If set, prompt strings undergo
8032 parameter expansion, command substitution, arithmetic
8033 expansion, and quote removal after being expanded as described in
8036 above. This option is enabled by default.
8039 The shell sets this option if it is started in restricted mode (see
8041 .B "RESTRICTED SHELL"
8043 The value may not be changed.
8044 This is not reset when the startup files are executed, allowing
8045 the startup files to discover whether or not a shell is restricted.
8050 builtin prints an error message when the shift count exceeds the
8051 number of positional parameters.
8055 \fBsource\fP (\fB.\fP) builtin uses the value of
8058 to find the directory containing the file supplied as an argument.
8059 This option is enabled by default.
8062 If set, the \fBecho\fP builtin expands backslash-escape sequences
8066 \fBsuspend\fP [\fB\-f\fP]
8067 Suspend the execution of this shell until it receives a
8072 option says not to complain if this is
8073 a login shell; just suspend anyway. The return status is 0 unless
8074 the shell is a login shell and
8076 is not supplied, or if job control is not enabled.
8078 \fBtest\fP \fIexpr\fP
8081 \fB[\fP \fIexpr\fP \fB]\fP
8082 Return a status of 0 or 1 depending on
8083 the evaluation of the conditional expression
8085 Each operator and operand must be a separate argument.
8086 Expressions are composed of the primaries described above under
8088 .BR "CONDITIONAL EXPRESSIONS" .
8091 Expressions may be combined using the following operators, listed
8092 in decreasing order of precedence.
8102 Returns the value of \fIexpr\fP.
8103 This may be used to override the normal precedence of operators.
8105 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
8112 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
8120 \fBtest\fP and \fB[\fP evaluate conditional
8121 expressions using a set of rules based on the number of arguments.
8127 The expression is false.
8130 The expression is true if and only if the argument is not null.
8133 If the first argument is \fB!\fP, the expression is true if and
8134 only if the second argument is null.
8135 If the first argument is one of the unary conditional operators listed above
8138 .BR "CONDITIONAL EXPRESSIONS" ,
8139 the expression is true if the unary test is true.
8140 If the first argument is not a valid unary conditional operator, the expression
8144 If the second argument is one of the binary conditional operators listed above
8147 .BR "CONDITIONAL EXPRESSIONS" ,
8148 the result of the expression is the result of the binary test using
8149 the first and third arguments as operands.
8150 If the first argument is \fB!\fP, the value is the negation of
8151 the two-argument test using the second and third arguments.
8152 If the first argument is exactly \fB(\fP and the third argument is
8153 exactly \fB)\fP, the result is the one-argument test of the second
8155 Otherwise, the expression is false.
8156 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
8160 If the first argument is \fB!\fP, the result is the negation of
8161 the three-argument expression composed of the remaining arguments.
8162 Otherwise, the expression is parsed and evaluated according to
8163 precedence using the rules listed above.
8166 The expression is parsed and evaluated according to precedence
8167 using the rules listed above.
8172 Print the accumulated user and system times for the shell and
8173 for processes run from the shell. The return status is 0.
8175 \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
8178 is to be read and executed when the shell receives
8183 is absent (and there is a single \fIsigspec\fP) or
8185 each specified signal is
8186 reset to its original disposition (the value it had
8187 upon entrance to the shell).
8190 is the null string the signal specified by each
8192 is ignored by the shell and by the commands it invokes.
8197 has been supplied, then the trap commands associated with each
8200 If no arguments are supplied or if only
8204 prints the list of commands associated with each signal.
8207 option causes the shell to print a list of signal names and
8208 their corresponding numbers.
8212 a signal name defined in <\fIsignal.h\fP>, or a signal number.
8213 Signal names are case insensitive and the SIG prefix is optional.
8221 is executed on exit from the shell.
8229 is executed before every \fIsimple command\fP, \fIfor\fP command,
8230 \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
8231 command, and before the first command executes in a shell function (see
8235 Refer to the description of the \fBextglob\fP option to the
8236 \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
8244 is executed whenever a simple command has a non\-zero exit status,
8245 subject to the following conditions.
8249 trap is not executed if the failed
8250 command is part of the command list immediately following a
8255 part of the test in an
8257 statement, part of a
8261 list, or if the command's return value is
8264 These are the same conditions obeyed by the \fBerrexit\fP option.
8272 is executed each time a shell function or a script executed with the
8273 \fB.\fP or \fBsource\fP builtins finishes executing.
8274 Signals ignored upon entry to the shell cannot be trapped or reset.
8275 Trapped signals are reset to their original values in a child
8276 process when it is created.
8277 The return status is false if any
8279 is invalid; otherwise
8283 \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
8287 would be interpreted if used as a command name.
8292 prints a string which is one of
8301 is an alias, shell reserved word, function, builtin, or disk file,
8305 is not found, then nothing is printed, and an exit status of false
8311 either returns the name of the disk file
8312 that would be executed if
8314 were specified as a command name,
8316 .if t \f(CWtype -t name\fP
8317 .if n ``type -t name''
8325 search for each \fIname\fP, even if
8326 .if t \f(CWtype -t name\fP
8327 .if n ``type -t name''
8330 If a command is hashed,
8334 print the hashed value, not necessarily the file that appears
8342 prints all of the places that contain
8345 This includes aliases and functions,
8348 option is not also used.
8349 The table of hashed commands is not consulted
8354 option suppresses shell function lookup, as with the \fBcommand\fP builtin.
8356 returns true if any of the arguments are found, false if
8359 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
8360 Provides control over the resources available to the shell and to
8361 processes started by it, on systems that allow such control.
8362 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
8363 set for the given resource. A hard limit cannot be increased once it
8364 is set; a soft limit may be increased up to the value of the hard limit.
8365 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
8369 can be a number in the unit specified for the resource
8370 or one of the special values
8375 which stand for the current hard limit, the current soft limit, and
8376 no limit, respectively.
8379 is omitted, the current value of the soft limit of the resource is
8380 printed, unless the \fB\-H\fP option is given. When more than one
8381 resource is specified, the limit name and unit are printed before the value.
8382 Other options are interpreted as follows:
8387 All current limits are reported
8390 The maximum size of core files created
8393 The maximum size of a process's data segment
8396 The maximum size of files created by the shell
8399 The maximum size that may be locked into memory
8402 The maximum resident set size
8405 The maximum number of open file descriptors (most systems do not
8406 allow this value to be set)
8409 The pipe size in 512-byte blocks (this may not be set)
8412 The maximum stack size
8415 The maximum amount of cpu time in seconds
8418 The maximum number of processes available to a single user
8421 The maximum amount of virtual memory available to the shell
8426 is given, it is the new value of the specified resource (the
8428 option is display only).
8429 If no option is given, then
8431 is assumed. Values are in 1024-byte increments, except for
8433 which is in seconds,
8435 which is in units of 512-byte blocks,
8440 which are unscaled values.
8441 The return status is 0 unless an invalid option or argument is supplied,
8442 or an error occurs while setting a new limit.
8445 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
8446 The user file-creation mask is set to
8450 begins with a digit, it
8451 is interpreted as an octal number; otherwise
8452 it is interpreted as a symbolic mode mask similar
8457 is omitted, the current value of the mask is printed.
8460 option causes the mask to be printed in symbolic form; the
8461 default output is an octal number.
8464 option is supplied, and
8466 is omitted, the output is in a form that may be reused as input.
8467 The return status is 0 if the mode was successfully changed or if
8468 no \fImode\fP argument was supplied, and false otherwise.
8470 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
8471 Remove each \fIname\fP from the list of defined aliases. If
8473 is supplied, all alias definitions are removed. The return
8474 value is true unless a supplied
8476 is not a defined alias.
8478 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
8481 remove the corresponding variable or function.
8482 If no options are supplied, or the
8484 option is given, each
8486 refers to a shell variable.
8487 Read-only variables may not be unset.
8493 refers to a shell function, and the function definition
8495 Each unset variable or function is removed from the environment
8496 passed to subsequent commands.
8513 are unset, they lose their special properties, even if they are
8514 subsequently reset. The exit status is true unless a
8518 \fBwait\fP [\fIn\fP]
8519 Wait for the specified process and return its termination
8523 ID or a job specification; if a job spec is given, all processes
8524 in that job's pipeline are waited for. If
8526 is not given, all currently active child processes
8527 are waited for, and the return status is zero. If
8529 specifies a non-existent process or job, the return status is
8530 127. Otherwise, the return status is the exit status of the last
8531 process or job waited for.
8534 .SH "RESTRICTED SHELL"
8540 is started with the name
8544 option is supplied at invocation,
8545 the shell becomes restricted.
8546 A restricted shell is used to
8547 set up an environment more controlled than the standard shell.
8548 It behaves identically to
8550 with the exception that the following are disallowed or not performed:
8552 changing directories with \fBcd\fP
8554 setting or unsetting the values of
8561 specifying command names containing
8564 specifying a file name containing a
8566 as an argument to the
8570 Specifying a filename containing a slash as an argument to the
8576 importing function definitions from the shell environment at startup
8578 parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
8580 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
8584 builtin command to replace the shell with another command
8586 adding or deleting builtin commands with the
8594 Using the \fBenable\fP builtin command to enable disabled shell builtins
8602 turning off restricted mode with
8603 \fBset +r\fP or \fBset +o restricted\fP.
8605 These restrictions are enforced after any startup files are read.
8607 .ie \n(zY=1 When a command that is found to be a shell script is executed,
8608 .el \{ When a command that is found to be a shell script is executed
8611 .B "COMMAND EXECUTION"
8615 turns off any restrictions in the shell spawned to execute the
8622 \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
8624 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
8626 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
8628 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
8630 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
8632 \fIemacs\fP(1), \fIvi\fP(1)
8640 The \fBbash\fP executable
8643 The systemwide initialization file, executed for login shells
8646 The personal initialization file, executed for login shells
8649 The individual per-interactive-shell startup file
8652 The individual login shell cleanup file, executed when a login shell exits
8655 Individual \fIreadline\fP initialization file
8658 Brian Fox, Free Software Foundation
8662 Chet Ramey, Case Western Reserve University
8666 If you find a bug in
8668 you should report it. But first, you should
8669 make sure that it really is a bug, and that it appears in the latest
8672 The latest version is always available from
8673 \fIftp://ftp.gnu.org/pub/bash/\fP.
8675 Once you have determined that a bug actually exists, use the
8677 command to submit a bug report.
8678 If you have a fix, you are encouraged to mail that as well!
8679 Suggestions and `philosophical' bug reports may be mailed
8680 to \fIbug-bash@gnu.org\fP or posted to the Usenet
8684 ALL bug reports should include:
8688 The version number of \fBbash\fR
8690 The hardware and operating system
8692 The compiler used to compile
8694 A description of the bug behaviour
8696 A short script or `recipe' which exercises the bug
8700 inserts the first three items automatically into the template
8701 it provides for filing a bug report.
8703 Comments and bug reports concerning
8704 this manual page should be directed to
8705 .IR chet@po.CWRU.Edu .
8708 It's too big and too slow.
8710 There are some subtle differences between
8712 and traditional versions of
8714 mostly because of the
8719 Aliases are confusing in some uses.
8721 Shell builtin commands and functions are not stoppable/restartable.
8723 Compound commands and command sequences of the form `a ; b ; c'
8724 are not handled gracefully when process suspension is attempted.
8725 When a process is stopped, the shell immediately executes the next
8726 command in the sequence.
8727 It suffices to place the sequence of commands between
8728 parentheses to force it into a subshell, which may be stopped as
8731 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
8732 parsed until substitution is attempted. This will delay error
8733 reporting until some time after the command is entered. For example,
8734 unmatched parentheses, even inside shell comments, will result in
8735 error messages while the construct is being read.
8737 Array variables may not (yet) be exported.