2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
9 .\" Last Change: Mon Nov 25 15:36:20 EST 1996
11 .\" bash_builtins, strip all but Built-Ins section
13 .TH BASH 1 "1996 Nov 25" GNU
15 .\" There's some problem with having a `@'
16 .\" in a tagged paragraph with the BSD man macros.
17 .\" It has to do with `@' appearing in the }1 macro.
18 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
19 .\" appears to have fixed it.
20 .\" If you're seeing the characters
21 .\" `@u-3p' appearing before the lines reading
22 .\" `possible-hostname-completions
23 .\" and `complete-hostname' down in READLINE,
24 .\" then uncomment this redefinition.
29 .if !"\\$1"" .nr )I \\$1n
32 .in \\n()Ru+\\n(INu+\\n()Iu
34 .ie !\\n()Iu+\\n()Ru-\w
\a\\*(]X
\au-3p \{\\*(]X
36 .el \\*(]X\h
\a|\\n()Iu+\\n()Ru
\a\c
40 .\" File Name macro. This used to be `.PN', for Path Name,
41 .\" but Sun doesn't seem to like that very much.
47 bash \- GNU Bourne-Again SHell
53 .if n Bash is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
54 .if t Bash is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
57 is an \fBsh\fR-compatible command language interpreter that
58 executes commands read from the standard input or from a file.
60 also incorporates useful features from the \fIKorn\fP and \fIC\fP
61 shells (\fBksh\fP and \fBcsh\fP).
64 is ultimately intended to be a conformant implementation of the IEEE
65 POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
67 In addition to the single-character shell options documented in the
68 description of the \fBset\fR builtin command, \fBbash\fR
69 interprets the following flags when it is invoked:
76 flag is present, then commands are read from
78 If there are arguments after the
80 they are assigned to the positional parameters, starting with
86 flag is present, the shell becomes
96 flag is present, the shell is
102 flag is present, or if no arguments remain after option
103 processing, then commands are read from the standard input.
104 This option allows the positional parameters to be set
105 when invoking an interactive shell.
108 A list of all double-quoted strings preceded by \fB$\fP
109 is printed on the standard ouput.
110 These are the strings that
111 are subject to language translation when the current locale
113 This implies the \fB\-n\fP option; no commands will be executed.
118 signals the end of options and disables further option processing.
119 Any arguments after the
121 are treated as filenames and arguments. An argument of
123 is equivalent to \fB\-\-\fP.
127 also interprets a number of multi-character options.
128 These options must appear on the command line before the
129 single-character options in order for them to be recognized.
134 Equivalent to \fB\-D\fP.
137 Display a usage message on standard output and exit successfully.
142 act as if it had been invoked as a login shell (see
150 library to read command lines if interactive.
153 Do not read either the system-wide startup file
155 or any of the personal initialization files
156 .IR ~/.bash_profile ,
162 reads these files when it is invoked as a login shell (see
168 Do not read and execute the personal initialization file
170 if the shell is interactive.
171 This option is on by default if the shell is invoked as
175 Change the behavior of \fBbash\fP where the default operation differs
176 from the POSIX 1003.2 standard to match the standard.
178 \fB\-\-rcfile\fP \fIfile\fP
179 Execute commands from
181 instead of the standard personal initialization file
183 if the shell is interactive (see
189 The shell becomes restricted (see
191 .B "RESTRICTED SHELL"
195 Equivalent to \fB\-v\fP.
198 Show version information for this instance of
200 on the standard output and exit successfully.
203 If arguments remain after option processing, and neither the
207 option has been supplied, the first argument is assumed to
208 be the name of a file containing shell commands.
211 is invoked in this fashion,
213 is set to the name of the file, and the positional parameters
214 are set to the remaining arguments.
216 reads and executes commands from this file, then exits.
217 \fBBash\fP's exit status is the exit status of the last command
218 executed in the script.
219 If no commands are executed, the exit status is 0.
221 A \fIlogin shell\fP is one whose first character of argument zero is a
223 or one started with the
227 An \fIinteractive\fP shell is one whose standard input and output are
228 both connected to terminals (as determined by
230 or one started with the
242 allowing a shell script or a startup file to test this state.
244 The following paragraphs describe how
246 executes its startup files.
247 If any of the files exist but cannot be read,
250 Tildes are expanded in file names as described below under
259 is invoked as a login shell, it first reads and executes commands
260 from the file \fI/etc/profile\fP, if that file exists.
261 After reading that file, it looks for \fI~/.bash_profile\fP,
262 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
263 and executes commands from the first one that exists and is readable.
266 option may be used when the shell is started to inhibit this behavior.
268 When a login shell exits,
270 reads and executes commands from the file \fI~/.bash_logout\fP, if it
273 When an interactive shell that is not a login shell is started,
275 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
276 This may be inhibited by using the
279 The \fB\-\-rcfile\fP \fIfile\fP option will force
281 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
285 is started non-interactively, to run a shell script, for example, it
286 looks for the variable
289 in the environment, expands its value if it appears there, and uses the
290 expanded value as the name of a file to read and execute.
292 behaves as if the following command were executed:
295 \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
301 variable is not used to search for the file name.
305 is invoked with the name
307 it tries to mimic the startup behavior of historical versions of
309 as closely as possible,
310 while conforming to the POSIX standard as well.
311 When invoked as a login shell, it first attempts to read and execute
319 option may be used to inhibit this behavior.
320 When invoked as an interactive shell with the name
323 looks for the variable
326 expands its value if it is defined, and uses the
327 expanded value as the name of a file to read and execute.
328 Since a shell invoked as
330 does not attempt to read and execute commands from any other startup
333 option has no effect.
334 A non-interactive shell invoked with the name
336 does not attempt to read any startup files.
342 mode after the startup files are read.
350 command line option, it follows the POSIX standard for startup files.
354 variable is expanded and commands are read and executed from the file
355 whose name is the expanded value.
356 No other startup files are read.
357 This is done by interactive shells only.
360 attempts to determine when it is being run by the remote shell
361 daemon, usually \fIrshd\fP.
364 determines it is being run by \fIrshd\fP, it reads and executes
365 commands from \fI~/.bashrc\fP, if that file exists and is readable.
366 It will not do this if invoked as \fBsh\fP.
369 option may be used to inhibit this behavior, and the
371 option may be used to force another file to be read, but
372 \fIrshd\fP does not generally invoke the shell with those options
373 or allow them to be specified.
376 The following definitions are used throughout the rest of this
384 A sequence of characters considered as a single unit by the shell.
391 consisting only of alphanumeric characters and underscores, and
392 beginning with an alphabetic character or an underscore. Also
397 A character that, when unquoted, separates words. One of the following:
401 .if t \fB| & ; ( ) < > space tab\fP
402 .if n \fB| & ; ( ) < > space tab\fP
407 A \fItoken\fP that performs a control function. It is one of the following
411 .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
412 .if n \fB|| & && ; ;; ( ) | <newline>\fP
416 \fIReserved words\fP are words that have a special meaning to the shell.
417 The following words are recognized as reserved when unquoted and either
418 the first word of a simple command (see
421 below) or the third word of a
429 .if n ! case do done elif else esac fi for function if in select then until while { } time
430 .if t ! case do done elif else esac fi for function if in select then until while { } time
436 A \fIsimple command\fP is a sequence of optional variable assignments
437 followed by \fBblank\fP-separated words and redirections, and
438 terminated by a \fIcontrol operator\fP. The first word
439 specifies the command to be executed. The remaining words are
440 passed as arguments to the invoked command.
442 The return value of a \fIsimple command\fP is its exit status, or
443 128+\fIn\^\fP if the command is terminated by signal
447 A \fIpipeline\fP is a sequence of one or more commands separated by
450 The format for a pipeline is:
453 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
456 The standard output of
458 is connected to the standard input of
460 This connection is performed before any redirections specified by the
468 precedes a pipeline, the exit status of that
469 pipeline is the logical NOT of the exit status of the last command.
470 Otherwise, the status of the pipeline is the exit status of the last
472 The shell waits for all commands in the pipeline to
473 terminate before returning a value.
477 reserved word precedes a pipeline, the elapsed as well as user and
478 system time consumed by its execution are reported when the pipeline
480 The \fB\-p\fP option changes the output format to that specified by POSIX.
484 variable may be set to a format string that specifies how the timing
485 information should be displayed; see the description of
492 Each command in a pipeline is executed as a separate process (i.e., in a
496 A \fIlist\fP is a sequence of one or more pipelines separated by one
503 and optionally terminated by one of
509 Of these list operators,
513 have equal precedence, followed by
517 which have equal precedence.
519 If a command is terminated by the control operator
521 the shell executes the command in the \fIbackground\fP
522 in a subshell. The shell does not wait for the command to
523 finish, and the return status is 0. Commands separated by a
525 are executed sequentially; the shell waits for each
526 command to terminate in turn. The return status is the
527 exit status of the last command executed.
529 The control operators
533 denote AND lists and OR lists, respectively.
534 An AND list has the form
537 \fIcommand\fP \fB&&\fP \fIcommand2\fP
541 is executed if, and only if,
543 returns an exit status of zero.
545 An OR list has the form
548 \fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP
553 is executed if and only if
555 returns a non-zero exit status. The return status of
556 AND and OR lists is the exit status of the last command
557 executed in the list.
558 .SS Compound Commands
560 A \fIcompound command\fP is one of the following:
563 \fIlist\fP is executed in a subshell. Variable assignments and builtin
564 commands that affect the shell's environment do not remain in effect
565 after the command completes. The return status is the exit status of
569 \fIlist\fP is simply executed in the current shell environment.
570 \fIlist\fP must be terminated with a newline or semicolon.
571 This is known as a \fIgroup command\fP.
572 The return status is the exit status of
576 The \fIexpression\fP is evaluated according to the rules described
579 .BR "ARITHMETIC EVALUATION" .
580 If the value of the expression is non-zero, the return status is 0;
581 otherwise the return status is 1. This is exactly equivalent to
582 \fBlet "\fIexpression\fP"\fR.
584 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
585 The list of words following \fBin\fP is expanded, generating a list
586 of items. The variable \fIname\fP is set to each element of this list
587 in turn, and \fIlist\fP is executed each time. If the \fBin\fP
588 \fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP
589 once for each positional parameter that is set (see
594 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
595 The list of words following \fBin\fP is expanded, generating a list
596 of items. The set of expanded words is printed on the standard
597 error, each preceded by a number. If the \fBin\fP
598 \fIword\fP is omitted, the positional parameters are printed (see
603 prompt is then displayed and a line read from the standard input.
604 If the line consists of a number corresponding to one of
605 the displayed words, then the value of
607 is set to that word. If the line is empty, the words and prompt
608 are displayed again. If EOF is read, the command completes. Any
609 other value read causes
611 to be set to null. The line read is saved in the variable
615 is executed after each selection until a
622 is the exit status of the last command executed in
624 or zero if no commands were executed.
626 \fBcase\fP \fIword\fP \fBin\fP [ \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
627 ... ) \fIlist\fP ;; ] ... \fBesac\fP
628 A \fBcase\fP command first expands \fIword\fP, and tries to match
629 it against each \fIpattern\fP in turn, using the same matching rules
630 as for pathname expansion (see
631 .B Pathname Expansion
632 below). When a match is found, the
633 corresponding \fIlist\fP is executed. After the first match, no
634 subsequent matches are attempted. The exit status is zero if no
635 pattern matches. Otherwise, it is the exit status of the
636 last command executed in \fIlist\fP.
638 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
639 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
640 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
644 is executed. If its exit status is zero, the
645 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
646 \fIlist\fP is executed in turn, and if its exit status is zero,
647 the corresponding \fBthen\fP \fIlist\fP is executed and the
648 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
649 executed, if present. The exit status is the exit status of the
650 last command executed, or zero if no condition tested true.
653 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
655 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
657 The \fBwhile\fP command continuously executes the \fBdo\fP
658 \fIlist\fP as long as the last command in \fIlist\fP returns
659 an exit status of zero. The \fBuntil\fP command is identical
660 to the \fBwhile\fP command, except that the test is negated;
664 is executed as long as the last command in
666 returns a non-zero exit status.
667 The exit status of the \fBwhile\fP and \fBuntil\fP commands
669 of the last \fBdo\fP \fIlist\fP command executed, or zero if
672 [ \fBfunction\fP ] \fIname\fP () { \fIlist\fP; }
673 This defines a function named \fIname\fP. The \fIbody\fP of the
676 of commands between { and }. This list
677 is executed whenever \fIname\fP is specified as the
678 name of a simple command. The exit status of a function is
679 the exit status of the last command executed in the body. (See
684 In a non-interactive shell, or an interactive shell in which the
685 .B interactive_comments
688 builtin is enabled (see
690 .B "SHELL BUILTIN COMMANDS"
691 below), a word beginning with
693 causes that word and all remaining characters on that line to
694 be ignored. An interactive shell without the
695 .B interactive_comments
697 option enabled does not allow comments. The
698 .B interactive_comments
699 option is on by default in interactive shells.
701 \fIQuoting\fP is used to remove the special meaning of certain
702 characters or words to the shell. Quoting can be used to
703 disable special treatment for special characters, to prevent
704 reserved words from being recognized as such, and to prevent
707 Each of the \fImetacharacters\fP listed above under
710 has special meaning to the shell and must be quoted if they are to
711 represent themselves. There are three quoting mechanisms: the
712 .IR "escape character" ,
713 single quotes, and double quotes.
715 A non-quoted backslash (\fB\e\fP) is the
716 .IR "escape character" .
717 It preserves the literal value of the next character that follows,
718 with the exception of <newline>. If a \fB\e\fP<newline> pair
719 appears, and the backslash is not quoted, the \fB\e\fP<newline>
720 is treated as a line continuation (that is, it is effectively ignored).
722 Enclosing characters in single quotes preserves the literal value
723 of each character within the quotes. A single quote may not occur
724 between single quotes, even when preceded by a backslash.
726 Enclosing characters in double quotes preserves the literal value
727 of all characters within the quotes, with the exception of
736 retain their special meaning within double quotes. The backslash
737 retains its special meaning only when followed by one of the following
745 A double quote may be quoted within double quotes by preceding it with
748 The special parameters
752 have special meaning when in double
758 Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
759 word expands to \fIstring\fP, with backslash-escaped characters replaced
760 as specifed by the ANSI C standard. Backslash escape sequences, if
761 present, are decoded as follows:
793 the character whose ASCII code is \fInnn\fP (octal)
797 The translated result is single-quoted, as if the dollar sign had
800 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
801 the string to be translated according to the current locale.
802 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
804 If the string is translated and replaced, the replacement is
809 is an entity that stores values.
812 a number, or one of the special characters listed below under
813 .BR "Special Parameters" .
814 For the shell's purposes, a
816 is a parameter denoted by a
819 A parameter is set if it has been assigned a value. The null string is
820 a valid value. Once a variable is set, it may be unset only by using
825 .B SHELL BUILTIN COMMANDS
830 may be assigned to by a statement of the form
833 \fIname\fP=[\fIvalue\fP]
838 is not given, the variable is assigned the null string. All
840 undergo tilde expansion, parameter and variable expansion, string
841 expansion, command substitution, arithmetic expansion, and quote
845 below). If the variable has its
851 .BR "SHELL BUILTIN COMMANDS" )
854 is subject to arithmetic expansion even if the $((...)) syntax does
856 .B "Arithmetic Expansion"
858 Word splitting is not performed, with the exception
859 of \fB"$@"\fP as explained below under
860 .BR "Special Parameters" .
861 Pathname expansion is not performed.
862 .SS Positional Parameters
865 .I positional parameter
866 is a parameter denoted by one or more
867 digits, other than the single digit 0. Positional parameters are
868 assigned from the shell's arguments when it is invoked,
869 and may be reassigned using the
871 builtin command. Positional parameters may not be assigned to
872 with assignment statements. The positional parameters are
873 temporarily replaced when a shell function is executed (see
878 When a positional parameter consisting of more than a single
879 digit is expanded, it must be enclosed in braces (see
883 .SS Special Parameters
885 The shell treats several parameters specially. These parameters may
886 only be referenced; assignment to them is not allowed.
890 Expands to the positional parameters, starting from one. When the
891 expansion occurs within double quotes, it expands to a single word
892 with the value of each parameter separated by the first character
896 special variable. That is, ``\fB$*\fP'' is equivalent
897 to ``\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP'', where
899 is the first character of the value of the
905 is null or unset, the parameters are separated by spaces.
908 Expands to the positional parameters, starting from one. When the
909 expansion occurs within double quotes, each parameter expands as a
910 separate word. That is, ``
913 ``\fB$1\fP'' ``\fB$2\fP'' ...
914 When there are no positional parameters, ``\fB$@\fP'' and
916 expand to nothing (i.e., they are removed).
919 Expands to the number of positional parameters in decimal.
922 Expands to the status of the most recently executed foreground
926 Expands to the current option flags as specified upon invocation,
929 builtin command, or those set by the shell itself
935 Expands to the process ID of the shell. In a () subshell, it
936 expands to the process ID of the current shell, not the
940 Expands to the process ID of the most recently executed background
941 (asynchronous) command.
944 Expands to the name of the shell or shell script. This is set at
945 shell initialization. If
947 is invoked with a file of commands,
949 is set to the name of that file. If
955 is set to the first argument after the string to be
956 executed, if one is present. Otherwise, it is set
957 to the file name used to invoke
959 as given by argument zero.
962 At shell startup, set to the absolute file name of the shell or shell
963 script being executed as passed in the argument list.
964 Subsequently, expands to the last argument to the previous command,
966 Also set to the full file name of each command executed and placed in
967 the environment exported to that command.
968 When checking mail, this parameter holds the name of the mail file
969 currently being checked.
973 The following variables are set by the shell:
978 The process ID of the shell's parent.
981 The current working directory as set by the
986 The previous working directory as set by the
991 Set to the line of input read by the
993 builtin command when no arguments are supplied.
996 Expands to the user ID of the current user, initialized at shell startup.
999 Expands to the effective user ID of the current user, initialized at
1003 Expands to the full file name used to invoke this instance of
1007 Expands to a string describing the version of this instance of
1011 An array variable whose members hold version information for this
1014 The values assigned to the array members are as follows:
1019 .B BASH_VERSINFO[\fR0\fP]
1020 The major version number (the \fIrelease\fP).
1022 .B BASH_VERSINFO[\fR1\fP]
1023 The minor version number (the \fIversion\fP).
1025 .B BASH_VERSINFO[\fR2\fP]
1028 .B BASH_VERSINFO[\fR3\fP]
1031 .B BASH_VERSINFO[\fR4\fP]
1032 The release status (e.g., \fIbeta1\fP).
1034 .B BASH_VERSINFO[\fR5\fP]
1035 The value of \fBMACHTYPE\fP.
1040 Incremented by one each time an instance of
1045 Each time this parameter is referenced, a random integer between
1047 generated. The sequence of random numbers may be initialized by assigning
1054 is unset, it loses its special properties, even if it is
1058 Each time this parameter is
1059 referenced, the number of seconds since shell invocation is returned. If a
1060 value is assigned to
1063 the value returned upon subsequent
1065 the number of seconds since the assignment plus the value assigned.
1069 is unset, it loses its special properties, even if it is
1073 Each time this parameter is referenced, the shell substitutes
1074 a decimal number representing the current sequential line number
1075 (starting with 1) within a script or function. When not in a
1076 script or function, the value substituted is not guaranteed to
1081 is unset, it loses its special properties, even if it is
1085 The history number, or index in the history list, of the current
1090 is unset, it loses its special properties, even if it is
1094 An array variable (see
1096 below) containing the current contents of the directory stack.
1097 Directories appear in the stack in the order they are displayed by the
1100 Assigning to members of this array variable may be used to modify
1101 directories already in the stack, but the
1105 builtins must be used to add and remove directories.
1106 Assignment to this variable will not change the current directory.
1110 is unset, it loses its special properties, even if it is
1114 An array variable (see
1116 below) containing a list of exit status values from the processes
1117 in the most-recently-executed foreground pipeline (which may
1118 contain only a single command).
1121 The value of the last option argument processed by the
1123 builtin command (see
1125 .B SHELL BUILTIN COMMANDS
1129 The index of the next argument to be processed by the
1131 builtin command (see
1133 .B SHELL BUILTIN COMMANDS
1137 Automatically set to the name of the current host.
1140 Automatically set to a string that uniquely
1141 describes the type of machine on which
1144 The default is system-dependent.
1147 Automatically set to a string that
1148 describes the operating system on which
1151 The default is system-dependent.
1154 Automatically set to a string that fully describes the system
1157 is executing, in the standard GNU \fIcpu-company-system\fP format.
1158 The default is system-dependent.
1161 A colon-separated list of enabled shell options. Each word in
1162 the list is a valid argument for the
1166 builtin command (see
1168 .B "SHELL BUILTIN COMMANDS"
1169 below). The options appearing in
1172 are those reported as
1175 If this variable is in the environment when
1177 starts up, each shell option in the list will be enabled before
1178 reading any startup files.
1179 This variable is read-only.
1182 The following variables are used by the shell. In some cases,
1184 assigns a default value to a variable; these cases are noted
1191 .I Internal Field Separator
1193 for word splitting after expansion and to
1194 split lines into words with the
1196 builtin command. The default value is
1197 ``<space><tab><newline>''.
1200 The search path for commands. It
1201 is a colon-separated list of directories in which
1202 the shell looks for commands (see
1204 .B COMMAND EXECUTION
1205 below). The default path is system-dependent,
1206 and is set by the administrator who installs
1208 A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
1211 The home directory of the current user; the default argument for the
1212 \fBcd\fP builtin command.
1215 The search path for the
1217 command. This is a colon-separated
1218 list of directories in which the shell looks for destination directories
1221 command. A sample value is
1225 If this parameter is set when \fBbash\fP is executing a shell script,
1226 its value is interpreted as a filename containing commands to
1227 initialize the shell, as in
1232 is subjected to parameter expansion, command substitution, and arithmetic
1233 expansion before being interpreted as a file name.
1236 is not used to search for the resultant file name.
1239 If this parameter is set to a file name and the
1242 variable is not set,
1244 informs the user of the arrival of mail in the specified file.
1250 checks for mail. The default is 60 seconds. When it is time to check
1251 for mail, the shell does so before displaying the primary prompt.
1252 If this variable is unset, the shell disables mail checking.
1255 A colon-separated list of file names to be checked for mail.
1256 The message to be printed may be specified by separating the file name from
1257 the message with a `?'. $_ stands for the name of the current mailfile.
1261 \fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1264 supplies a default value for this variable, but the location of the user
1265 mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP).
1269 The value of this parameter is expanded (see
1272 below) and used as the primary prompt string. The default value is
1273 ``\fB\es\-\ev\e$ \fP''.
1276 The value of this parameter is expanded as with
1278 and used as the secondary prompt string. The default is
1282 The value of this parameter is used as the prompt for the
1290 The value of this parameter is expanded as with
1292 and the value is printed before each command
1294 displays during an execution trace. The first character of
1297 is replicated multiple times, as necessary, to indicate multiple
1298 levels of indirection. The default is ``\fB+ \fP''.
1301 The value of this parameter is used as a format string specifying
1302 how the timing information for pipelines prefixed with the
1304 reserved word should be displayed.
1305 The \fB%\fP character introduces an escape sequence that is
1306 expanded to a time value or other information.
1307 The escape sequences and their meanings are as follows; the
1308 braces denote optional portions.
1317 The elapsed time in seconds.
1320 The number of CPU seconds spent in user mode.
1323 The number of CPU seconds spent in system mode.
1326 The CPU percentage, computed as (%U + %S) / %R.
1330 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1331 the number of fractional digits after a decimal point.
1332 A value of 0 causes no decimal point or fraction to be output.
1333 At most three places after the decimal point may be specified;
1334 values of \fIp\fP greater than 3 are changed to 3.
1335 If \fIp\fP is not specified, the value 3 is used.
1337 The optional \fBl\fP specifies a longer format, including
1338 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1339 The value of \fIp\fP determines whether or not the fraction is
1342 If this variable is not set, \fBbash\fP acts as if it had the
1343 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1344 If the value is null, no timing information is displayed.
1345 A trailing newline is added when the format string is displayed.
1348 The number of commands to remember in the command history (see
1351 below). The default value is 500.
1354 The name of the file in which command history is saved (see
1357 below). The default value is \fI~/.bash_history\fP. If unset, the
1358 command history is not saved when an interactive shell exits.
1361 The maximum number of lines contained in the history file. When this
1362 variable is assigned a value, the history file is truncated, if
1363 necessary, to contain no more than that number of lines. The default
1364 value is 500. The history file is also truncated to this size after
1365 writing it when an interactive shell exits.
1368 If set to the value 1,
1370 displays error messages generated by the
1372 builtin command (see
1374 .B SHELL BUILTIN COMMANDS
1378 is initialized to 1 each time the shell is invoked or a shell
1382 Used to determine the locale category for any category not specifically
1383 selected with a variable starting with \fBLC_\fP.
1386 This variable overrides the value of \fBLANG\fP and any other
1387 \fBLC_\fP variable specifying a locale category.
1390 This variable determines the collation order used when sorting the
1391 results of pathname expansion.
1394 This variable determines the locale used to translate double-quoted
1395 strings preceded by a \fB$\fP.
1398 If set, the value is executed as a command prior to issuing each primary
1403 action of an interactive shell on receipt of an
1406 character as the sole input. If set, the value is the number of
1410 characters which must be
1411 typed as the first characters on an input line before
1413 exits. If the variable exists but does not have a numeric value, or
1414 has no value, the default value is 10. If it does not exist,
1417 signifies the end of input to the shell.
1420 If set to a value greater than zero, the value is interpreted as the
1421 number of seconds to wait for input after issuing the primary prompt.
1423 terminates after waiting for that number of seconds if input does
1427 The default editor for the
1432 A colon-separated list of suffixes to ignore when performing
1433 filename completion (see
1437 A filename whose suffix matches one of the entries in
1440 is excluded from the list of matched filenames.
1441 A sample value is ``.o:~''.
1444 A colon-separated list of patterns defining the set of filenames to
1445 be ignored by pathname expansion.
1446 If a filename matched by a pathname expansion pattern also matches one
1450 it is removed from the list of matches.
1453 The filename for the
1455 startup file, overriding the default of
1463 If set to a value of
1465 lines which begin with a
1467 character are not entered on the history list. If set to
1470 lines matching the last history line are not entered.
1473 combines the two options.
1474 If unset, or if set to any other value than those above,
1476 by the parser are saved on the history list, subject to the value
1479 This variable's function is superseded by
1483 A colon-separated list of patterns used to decide which command lines
1484 should be saved on the history list. Each pattern is anchored at the
1485 beginning of the line and must fully specify the line (no implicit
1486 `\fB*\fP' is appended). Each pattern is tested against the line
1487 after the checks specified by
1490 In addition to the normal shell pattern matching characters, `\fB&\fP'
1491 matches the previous history line. `\fB&\fP' may be escaped using a
1492 backslash. The backslash is removed before attempting a match.
1495 The two or three characters which control history expansion
1496 and tokenization (see
1498 .B HISTORY EXPANSION
1499 below). The first character is the
1500 .IR "history expansion character" ,
1501 that is, the character which signals the start of a history
1502 expansion, normally `\fB!\fP'.
1503 The second character is the
1504 .IR "quick substitution"
1505 character, which is used as shorthand for re-running the previous
1506 command entered, substituting one string for another in the command.
1507 The default is `\fB^\fP'.
1508 The optional third character is the character
1509 which signifies that the remainder of the line is a comment when found
1510 as the first character of a word, normally `\fB#\fP'. The history
1511 comment character causes history substitution to be skipped for the
1512 remaining words on the line. It does not necessarily cause the shell
1513 parser to treat the rest of the line as a comment.
1516 Contains the name of a file in the same format as
1518 that should be read when the shell needs to complete a
1519 hostname. The file may be changed interactively; the next
1520 time hostname completion is attempted
1522 adds the contents of the new file to the already existing database.
1525 This variable controls how the shell interacts with the user and
1526 job control. If this variable is set, single word simple
1527 commands without redirections are treated as candidates for resumption
1528 of an existing stopped job. There is no ambiguity allowed; if there is
1529 more than one job beginning with the string typed, the job most recently
1530 accessed is selected. The
1532 of a stopped job, in this context, is the command line used to
1536 the string supplied must match the name of a stopped job exactly;
1539 the string supplied needs to match a substring of the name of a
1542 value provides functionality analogous to the
1547 below). If set to any other value, the supplied string must
1548 be a prefix of a stopped job's name; this provides functionality
1555 provides one-dimensional array variables. Any variable may be used as
1558 builtin will explicitly declare an array. There is no maximum
1559 limit on the size of an array, nor any requirement that members
1560 be indexed or assigned contiguously. Arrays are indexed using
1561 integers and are zero-based.
1563 An array is created automatically if any variable is assigned to using
1564 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
1566 is treated as an arithmetic expression that must evaluate to a number
1567 greater than or equal to zero. To explicitly declare an array, use
1568 .B declare \-a \fIname\fP
1571 .B SHELL BUILTIN COMMANDS
1573 .B declare \-a \fIname\fP[\fIsubscript\fP]
1574 is also accepted; the \fIsubscript\fP is ignored. Attributes may be
1575 specified for an array variable using the
1579 builtins. Each attribute applies to all members of an array.
1581 Arrays are assigned to using compound assignments of the form
1582 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
1583 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
1584 \fIstring\fP is required. If
1585 the optional brackets and subscript are supplied, that index is assigned to;
1586 otherwise the index of the element assigned is the last index assigned
1587 to by the statement plus one. Indexing starts at zero.
1588 This syntax is also accepted by the
1590 builtin. Individual array elements may be assigned to using the
1591 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
1593 Any element of an array may be referenced using
1594 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
1595 conflicts with pathname expansion. If
1596 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
1597 all members of \fIname\fP. These subscripts differ only when the
1598 word appears within double quotes. If the word is double-quoted,
1599 ${\fIname\fP[*]} expands to a single
1600 word with the value of each array member separated by the first
1604 special variable, and ${\fIname\fP[@]} expands each element of
1605 \fIname\fP to a separate word. When there are no array members,
1606 ${\fIname\fP[@]} expands to nothing. This is analogous to the expansion
1607 of the special parameters \fB*\fP and \fB@\fP (see
1608 .B Special Parameters
1609 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
1610 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
1611 \fB@\fP, the expansion is the number of elements in the array.
1612 Referencing an array variable without a subscript is equivalent to
1613 referencing element zero.
1617 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
1618 destroys the array element at index \fIsubscript\fP.
1619 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
1620 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
1621 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
1628 builtins each accept a
1630 option to specify an array. The
1634 option to assign a list of words read from the standard input
1639 builtins display array values in a way that allows them to be
1640 reused as assignments.
1642 Expansion is performed on the command line after it has been split into
1643 words. There are seven kinds of expansion performed:
1644 .IR "brace expansion" ,
1645 .IR "tilde expansion" ,
1646 .IR "parameter and variable expansion" ,
1647 .IR "command substitution" ,
1648 .IR "arithmetic expansion" ,
1649 .IR "word splitting" ,
1651 .IR "pathname expansion" .
1653 The order of expansions is: brace expansion, tilde expansion,
1654 parameter, variable and arithmetic expansion and
1655 command substitution
1656 (done in a left-to-right fashion), word splitting, and pathname
1659 On systems that can support it, there is an additional expansion
1660 available: \fIprocess substitution\fP.
1662 Only brace expansion, word splitting, and pathname expansion
1663 can change the number of words of the expansion; other expansions
1664 expand a single word to a single word.
1665 The only exceptions to this are the expansions of
1666 ``\fB$@\fP'' and ``\fB${\fP\fIname\fP\fB[@]}\fP''
1667 as explained above (see
1672 .I "Brace expansion"
1673 is a mechanism by which arbitrary strings
1674 may be generated. This mechanism is similar to
1675 \fIpathname expansion\fP, but the filenames generated
1676 need not exist. Patterns to be brace expanded take
1677 the form of an optional
1679 followed by a series of comma-separated strings
1680 between a pair of braces, followed by an optional
1682 The preamble is prefixed to each string contained
1683 within the braces, and the postamble is then appended
1684 to each resulting string, expanding left to right.
1686 Brace expansions may be nested. The results of each expanded
1687 string are not sorted; left to right order is preserved.
1688 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
1690 Brace expansion is performed before any other expansions,
1691 and any characters special to other expansions are preserved
1692 in the result. It is strictly textual.
1694 does not apply any syntactic interpretation to the context of the
1695 expansion or the text between the braces.
1697 A correctly-formed brace expansion must contain unquoted opening
1698 and closing braces, and at least one unquoted comma.
1699 Any incorrectly formed brace expansion is left unchanged.
1700 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
1701 being considered part of a brace expression.
1703 This construct is typically used as shorthand when the common
1704 prefix of the strings to be generated is longer than in the
1708 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1712 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1715 Brace expansion introduces a slight incompatibility with
1716 historical versions of
1719 does not treat opening or closing braces specially when they
1720 appear as part of a word, and preserves them in the output.
1722 removes braces from words as a consequence of brace
1723 expansion. For example, a word entered to
1726 appears identically in the output. The same word is
1731 If strict compatibility with
1737 option or disable brace expansion with the
1743 .B SHELL BUILTIN COMMANDS
1747 If a word begins with a tilde character (`\fB~\fP'), all of the characters
1748 preceding the first slash (or all characters, if there is no slash)
1749 are treated as a possible \fIlogin name\fP. If this \fIlogin name\fP
1750 is the null string, the tilde is replaced with the value of the
1757 is unset, the home directory of
1758 the user executing the shell is substituted instead.
1760 If a `+' follows the tilde, the value of
1763 replaces the tilde and `+'. If
1764 a `\-' follows, the value of
1768 If the value following the tilde is a valid \fIlogin name\fP,
1769 the tilde and \fIlogin name\fP are replaced with the home directory
1770 associated with that name. If the name is invalid, or the tilde
1771 expansion fails, the word is unchanged.
1773 Each variable assignment is checked for unquoted
1774 tildes immediately following a
1778 In these cases, tilde substitution is also performed. Consequently, one
1779 may use file names with tildes in assignments to
1787 and the shell assigns the expanded value.
1788 .SS Parameter Expansion
1790 The `\fB$\fP' character introduces parameter expansion,
1791 command substitution, or arithmetic expansion. The parameter name
1792 or symbol to be expanded may be enclosed in braces, which
1793 are optional but serve to protect the variable to be expanded from
1794 characters immediately following it which could be
1795 interpreted as part of the name.
1800 The value of \fIparameter\fP is substituted. The braces are required
1803 is a positional parameter with more than one digit,
1806 is followed by a character which is not to be
1807 interpreted as part of its name.
1810 If the first character of \fIparameter\fP is an exclamation point,
1811 a level of variable indirection is introduced.
1812 \fBBash\fP uses the value of the variable formed from the rest of
1813 \fIparameter\fP as the name of the variable; this variable is then
1814 expanded and that value used in the rest of the substitution, rather
1815 than the value of \fIparameter\fP itself.
1816 This is known as \fIindirect expansion\fP.
1818 In each of the cases below, \fIword\fP is subject to tilde expansion,
1819 parameter expansion, command substitution, and arithmetic expansion.
1820 When not performing substring expansion, \fBbash\fP tests for a parameter
1821 that is unset or null; omitting the colon results in a test only for a
1822 parameter that is unset.
1826 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
1827 \fBUse Default Values\fP. If
1829 is unset or null, the expansion of
1831 is substituted. Otherwise, the value of
1835 ${\fIparameter\fP\fB:=\fP\fIword\fP}
1836 \fBAssign Default Values\fP.
1839 is unset or null, the expansion of
1845 is then substituted. Positional parameters and special parameters may
1846 not be assigned to in this way.
1848 ${\fIparameter\fP\fB:?\fP\fIword\fP}
1849 \fBDisplay Error if Null or Unset\fP.
1852 is null or unset, the expansion of \fIword\fP (or a message to that effect
1855 is not present) is written to the standard error and the shell, if it
1856 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
1859 ${\fIparameter\fP\fB:+\fP\fIword\fP}
1860 \fBUse Alternate Value\fP.
1863 is null or unset, nothing is substituted, otherwise the expansion of
1868 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
1870 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
1872 \fBSubstring Expansion.\fP
1873 Expands to up to \fIlength\fP characters of \fIparameter\fP,
1874 starting at \fIoffset\fP.
1875 If \fIlength\fP is omitted, expands to the substring of
1876 \fIparameter\fP, starting at the character specified by \fIoffset\fP.
1877 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
1880 ARITHMETIC EVALUATION
1882 \fIlength\fP must evaluate to a number greater than or equal to zero.
1883 If \fIoffset\fP evaluates to a number less than zero, the value
1884 is used as an offset from the end of the value of \fIparameter\fP.
1885 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
1886 parameters beginning at \fIoffset\fP.
1887 If \fIparameter\fP is an array name indexed by @ or *,
1888 the result is the \fIlength\fP
1889 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
1890 Substring indexing is zero-based unless the positional parameters are
1891 used, in which case the indexing starts at 1.
1893 ${\fB#\fP\fIparameter\fP}
1894 The length in characters of the value of \fIparameter\fP is substituted.
1901 the length substituted is the number of positional parameters.
1904 is an array name subscripted by
1908 the length substituted is the number of elements in the array.
1911 ${\fIparameter\fP\fB#\fP\fIword\fP}
1913 ${\fIparameter\fP\fB##\fP\fIword\fP}
1917 is expanded to produce a pattern just as in pathname
1918 expansion. If the pattern matches the beginning of
1921 then the expansion is the value of
1923 with the shortest matching pattern (the ``\fB#\fP'' case) or the
1924 longest matching pattern (the ``\fB##\fP'' case) deleted.
1931 the pattern removal operation is applied to each positional
1932 parameter in turn, and the expansion is the resultant list.
1935 is an array variable subscripted with
1939 the pattern removal operation is applied to each member of the
1940 array in turn, and the expansion is the resultant list.
1943 ${\fIparameter\fP\fB%\fP\fIword\fP}
1945 ${\fIparameter\fP\fB%%\fP\fIword\fP}
1947 The \fIword\fP is expanded to produce a pattern just as in
1949 If the pattern matches a trailing portion of the value of
1951 then the expansion is the value of
1953 with the shortest matching pattern (the ``\fB%\fP'' case) or the
1954 longest matching pattern (the ``\fB%%\fP'' case) deleted.
1961 the pattern removal operation is applied to each positional
1962 parameter in turn, and the expansion is the resultant list.
1965 is an array variable subscripted with
1969 the pattern removal operation is applied to each member of the
1970 array in turn, and the expansion is the resultant list.
1973 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
1975 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
1977 The \fIpattern\fP is expanded to produce a pattern just as in
1979 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
1980 against its value is replaced with \fIstring\fP.
1981 In the first form, only the first match is replaced.
1982 The second form causes all matches of \fIpattern\fP to be
1983 replaced with \fIstring\fP.
1984 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
1986 If \fIpattern\fP begins with \fB%\fP, it must match at the end
1988 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
1989 and the \fB/\fP following \fIpattern\fP may be omitted.
1996 the substitution operation is applied to each positional
1997 parameter in turn, and the expansion is the resultant list.
2000 is an array variable subscripted with
2004 the substitution operation is applied to each member of the
2005 array in turn, and the expansion is the resultant list.
2006 .SS Command Substitution
2008 \fICommand substitution\fP allows the output of a command to replace
2009 the command name. There are two forms:
2013 \fB$(\fP\fIcommand\fP\|\fB)\fP
2017 \fB`\fP\fIcommand\fP\fB`\fP
2021 performs the expansion by executing \fIcommand\fP and
2022 replacing the command substitution with the standard output of the
2023 command, with any trailing newlines deleted.
2025 When the old-style backquote form of substitution is used,
2026 backslash retains its literal meaning except when followed by
2031 When using the $(\^\fIcommand\fP\|) form, all characters between the
2032 parentheses make up the command; none are treated specially.
2034 Command substitutions may be nested. To nest when using the old form,
2035 escape the inner backquotes with backslashes.
2037 If the substitution appears within double quotes, word splitting and
2038 pathname expansion are not performed on the results.
2039 .SS Arithmetic Expansion
2041 Arithmetic expansion allows the evaluation of an arithmetic expression
2042 and the substitution of the result. The format for arithmetic expansion is:
2045 \fB$((\fP\fIexpression\fP\fB))\fP
2050 is treated as if it were within double quotes, but a double quote
2051 inside the parentheses is not treated specially.
2052 All tokens in the expression undergo parameter expansion, string
2053 expansion, command substitution, and quote removal.
2054 Arithmetic substitutions may be nested.
2056 The evaluation is performed according to the rules listed below under
2058 .BR "ARITHMETIC EVALUATION" .
2063 prints a message indicating failure and no substitution occurs.
2064 .SS Process Substitution
2066 \fIProcess substitution\fP is supported on systems that support named
2067 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2068 It takes the form of
2069 \fB<(\fP\fIlist\^\fP\fB)\fP
2071 \fB>(\fP\fIlist\^\fP\fB)\fP.
2072 The process \fIlist\fP is run with its input or output connected to a
2073 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2074 passed as an argument to the current command as the result of the
2075 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2076 the file will provide input for \fIlist\fP. If the
2077 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2078 argument should be read to obtain the output of \fIlist\fP.
2080 On systems that support it, \fIprocess substitution\fP is performed
2081 simultaneously with parameter and variable expansion,
2082 command substitution,
2083 and arithmetic expansion.
2086 The shell scans the results of
2087 parameter expansion,
2088 command substitution,
2090 arithmetic expansion
2091 that did not occur within double quotes for
2092 .IR "word splitting" .
2094 The shell treats each character of
2097 as a delimiter, and splits the results of the other
2098 expansions into words on these characters. If
2103 .BR <space><tab><newline> ,
2108 characters serves to delimit words. If
2111 has a value other than the default, then sequences of
2112 the whitespace characters
2116 are ignored at the beginning and end of the
2117 word, as long as the whitespace character is in the
2124 whitespace character).
2131 whitespace, along with any adjacent
2134 whitespace characters, delimits a field.
2138 whitespace characters is also treated as a delimiter.
2142 is null, no word splitting occurs.
2144 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2145 Unquoted implicit null arguments, resulting from the expansion of
2147 that have no values, are removed.
2148 If a parameter with no value is expanded within double quotes, a
2149 null argument results and is retained.
2151 Note that if no expansion occurs, no splitting
2153 .SS Pathname Expansion
2155 After word splitting,
2158 option has been set,
2160 scans each word for the characters
2165 If one of these characters appears, then the word is
2168 and replaced with an alphabetically sorted list of
2169 file names matching the pattern.
2170 If no matching file names are found,
2171 and the shell option
2173 is disabled, the word is left unchanged.
2174 If the option is set, and no matches are found,
2175 the word is removed.
2176 When a pattern is used for pathname expansion,
2179 at the start of a name or immediately following a slash
2180 must be matched explicitly, unless the shell option
2183 The slash character must always be matched explicitly.
2186 character is not treated specially.
2187 See the description of
2191 .B SHELL BUILTIN COMMANDS
2192 for a description of the
2201 shell variable may be used to restrict the set of file names matching a
2206 is set, each matching file name that also matches one of the patterns in
2209 is removed from the list of matches.
2214 are always ignored, even when
2217 is set. However, setting
2220 has the effect of enabling the
2222 shell option, so all other file names beginning with a
2225 To get the old behavior of ignoring file names beginning with a
2229 one of the patterns in
2234 option is disabled when
2239 The special pattern characters have the following meanings:
2244 Matches any string, including the null string.
2247 Matches any single character.
2250 Matches any one of the enclosed characters. A pair of characters
2251 separated by a minus sign denotes a
2253 any character lexically between those two characters, inclusive,
2254 is matched. If the first character following the
2260 then any character not enclosed is matched.
2263 may be matched by including it as the first or last character
2267 may be matched by including it as the first character
2272 After the preceding expansions, all unquoted occurrences of the
2276 and \^\f3"\fP\^ that did not result from one of the above
2277 expansions are removed.
2279 Before a command is executed, its input and output
2282 using a special notation interpreted by the shell.
2283 Redirection may also be used to open and close files for the
2284 current shell execution environment. The following redirection
2285 operators may precede or appear anywhere within a
2289 Redirections are processed in the order they appear, from
2292 In the following descriptions, if the file descriptor number is
2293 omitted, and the first character of the redirection operator is
2295 the redirection refers to the standard input (file descriptor
2296 0). If the first character of the redirection operator is
2298 the redirection refers to the standard output (file descriptor
2301 The word that follows the redirection operator in the following
2302 descriptions is subjected to brace expansion, tilde expansion,
2303 parameter expansion, command substitution, arithmetic expansion,
2304 quote removal, and pathname expansion. If it expands to more
2309 Note that the order of redirections is significant. For example,
2313 ls \fB>\fP dirlist 2\fB>&\fP1
2316 directs both standard output and standard error to the file
2321 ls 2\fB>&\fP1 \fB>\fP dirlist
2324 directs only the standard output to file
2326 because the standard error was duplicated as standard output
2327 before the standard output was redirected to
2329 .SS Redirecting Input
2331 Redirection of input causes the file whose name results from
2334 to be opened for reading on file descriptor
2336 or the standard input (file descriptor 0) if
2340 The general format for redirecting input is:
2343 [\fIn\fP]\fB<\fP\fIword\fP
2345 .SS Redirecting Output
2347 Redirection of output causes the file whose name results from
2350 to be opened for writing on file descriptor
2352 or the standard output (file descriptor 1) if
2354 is not specified. If the file does not exist it is created;
2355 if it does exist it is truncated to zero size.
2357 The general format for redirecting output is:
2360 [\fIn\fP]\fB>\fP\fIword\fP
2363 If the redirection operator is
2369 builtin has been enabled, the redirection will fail if the filename
2370 whose name results from the expansion of \fIword\fP exists.
2371 If the redirection operator is
2373 then the value of the
2377 builtin command is not tested, and the redirection is attempted even
2378 if the file named by \fIword\fP exists.
2379 .SS Appending Redirected Output
2381 Redirection of output in this fashion
2382 causes the file whose name results from
2385 to be opened for appending on file descriptor
2387 or the standard output (file descriptor 1) if
2389 is not specified. If the file does not exist it is created.
2391 The general format for appending output is:
2394 [\fIn\fP]\fB>>\fP\fIword\fP
2397 .SS Redirecting Standard Output and Standard Error
2401 standard output (file descriptor 1) and
2402 the standard error output (file descriptor 2)
2403 to be redirected to the file whose name is the
2406 with this construct.
2408 There are two formats for redirecting standard output and
2419 Of the two forms, the first is preferred.
2420 This is semantically equivalent to
2423 \fB>\fP\fIword\fP 2\fB>&\fP1
2427 This type of redirection instructs the shell to read input from the
2428 current source until a line containing only
2430 (with no trailing blanks)
2432 the lines read up to that point are then used as the standard
2433 input for a command.
2435 The format of here-documents is as follows:
2439 \fB<<\fP[\fB\-\fP]\fIword\fP
2440 \fIhere\-document\fP
2445 No parameter expansion, command substitution, pathname
2446 expansion, or arithmetic expansion is performed on
2448 If any characters in
2452 is the result of quote removal on
2454 and the lines in the here-document are not expanded. Otherwise,
2455 all lines of the here-document are subjected to parameter expansion,
2456 command substitution, and arithmetic expansion. In the latter
2461 must be used to quote the characters
2467 If the redirection operator is
2469 then all leading tab characters are stripped from input lines and the
2473 here-documents within shell scripts to be indented in a
2475 .SS "Duplicating File Descriptors"
2477 The redirection operator
2480 [\fIn\fP]\fB<&\fP\fIword\fP
2483 is used to duplicate input file descriptors.
2486 expands to one or more digits, the file descriptor denoted by
2488 is made to be a copy of that file descriptor. If
2496 is not specified, the standard input (file descriptor 0) is used.
2501 [\fIn\fP]\fB>&\fP\fIword\fP
2504 is used similarly to duplicate output file descriptors. If
2506 is not specified, the standard output (file descriptor 1) is used.
2507 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
2508 expand to one or more digits, the standard output and standard
2509 error are redirected as described previously.
2510 .SS "Opening File Descriptors for Reading and Writing"
2512 The redirection operator
2515 [\fIn\fP]\fB<>\fP\fIword\fP
2518 causes the file whose name is the expansion of
2520 to be opened for both reading and writing on file descriptor
2522 or on file descriptor 0 if
2524 is not specified. If the file does not exist, it is created.
2526 The shell maintains a list of
2528 that may be set and unset with the
2532 builtin commands (see
2534 .B SHELL BUILTIN COMMANDS
2536 The first word of each command, if unquoted,
2537 is checked to see if it has an
2538 alias. If so, that word is replaced by the text of the alias.
2539 The alias name and the replacement text may contain any valid
2540 shell input, including the
2542 listed above, with the exception that the alias name may not
2543 contain \fI=\fP. The first word of the replacement text is tested
2544 for aliases, but a word that is identical to an alias being expanded
2545 is not expanded a second time. This means that one may alias
2551 does not try to recursively expand the replacement text.
2552 If the last character of the alias value is a
2554 then the next command
2555 word following the alias is also checked for alias expansion.
2557 Aliases are created and listed with the
2559 command, and removed with the
2563 There is no mechanism for using arguments in the replacement text.
2564 If arguments are needed, a shell function should be used.
2566 Aliases are not expanded when the shell is not interactive, unless
2569 shell option is set using
2571 (see the description of
2575 \fBSHELL BUILTIN COMMANDS\fP
2578 The rules concerning the definition and use of aliases are
2581 always reads at least one complete line
2582 of input before executing any
2583 of the commands on that line. Aliases are expanded when a
2584 command is read, not when it is executed. Therefore, an
2585 alias definition appearing on the same line as another
2586 command does not take effect until the next line of input is read.
2587 The commands following the alias definition
2588 on that line are not affected by the new alias.
2589 This behavior is also an issue when functions are executed.
2590 Aliases are expanded when the function definition is read,
2591 not when the function is executed, because a function definition
2592 is itself a compound command. As a consequence, aliases
2593 defined in a function are not available until after that
2594 function is executed. To be safe, always put
2595 alias definitions on a separate line, and do not use
2597 in compound commands.
2599 Note that for almost every purpose, aliases are superseded by
2602 A shell function, defined as described above under
2604 .BR "SHELL GRAMMAR" ,
2605 stores a series of commands for later execution.
2606 Functions are executed in the context of the
2607 current shell; no new process is created to interpret
2608 them (contrast this with the execution of a shell script).
2609 When a function is executed, the arguments to the
2610 function become the positional parameters
2611 during its execution. The special parameter
2613 is updated to reflect the change. Positional parameter 0
2614 is unchanged. All other aspects of the shell execution
2615 environment are identical between a function and its caller
2616 with the exception that the
2619 trap (see the description of the
2623 .B SHELL BUILTIN COMMANDS
2624 below) is not inherited.
2626 Variables local to the function may be declared with the
2628 builtin command. Ordinarily, variables and their values
2629 are shared between the function and its caller.
2631 If the builtin command
2633 is executed in a function, the function completes and
2634 execution resumes with the next command after the function
2635 call. When a function completes, the values of the
2636 positional parameters and the special parameter
2638 are restored to the values they had prior to function
2641 Function names and definitions may be listed with the
2647 builtin commands. The
2653 will list the function names only.
2654 Functions may be exported so that subshells
2655 automatically have them defined with the
2661 Functions may be recursive. No limit is imposed on the number
2663 .SH "COMMAND EXECUTION"
2664 After a command has been split into words, if it results in a
2665 simple command and an optional list of arguments, the following
2668 If the command name contains no slashes, the shell attempts to
2669 locate it. If there exists a shell function by that name, that
2670 function is invoked as described above in
2673 If the name does not match a function, the shell searches for
2674 it in the list of shell builtins. If a match is found, that
2677 If the name is neither a shell function nor a builtin,
2678 and contains no slashes,
2680 searches each element of the
2683 for a directory containing an executable file by that name.
2685 uses a hash table to remember the full file names of executable
2690 .B "SHELL BUILTIN COMMANDS"
2692 A full search of the directories in
2695 is performed only if the command is not found in the hash table.
2696 If the search is unsuccessful, the shell prints an error
2697 message and returns a non-zero exit status.
2699 If the search is successful, or if the command name contains
2700 one or more slashes, the shell executes the named program.
2701 Argument 0 is set to the name given, and the remaining arguments
2702 to the command are set to the arguments given, if any.
2704 If this execution fails because the file is not in executable
2705 format, and the file is not a directory, it is assumed to be
2706 a \fIshell script\fP, a file
2707 containing shell commands. A subshell is spawned to execute
2708 it. This subshell reinitializes itself, so
2709 that the effect is as if a new shell had been invoked
2710 to handle the script, with the exception that the locations of
2711 commands remembered by the parent (see
2715 \fBSHELL BUILTIN COMMANDS\fP)
2716 are retained by the child.
2718 If the program is a file beginning with
2720 the remainder of the first line specifies an interpreter
2721 for the program. The shell executes the
2722 specified interpreter on operating systems that do not
2723 handle this executable format themselves. The arguments to the
2724 interpreter consist of a single optional argument following the
2725 interpreter name on the first line of the program, followed
2726 by the name of the program, followed by the command
2729 When a program is invoked it is given an array of strings
2733 \fIname\fP\-\fIvalue\fP pairs, of the form
2734 .IR "name\fR=\fPvalue" .
2736 The shell allows you to manipulate the environment in several
2737 ways. On invocation, the shell scans its own environment and
2738 creates a parameter for each name found, automatically marking
2741 to child processes. Executed commands inherit the environment.
2746 commands allow parameters and functions to be added to and
2747 deleted from the environment. If the value of a parameter
2748 in the environment is modified, the new value becomes part
2749 of the environment, replacing the old. The environment
2750 inherited by any executed command consists of the shell's
2751 initial environment, whose values may be modified in the shell,
2752 less any pairs removed by the
2754 command, plus any additions via the
2760 The environment for any
2762 or function may be augmented temporarily by prefixing it with
2763 parameter assignments, as described above in
2766 These assignment statements affect only the environment seen
2771 flag is set (see the
2773 builtin command below), then
2775 parameter assignments are placed in the environment for a command,
2776 not just those that precede the command name.
2780 invokes an external command, the variable
2782 is set to the full file name of the command and passed to that
2783 command in its environment.
2785 For the purposes of the shell, a command which exits with a
2786 zero exit status has succeeded. An exit status of zero
2787 indicates success. A non-zero exit status indicates failure.
2788 When a command terminates on a fatal signal, \fBbash\fP uses
2789 the value of 128+\fBsignal\fP as the exit status.
2791 If a command is not found, the child process created to
2792 execute it returns a status of 127. If a command is found
2793 but is not executable, the return status is 126.
2795 Shell builtin commands return a status of 0 (\fItrue\fP) if
2796 successful, and non-zero (\fIfalse\fP) if an error occurs
2798 All builtins return an exit status of 2 to indicate incorrect usage.
2800 \fBBash\fP itself returns the exit status of the last command
2801 executed, unless a syntax error occurs, in which case it exits
2802 with a non-zero value. See also the \fBexit\fP builtin
2805 When \fBbash\fP is interactive, it ignores
2808 (so that \fBkill 0\fP does not kill an interactive shell),
2812 is caught and handled (so that the \fBwait\fP builtin is interruptible).
2813 In all cases, \fBbash\fP ignores
2816 If job control is in effect,
2827 Synchronous jobs started by \fBbash\fP have signals set to the
2828 values inherited by the shell from its parent. When job control
2829 is not in effect, background jobs (jobs started with
2837 Commands run as a result of command substitution ignore the
2838 keyboard-generated job control signals
2847 The shell exits by default upon receipt of a
2850 Before exiting, it resends the
2853 to all jobs, running or stopped. To prevent the shell from
2854 sending the signal to a particular job, remove it from the
2859 .B "SHELL BUILTIN COMMANDS"
2862 to mark it to not receive
2867 refers to the ability to selectively stop (\fIsuspend\fP)
2868 the execution of processes and continue (\fIresume\fP)
2869 their execution at a later point. A user typically employs
2870 this facility via an interactive interface supplied jointly
2871 by the system's terminal driver and
2874 The shell associates a
2876 with each pipeline. It keeps a table of currently executing
2877 jobs, which may be listed with the
2881 starts a job asynchronously (in the
2883 it prints a line that looks like:
2889 indicating that this job is job number 1 and that the process ID
2890 of the last process in the pipeline associated with this job is 25647.
2891 All of the processes in a single pipeline are members of the same job.
2895 abstraction as the basis for job control.
2897 To facilitate the implementation of the user interface to job
2898 control, the system maintains the notion of a \fIcurrent terminal
2899 process group ID\fP. Members of this process group (processes whose
2900 process group ID is equal to the current terminal process group ID)
2901 receive keyboard-generated signals such as
2904 These processes are said to be in the
2907 processes are those whose process group ID differs from the terminal's;
2908 such processes are immune to keyboard-generated signals.
2909 Only foreground processes are allowed to read from or write to the
2910 terminal. Background processes which attempt to read from (write to) the
2913 .B SIGTTIN (SIGTTOU)
2914 signal by the terminal driver,
2915 which, unless caught, suspends the process.
2917 If the operating system on which
2922 allows you to use it.
2925 character (typically
2927 Control-Z) while a process is running
2928 causes that process to be stopped and returns you to
2931 .I "delayed suspend"
2932 character (typically
2934 Control-Y) causes the process to be stopped when it
2935 attempts to read input from the terminal, and control to
2938 You may then manipulate the state of this job, using the
2940 command to continue it in the background, the
2942 command to continue it in the foreground, or
2945 command to kill it. A \fB^Z\fP takes effect immediately,
2946 and has the additional side effect of causing pending output
2947 and typeahead to be discarded.
2949 There are a number of ways to refer to a job in the shell.
2952 introduces a job name. Job number
2954 may be referred to as
2956 A job may also be referred to using a prefix of the name used to
2957 start it, or using a substring that appears in its command line.
2962 job. If a prefix matches more than one job,
2964 reports an error. Using
2966 on the other hand, refers to any job containing the string
2968 in its command line. If the substring matches more than one job,
2970 reports an error. The symbols
2974 refer to the shell's notion of the
2976 which is the last job stopped while it was in
2980 may be referenced using
2982 In output pertaining to jobs (e.g., the output of the
2984 command), the current job is always flagged with a
2986 and the previous job with a
2989 Simply naming a job can be used to bring it into the
2994 bringing job 1 from the background into the foreground.
2997 resumes job 1 in the background, equivalent to
3000 The shell learns immediately whenever a job changes state.
3003 waits until it is about to print a prompt before reporting
3004 changes in a job's status so as to not interrupt
3005 any other output. If the
3012 reports such changes immediately.
3014 If an attempt to exit
3016 is made while jobs are stopped, the shell prints a warning message. The
3018 command may then be used to inspect their status.
3019 If a second attempt to exit is made without an intervening command,
3020 the shell does not print another warning, and the stopped
3021 jobs are terminated.
3023 When executing interactively,
3025 displays the primary prompt
3028 when it is ready to read a command, and the secondary prompt
3031 when it needs more input to complete a command.
3033 allows these prompt strings to be customized by inserting a number of
3034 backslash-escaped special characters that are decoded as follows:
3039 an ASCII bell character (07)
3042 the date in "Weekday Month Date" format (e.g., "Tue May 26")
3045 an ASCII escape character (033)
3048 the hostname up to the first `.'
3057 the name of the shell, the basename of
3059 (the portion following the final slash)
3062 the current time in 24-hour HH:MM:SS format
3065 the current time in 12-hour HH:MM:SS format
3068 the current time in 12-hour am/pm format
3071 the username of the current user
3074 the version of \fBbash\fP (e.g., 2.00)
3077 the release of \fBbash\fP, version + patchlevel (e.g., 2.00.0)
3080 the current working directory
3083 the basename of the current working directory
3086 the history number of this command
3089 the command number of this command
3092 if the effective UID is 0, a
3098 the character corresponding to the octal number \fInnn\fP
3104 begin a sequence of non-printing characters, which could be used to
3105 embed a terminal control sequence into the prompt
3108 end a sequence of non-printing characters
3112 The command number and the history number are usually different:
3113 the history number of a command is its position in the history
3114 list, which may include commands restored from the history file
3118 below), while the command number is the position in the sequence
3119 of commands executed during the current shell session.
3120 After the string is decoded, it is expanded via
3121 parameter expansion, command substitution, arithmetic expansion,
3122 string expansion, and quote removal, subject to the value of the
3124 shell option (see the description of the
3128 .B "SHELL BUILTIN COMMANDS"
3131 This is the library that handles reading input when using an interactive
3134 option is given at shell invocation.
3135 By default, the line editing commands are similar to those of emacs.
3136 A vi-style line editing interface is also available.
3137 To turn off line editing after the shell is running, use the
3145 .B SHELL BUILTIN COMMANDS
3147 .SS "Readline Notation"
3149 In this section, the emacs-style notation is used to denote
3150 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
3151 means Control\-N. Similarly,
3153 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
3156 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
3159 key. This makes ESC the \fImeta prefix\fP.
3160 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
3161 or press the Escape key
3162 then hold the Control key while pressing the
3166 Readline commands may be given numeric
3168 which normally act as a repeat count.
3169 Sometimes, however, it is the sign of the argument that is significant.
3170 Passing a negative argument to a command that acts in the forward
3171 direction (e.g., \fBkill\-line\fP) causes that command to act in a
3173 Commands whose behavior with arguments deviates from this are noted
3176 When a command is described as \fIkilling\fP text, the text
3177 deleted is saved for possible future retrieval
3178 (\fIyanking\fP). The killed text is saved in a
3179 \fIkill ring\fP. Consecutive kills cause the text to be
3180 accumulated into one unit, which can be yanked all at once.
3181 Commands which do not kill text separate the chunks of text
3183 .SS "Readline Initialization"
3185 Readline is customized by putting commands in an initialization
3186 file (the \fIinputrc\fP file).
3187 The name of this file is taken from the value of the
3190 variable. If that variable is unset, the default is
3192 When a program which uses the readline library starts up, the
3193 initialization file is read, and the key bindings and variables
3195 There are only a few basic constructs allowed in the
3196 readline initialization file.
3197 Blank lines are ignored.
3198 Lines beginning with a \fB#\fP are comments.
3199 Lines beginning with a \fB$\fP indicate conditional constructs.
3200 Other lines denote key bindings and variable settings.
3202 The default key-bindings may be changed with an
3205 Other programs that use this library may add their own commands
3208 For example, placing
3211 M\-Control\-u: universal\-argument
3215 C\-Meta\-u: universal\-argument
3219 would make M\-C\-u execute the readline command
3220 .IR universal\-argument .
3222 The following symbolic character names are recognized:
3234 In addition to command names, readline allows keys to be bound
3235 to a string that is inserted when the key is pressed (a \fImacro\fP).
3236 .SS "Readline Key Bindings"
3238 The syntax for controlling key bindings in the
3240 file is simple. All that is required is the name of the
3241 command or the text of a macro and a key sequence to which
3242 it should be bound. The name may be specified in one of two ways:
3243 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
3244 prefixes, or as a key sequence.
3245 When using the form \fBkeyname\fP:\fIfunction\-name\fP or \fImacro\fP,
3247 is the name of a key spelled out in English. For example:
3250 Control-u: universal\-argument
3252 Meta-Rubout: backward-kill-word
3254 Control-o: "> output"
3257 In the above example,
3259 is bound to the function
3260 .BR universal\-argument ,
3262 is bound to the function
3263 .BR backward\-kill\-word ,
3266 is bound to run the macro
3267 expressed on the right hand side (that is, to insert the text
3271 In the second form, \fB"keyseq"\fP:\fIfunction\-name\fP or \fImacro\fP,
3275 above in that strings denoting
3276 an entire key sequence may be specified by placing the sequence
3277 within double quotes. Some GNU Emacs style key escapes can be
3278 used, as in the following example.
3281 "\eC\-u": universal\-argument
3283 "\eC\-x\eC\-r": re\-read\-init\-file
3285 "\ee[11~": "Function Key 1"
3290 is again bound to the function
3291 .BR universal\-argument .
3293 is bound to the function
3294 .BR re\-read\-init\-file ,
3297 is bound to insert the text
3298 .BR "Function Key 1" .
3299 The full set of escape sequences is
3321 When entering the text of a macro, single or double quotes should
3322 be used to indicate a macro definition. Unquoted text
3323 is assumed to be a function name. Backslash
3324 will quote any character in the macro text, including " and '.
3327 allows the current readline key bindings to be displayed or modified
3330 builtin command. The editing mode may be switched during interactive
3335 builtin command (see
3337 .B SHELL BUILTIN COMMANDS
3339 .SS "Readline Variables"
3341 Readline has variables that can be used to further customize its
3342 behavior. A variable may be set in the
3344 file with a statement of the form
3347 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
3350 Except where noted, readline variables can take the values
3354 The variables and their default values are:
3358 .B bell\-style (audible)
3359 Controls what happens when readline wants to ring the terminal bell.
3360 If set to \fBnone\fP, readline never rings the bell. If set to
3361 \fBvisible\fP, readline uses a visible bell if one is available.
3362 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
3364 .B comment\-begin (``#'')
3365 The string that is inserted when the
3368 command is executed.
3369 This command is bound to
3371 in emacs mode and to
3375 .B completion\-query\-items (100)
3376 This determines when the user is queried about viewing
3377 the number of possible completions
3378 generated by the \fBpossible\-completions\fP command.
3379 It may be set to any integer value greater than or equal to
3380 zero. If the number of possible completions is greater than
3381 or equal to the value of this variable, the user is asked whether
3382 or not he wishes to view them; otherwise they are simply listed
3385 .B convert\-meta (On)
3386 If set to \fBOn\fP, readline will convert characters with the
3387 eighth bit set to an ASCII key sequence
3388 by stripping the eighth bit and prepending an
3389 escape character (in effect, using escape as the \fImeta prefix\fP).
3391 .B disable\-completion (Off)
3392 If set to \fBOn\fP, readline will inhibit word completion. Completion
3393 characters will be inserted into the line as if they had been
3394 mapped to \fBself-insert\fP.
3396 .B editing\-mode (emacs)
3397 Controls whether readline begins with a set of key bindings similar
3398 to \fIemacs\fP or \fIvi\fP.
3400 can be set to either
3405 .B enable\-keypad (Off)
3406 When set to \fBOn\fP, readline will try to enable the application
3407 keypad when it is called. Some systems need this to enable the
3410 .B expand\-tilde (Off)
3411 If set to \fBon\fP, tilde expansion is performed when readline
3412 attempts word completion.
3414 .B horizontal\-scroll\-mode (Off)
3415 When set to \fBOn\fP, makes readline use a single line for display,
3416 scrolling the input horizontally on a single screen line when it
3417 becomes longer than the screen width rather than wrapping to a new line.
3419 .B input\-meta (Off)
3420 If set to \fBOn\fP, readline will enable eight-bit input (that is,
3421 it will not strip the high bit from the characters it reads),
3422 regardless of what the terminal claims it can support. The name
3424 is a synonym for this variable.
3427 Set the current readline keymap. The set of legal keymap names is
3428 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
3431 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
3432 equivalent to \fIemacs\-standard\fP. The default value is
3436 also affects the default keymap.
3438 .B mark\-directories (On)
3439 If set to \fBOn\fP, completed directory names have a slash
3442 .B mark\-modified\-lines (Off)
3443 If set to \fBOn\fP, history lines that have been modified are displayed
3444 with a preceding asterisk (\fB*\fP).
3446 .B output\-meta (Off)
3447 If set to \fBOn\fP, readline will display characters with the
3448 eighth bit set directly rather than as a meta-prefixed escape
3451 .B show\-all\-if\-ambiguous (Off)
3452 This alters the default behavior of the completion functions. If
3455 words which have more than one possible completion cause the
3456 matches to be listed immediately instead of ringing the bell.
3458 .B visible\-stats (Off)
3459 If set to \fBOn\fP, a character denoting a file's type as reported
3460 by \fIstat\fP(2) is appended to the filename when listing possible
3463 .SS "Readline Conditional Constructs"
3465 Readline implements a facility similar in spirit to the conditional
3466 compilation features of the C preprocessor which allows key
3467 bindings and variable settings to be performed as the result
3468 of tests. There are three parser directives used.
3472 construct allows bindings to be made based on the
3473 editing mode, the terminal being used, or the application using
3474 readline. The text of the test extends to the end of the line;
3475 no characters are required to isolate it.
3478 The \fBmode=\fP form of the \fB$if\fP directive is used to test
3479 whether readline is in emacs or vi mode.
3480 This may be used in conjunction
3481 with the \fBset keymap\fP command, for instance, to set bindings in
3482 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
3483 readline is starting out in emacs mode.
3485 The \fBterm=\fP form may be used to include terminal-specific
3486 key bindings, perhaps to bind the key sequences output by the
3487 terminal's function keys. The word on the right side of the
3489 is tested against the full name of the terminal and the portion
3490 of the terminal name before the first \fB\-\fP. This allows
3497 .IP \fBapplication\fP
3498 The \fBapplication\fP construct is used to include
3499 application-specific settings. Each program using the readline
3500 library sets the \fIapplication name\fP, and an initialization
3501 file can test for a particular value.
3502 This could be used to bind key sequences to functions useful for
3503 a specific program. For instance, the following command adds a
3504 key sequence that quotes the current or previous word in Bash:
3508 # Quote the current or previous word
3509 "\eC\-xq": "\eeb\e"\eef\e""
3515 This command, as you saw in the previous example, terminates an
3518 Commands in this branch of the \fB$if\fP directive are executed if
3522 Readline provides commands for searching through the command history
3526 below) for lines containing a specified string.
3527 There are two search modes:
3530 .IR non-incremental .
3532 Incremental searches begin before the user has finished typing the
3534 As each character of the search string is typed, readline displays
3535 the next entry from the history matching the string typed so far.
3536 An incremental search requires only as many characters as needed to
3537 find the desired history entry.
3538 The Escape character is used to terminate an incremental search.
3539 Control-J will also terminate the search.
3540 Control-G will abort an incremental search and restore the original
3542 When the search is terminated, the history entry containing the
3543 search string becomes the current line.
3544 To find other matching entries in the history list, type Control-S or
3545 Control-R as appropriate.
3546 This will search backward or forward in the history for the next
3547 entry matching the search string typed so far.
3548 Any other key sequence bound to a readline command will terminate
3549 the search and execute that command.
3550 For instance, a \fInewline\fP will terminate the search and accept
3551 the line, thereby executing the command from the history list.
3553 Non-incremental searches read the entire search string before starting
3554 to search for matching history lines. The search string may be
3555 typed by the user or part of the contents of the current line.
3556 .SS "Readline Command Names"
3558 The following is a list of the names of the commands and the default
3559 key sequences to which they are bound.
3560 Command names without an accompanying key sequence are unbound by default.
3561 .SS Commands for Moving
3565 .B beginning\-of\-line (C\-a)
3566 Move to the start of the current line.
3568 .B end\-of\-line (C\-e)
3569 Move to the end of the line.
3571 .B forward\-char (C\-f)
3572 Move forward a character.
3574 .B backward\-char (C\-b)
3575 Move back a character.
3577 .B forward\-word (M\-f)
3578 Move forward to the end of the next word. Words are composed of
3579 alphanumeric characters (letters and digits).
3581 .B backward\-word (M\-b)
3582 Move back to the start of this, or the previous, word. Words are
3583 composed of alphanumeric characters (letters and digits).
3585 .B clear\-screen (C\-l)
3586 Clear the screen leaving the current line at the top of the screen.
3587 With an argument, refresh the current line without clearing the
3590 .B redraw\-current\-line
3591 Refresh the current line.
3593 .SS Commands for Manipulating the History
3597 .B accept\-line (Newline, Return)
3598 Accept the line regardless of where the cursor is. If this line is
3599 non-empty, add it to the history list according to the state of the
3602 variable. If the line is a modified history
3603 line, then restore the history line to its original state.
3605 .B previous\-history (C\-p)
3606 Fetch the previous command from the history list, moving back in
3609 .B next\-history (C\-n)
3610 Fetch the next command from the history list, moving forward in the
3613 .B beginning\-of\-history (M\-<)
3614 Move to the first line in the history.
3616 .B end\-of\-history (M\->)
3617 Move to the end of the input history, i.e., the line currently being
3620 .B reverse\-search\-history (C\-r)
3621 Search backward starting at the current line and moving `up' through
3622 the history as necessary. This is an incremental search.
3624 .B forward\-search\-history (C\-s)
3625 Search forward starting at the current line and moving `down' through
3626 the history as necessary. This is an incremental search.
3628 .B non\-incremental\-reverse\-search\-history (M\-p)
3629 Search backward through the history starting at the current line
3630 using a non-incremental search for a string supplied by the user.
3632 .B non\-incremental\-forward\-search\-history (M\-n)
3633 Search forward through the history using a non-incremental search for
3634 a string supplied by the user.
3636 .B history\-search\-forward
3637 Search forward through the history for the string of characters
3638 between the start of the current line and the current cursor
3639 position (the \fIpoint\fP).
3640 This is a non-incremental search.
3642 .B history\-search\-backward
3643 Search backward through the history for the string of characters
3644 between the start of the current line and the point.
3645 This is a non-incremental search.
3647 .B yank\-nth\-arg (M\-C\-y)
3648 Insert the first argument to the previous command (usually
3649 the second word on the previous line) at point (the current
3650 cursor position). With an argument
3652 insert the \fIn\fPth word from the previous command (the words
3653 in the previous command begin with word 0). A negative argument
3654 inserts the \fIn\fPth word from the end of the previous command.
3657 yank\-last\-arg (M\-.\^, M\-_\^)
3658 Insert the last argument to the previous command (the last word of
3659 the previous history entry). With an argument,
3660 behave exactly like \fByank\-nth\-arg\fP.
3662 .B shell\-expand\-line (M\-C\-e)
3663 Expand the line the way the shell does when it reads it. This
3664 performs alias and history expansion as well as all of the shell
3665 word expansions. See
3667 .B HISTORY EXPANSION
3668 below for a description of history expansion.
3670 .B history\-expand\-line (M\-^)
3671 Perform history expansion on the current line. See
3673 .B HISTORY EXPANSION
3674 below for a description of history expansion.
3676 .B insert\-last\-argument (M\-.\^, M\-_\^)
3677 A synonym for \fByank\-last\-arg\fP.
3679 .B operate\-and\-get\-next (C\-o)
3680 Accept the current line for execution and fetch the next line
3681 relative to the current line from the history for editing. Any
3682 argument is ignored.
3684 .SS Commands for Changing Text
3688 .B delete\-char (C\-d)
3689 Delete the character under the cursor. If point is at the
3690 beginning of the line, there are no characters in the line, and
3691 the last character typed was not
3697 .B backward\-delete\-char (Rubout)
3698 Delete the character behind the cursor. When given a numeric argument,
3699 save the deleted text on the kill ring.
3701 .B quoted\-insert (C\-q, C\-v)
3702 Add the next character that you type to the line verbatim. This is
3703 how to insert characters like \fBC\-q\fP, for example.
3705 .B tab\-insert (C\-v TAB)
3706 Insert a tab character.
3708 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
3709 Insert the character typed.
3711 .B transpose\-chars (C\-t)
3712 Drag the character before point forward over the character at point.
3713 Point moves forward as well. If point is at the end of the line, then
3714 transpose the two characters before point. Negative arguments don't work.
3716 .B transpose\-words (M\-t)
3717 Drag the word behind the cursor past the word in front of the cursor
3718 moving the cursor over that word as well.
3720 .B upcase\-word (M\-u)
3721 Uppercase the current (or following) word. With a negative argument,
3722 do the previous word, but do not move point.
3724 .B downcase\-word (M\-l)
3725 Lowercase the current (or following) word. With a negative argument,
3726 do the previous word, but do not move point.
3728 .B capitalize\-word (M\-c)
3729 Capitalize the current (or following) word. With a negative argument,
3730 do the previous word, but do not move point.
3732 .SS Killing and Yanking
3736 .B kill\-line (C\-k)
3737 Kill the text from the current cursor position to the end of the line.
3739 .B backward\-kill\-line (C\-x Rubout)
3740 Kill backward to the beginning of the line.
3742 .B unix\-line\-discard (C\-u)
3743 Kill backward from point to the beginning of the line.
3744 .\" There is no real difference between this and backward-kill-line
3746 .B kill\-whole\-line
3747 Kill all characters on the current line, no matter where the
3750 .B kill\-word (M\-d)
3751 Kill from the cursor to the end of the current word, or if between
3752 words, to the end of the next word. Word boundaries are the same as
3753 those used by \fBforward\-word\fP.
3755 .B backward\-kill\-word (M\-Rubout)
3756 Kill the word behind the cursor. Word boundaries are the same as
3757 those used by \fBbackward\-word\fP.
3759 .B unix\-word\-rubout (C\-w)
3760 Kill the word behind the cursor, using white space as a word boundary.
3761 The word boundaries are different from \fBbackward\-kill\-word\fP.
3763 .B delete\-horizontal\-space (M\-\e)
3764 Delete all spaces and tabs around point.
3767 Kill the text between the point and \fImark\fP (saved cursor position).
3768 This text is referred to as the \fIregion\fP.
3770 .B copy\-region\-as\-kill
3771 Copy the text in the region to the kill buffer.
3773 .B copy\-backward\-word
3774 Copy the word before point to the kill buffer.
3776 .B copy\-forward\-word
3777 Copy the word following point to the kill buffer.
3780 Yank the top of the kill ring into the buffer at the cursor.
3783 Rotate the kill ring, and yank the new top. Only works following
3788 .SS Numeric Arguments
3792 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
3793 Add this digit to the argument already accumulating, or start a new
3794 argument. M\-\- starts a negative argument.
3796 .B universal\-argument
3797 Each time this is executed, the argument count is multiplied by four.
3798 The argument count is initially one, so executing this function the
3799 first time makes the argument count four.
3806 Attempt to perform completion on the text before point.
3808 attempts completion treating the text as a variable (if the
3809 text begins with \fB$\fP), username (if the text begins with
3810 \fB~\fP), hostname (if the text begins with \fB@\fP), or
3811 command (including aliases and functions) in turn. If none
3812 of these produces a match, filename completion is attempted.
3814 .B possible\-completions (M\-?)
3815 List the possible completions of the text before point.
3817 .B insert\-completions (M\-*)
3818 Insert all completions of the text before point
3819 that would have been generated by
3820 \fBpossible\-completions\fP.
3822 .B complete\-filename (M\-/)
3823 Attempt filename completion on the text before point.
3825 .B possible\-filename\-completions (C\-x /)
3826 List the possible completions of the text before point,
3827 treating it as a filename.
3829 .B complete\-username (M\-~)
3830 Attempt completion on the text before point, treating
3833 .B possible\-username\-completions (C\-x ~)
3834 List the possible completions of the text before point,
3835 treating it as a username.
3837 .B complete\-variable (M\-$)
3838 Attempt completion on the text before point, treating
3839 it as a shell variable.
3841 .B possible\-variable\-completions (C\-x $)
3842 List the possible completions of the text before point,
3843 treating it as a shell variable.
3845 .B complete\-hostname (M\-@)
3846 Attempt completion on the text before point, treating
3849 .B possible\-hostname\-completions (C\-x @)
3850 List the possible completions of the text before point,
3851 treating it as a hostname.
3853 .B complete\-command (M\-!)
3854 Attempt completion on the text before point, treating
3855 it as a command name. Command completion attempts to
3856 match the text against aliases, reserved words, shell
3857 functions, builtins, and finally executable filenames,
3860 .B possible\-command\-completions (C\-x !)
3861 List the possible completions of the text before point,
3862 treating it as a command name.
3864 .B dynamic\-complete\-history (M\-TAB)
3865 Attempt completion on the text before point, comparing
3866 the text against lines from the history list for possible
3869 .B complete\-into\-braces (M\-{)
3870 Perform filename completion and return the list of possible completions
3871 enclosed within braces so the list is available to the shell (see
3879 .B start\-kbd\-macro (C\-x (\^)
3880 Begin saving the characters typed into the current keyboard macro.
3882 .B end\-kbd\-macro (C\-x )\^)
3883 Stop saving the characters typed into the current keyboard macro
3884 and store the definition.
3886 .B call\-last\-kbd\-macro (C\-x e)
3887 Re-execute the last keyboard macro defined, by making the characters
3888 in the macro appear as if typed at the keyboard.
3894 .B re\-read\-init\-file (C\-x C\-r)
3895 Read in the contents of the \fIinputrc\fP file, and incorporate
3896 any bindings or variable assignments found there.
3899 Abort the current editing command and
3900 ring the terminal's bell (subject to the setting of
3903 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
3904 If the metafied character \fIx\fP is lowercase, run the command
3905 that is bound to the corresponding uppercase character.
3907 .B prefix\-meta (ESC)
3908 Metafy the next character typed.
3915 .B undo (C\-_, C\-x C\-u)
3916 Incremental undo, separately remembered for each line.
3918 .B revert\-line (M\-r)
3919 Undo all changes made to this line. This is like typing the
3921 command enough times to return the line to its initial state.
3923 .B tilde\-expand (M\-~)
3924 Perform tilde expansion on the current word.
3926 .B set\-mark (C\-@, M\-<space>)
3927 Set the mark to the current point. If a
3928 numeric argument is supplied, the mark is set to that position.
3930 .B exchange\-point\-and\-mark (C\-x C\-x)
3931 Swap the point with the mark. The current cursor position is set to
3932 the saved position, and the old cursor position is saved as the mark.
3934 .B character\-search (C\-])
3935 A character is read and point is moved to the next occurrence of that
3936 character. A negative count searches for previous occurrences.
3938 .B character\-search\-backward (M\-C\-])
3939 A character is read and point is moved to the previous occurrence of that
3940 character. A negative count searches for subsequent occurrences.
3942 .B insert\-comment (M\-#)
3946 variable is inserted at the beginning of the current line, and the line
3947 is accepted as if a newline had been typed. This makes the current line
3950 .B glob\-expand\-word (C\-x *)
3951 The word before point is treated as a pattern for pathname expansion,
3952 and the list of matching file names is inserted, replacing the word.
3954 .B glob\-list\-expansions (C\-x g)
3955 The list of expansions that would have been generated by
3956 .B glob\-expand\-word
3957 is displayed, and the line is redrawn.
3960 Print all of the functions and their key bindings to the
3961 readline output stream. If a numeric argument is supplied,
3962 the output is formatted in such a way that it can be made part
3963 of an \fIinputrc\fP file.
3966 Print all of the settable readline variables and their values to the
3967 readline output stream. If a numeric argument is supplied,
3968 the output is formatted in such a way that it can be made part
3969 of an \fIinputrc\fP file.
3972 Print all of the readline key sequences bound to macros and the
3973 strings they ouput. If a numeric argument is supplied,
3974 the output is formatted in such a way that it can be made part
3975 of an \fIinputrc\fP file.
3977 .B display\-shell\-version (C\-x C\-v)
3978 Display version information about the current instance of
3986 builtin is enabled, the shell provides access to the
3987 \fIcommand history\fP,
3988 the list of commands previously typed. The text of the last
3991 commands (default 500) is saved in a history list. The shell
3992 stores each command in the history list prior to parameter and
3993 variable expansion (see
3996 above) but after history expansion is performed, subject to the
3997 values of the shell variables
4003 On startup, the history is initialized from the file named by
4007 (default \fI~/.bash_history\fP).
4010 is truncated, if necessary, to contain no more than
4014 When an interactive shell exits, the last
4017 lines are copied from the history list to
4022 shell option is enabled
4023 (see the description of
4027 .B "SHELL BUILTIN COMMANDS"
4028 below), the lines are appended to the history file,
4029 otherwise the history file is overwritten.
4033 is unset, or if the history file is unwritable, the history is
4034 not saved. After saving the history, the history file is truncated
4035 to contain no more than
4041 is not set, no truncation is performed.
4047 .B SHELL BUILTIN COMMANDS
4048 below) may be used to list or edit and re-execute a portion of
4052 builtin can be used to display or modify the history list and
4053 manipulate the history file.
4054 When using the command-line editing, search commands
4055 are available in each editing mode that provide access to the
4058 The shell allows control over which commands are saved on the history
4065 variables may be set to cause the shell to save only a subset of the
4069 shell option, if enabled, causes the shell to attempt to save each
4070 line of a multi-line command in the same history entry, adding
4071 semicolons where necessary to preserve syntactic correctness.
4074 shell option causes the shell to save the command with embedded newlines
4075 instead of semicolons. See the description of the
4079 .B "SHELL BUILTIN COMMANDS"
4080 for information on setting and unsetting shell options.
4081 .SH "HISTORY EXPANSION"
4083 The shell supports a history expansion feature that
4084 is similar to the history expansion in
4086 This section describes what syntax features are available. This
4087 feature is enabled by default for interactive shells, and can be
4092 builtin command (see
4094 .B SHELL BUILTIN COMMANDS
4095 below). Non-interactive shells do not perform history expansion
4098 History expansions introduce words from the history list into
4099 the input stream, making it easy to repeat commands, insert the
4100 arguments to a previous command into the current input line, or
4101 fix errors in previous commands quickly.
4103 History expansion is performed immediately after a complete line
4104 is read, before the shell breaks it into words.
4105 It takes place in two parts.
4106 The first is to determine which line from the previous history
4107 to use during substitution.
4108 The second is to select portions of that line for inclusion into
4110 The line selected from the previous history is the \fIevent\fP,
4111 and the portions of that line that are acted upon are \fIwords\fP.
4112 Various \fImodifiers\fP are available to manipulate the selected words.
4113 The line is broken into words in the same fashion as when reading input,
4114 so that several \fImetacharacter\fP-separated words surrounded by
4115 quotes are considered as one word.
4116 History expansions are introduced by the appearance of the
4117 history expansion character, which is \^\fB!\fP\^ by default.
4118 Only backslash (\^\fB\e\fP\^) and single quotes can quote
4119 the history expansion character.
4121 Several shell options settable with the
4123 builtin may be used to tailor the behavior of history expansion.
4126 shell option is enabled (see the description of the
4130 is being used, history substitutions are not immediately passed to
4132 Instead, the expanded line is reloaded into the
4134 editing buffer for further modification.
4137 is being used, and the
4139 shell option is enabled, a failed history substitution will be reloaded
4142 editing buffer for correction.
4147 builtin command may be used to see what a history expansion will
4153 builtin may be used to add commands to the end of the history list
4154 without actually executing them, so that they are available for
4157 The shell allows control of the various characters used by the
4158 history expansion mechanism (see the description of
4161 .BR "Shell Variables" ).
4162 .SS Event Designators
4164 An event designator is a reference to a command line entry in the
4170 Start a history substitution, except when followed by a
4175 Refer to command line
4179 Refer to the current command line minus
4183 Refer to the previous command. This is a synonym for `!\-1'.
4186 Refer to the most recent command starting with
4189 .B !?\fIstring\fR\fB[?]\fR
4190 Refer to the most recent command containing
4192 The trailing \fB?\fP may be omitted if
4194 is followed immediately by a newline.
4196 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
4197 Quick substitution. Repeat the last command, replacing
4202 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
4203 (see \fBModifiers\fP below).
4206 The entire command line typed so far.
4208 .SS Word Designators
4210 Word designators are used to select desired words from the event.
4213 separates the event specification from the word designator.
4214 It can be omitted if the word designator begins with a
4221 Words are numbered from the beginning of the line,
4222 with the first word being denoted by 0 (zero).
4223 Words are inserted into the current line separated by single spaces.
4228 The zeroth word. For the shell, this is the command
4235 The first argument. That is, word 1.
4241 The word matched by the most recent `?\fIstring\fR?' search.
4244 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
4247 All of the words but the zeroth. This is a synonym
4248 for `\fI1\-$\fP'. It is not an error to use
4250 if there is just one
4251 word in the event; the empty string is returned in that case.
4254 Abbreviates \fIx\-$\fP.
4257 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
4260 If a word designator is supplied without an event specification, the
4261 previous command is used as the event.
4264 After the optional word designator, there may appear a sequence of
4265 one or more of the following modifiers, each preceded by a `:'.
4271 Remove a trailing file name component, leaving only the head.
4274 Remove all leading file name components, leaving the tail.
4277 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
4281 Remove all but the trailing suffix.
4284 Print the new command but do not execute it.
4287 Quote the substituted words, escaping further substitutions.
4290 Quote the substituted words as with
4292 but break into words at
4296 .B s/\fIold\fP/\fInew\fP/
4299 for the first occurrence of
4301 in the event line. Any delimiter can be used in place of /. The
4302 final delimiter is optional if it is the last character of the
4303 event line. The delimiter may be quoted in
4307 with a single backslash. If & appears in
4311 A single backslash will quote the &. If
4313 is null, it is set to the last
4315 substituted, or, if no previous history substitutions took place,
4319 .B !?\fIstring\fR\fB[?]\fR
4323 Repeat the previous substitution.
4326 Cause changes to be applied over the entire event line. This is
4327 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
4328 or `\fB:&\fP'. If used with
4329 `\fB:s\fP', any delimiter can be used
4330 in place of /, and the final delimiter is optional
4331 if it is the last character of the event line.
4333 .SH "ARITHMETIC EVALUATION"
4334 The shell allows arithmetic expressions to be evaluated, under
4335 certain circumstances (see the \fBlet\fP builtin command and
4336 \fBArithmetic Expansion\fP).
4338 is done in long integers with no check for overflow, though division
4339 by 0 is trapped and flagged as an error. The following list of
4340 operators is grouped into levels of equal-precedence operators.
4341 The levels are listed in order of decreasing precedence.
4346 unary minus and plus
4349 logical and bitwise negation
4352 multiplication, division, remainder
4355 addition, subtraction
4358 left and right bitwise shifts
4364 equality and inequality
4370 bitwise exclusive OR
4381 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
4382 conditional evaluation
4384 .B = *= /= %= += \-= <<= >>= &= ^= |=
4388 Shell variables are allowed as operands; parameter expansion is
4389 performed before the expression is evaluated.
4390 The value of a parameter is coerced to a long integer within
4391 an expression. A shell variable need not have its integer attribute
4392 turned on to be used in an expression.
4394 Constants with a leading 0 are interpreted as octal numbers.
4395 A leading 0x or 0X denotes hexadecimal.
4396 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
4397 is a decimal number between 2 and 64 representing the arithmetic
4398 base, and \fIn\fP is a number in that base.
4399 If \fIbase\fP is omitted, then base 10 is used.
4400 The digits greater than 9 are represented by the lowercase letters,
4401 the uppercase letters, _, and @, in that order.
4402 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
4403 letters may be used interchangably to represent numbers between 10
4406 Operators are evaluated in order of precedence. Sub-expressions in
4407 parentheses are evaluated first and may override the precedence
4409 .SH "SHELL BUILTIN COMMANDS"
4410 .\" start of bash_builtins
4413 Unless otherwise noted, each builtin command documented in this
4414 section as accepting options preceded by
4418 to signify the end of the options.
4422 \fB:\fP [\fIarguments\fP]
4424 No effect; the command does nothing beyond expanding
4426 and performing any specified
4427 redirections. A zero exit code is returned.
4430 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
4432 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
4434 Read and execute commands from
4437 shell environment and return the exit status of the last command
4442 does not contain a slash, file names in
4445 are used to find the directory containing
4447 The file searched for in
4450 need not be executable. The current directory is
4451 searched if no file is found in
4458 builtin command is turned off, the
4462 If any \fIarguments\fP are supplied, they become the positional
4463 parameters when \fIfilename\fP is executed. Otherwise the positional
4464 parameters are unchanged.
4465 The return status is the status of the last command exited within
4466 the script (0 if no commands are executed), and false if
4470 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
4471 \fBAlias\fP with no arguments or with the
4473 option prints the list of aliases in the form
4474 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
4475 When arguments are supplied, an alias is defined for
4476 each \fIname\fP whose \fIvalue\fP is given.
4477 A trailing space in \fIvalue\fP causes the next word to be
4478 checked for alias substitution when the alias is expanded.
4479 For each \fIname\fP in the argument list for which no \fIvalue\fP
4480 is supplied, the name and value of the alias is printed.
4481 \fBAlias\fP returns true unless a \fIname\fP is given for which
4482 no alias has been defined.
4484 \fBbg\fP [\fIjobspec\fP]
4485 Place \fIjobspec\fP in the background, as if it had been started with
4487 If \fIjobspec\fP is not present, the shell's notion of the
4488 \fIcurrent job\fP is used.
4491 returns 0 unless run when job control is disabled or, when run with
4492 job control enabled, if \fIjobspec\fP was not found or started without
4496 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP] [\fB\-q\fP \fIname\fP] [\fB\-r\fP \fIkeyseq\fP]
4498 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
4500 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
4504 key and function bindings, or bind a key sequence to a
4506 function or macro. The binding syntax accepted is identical to that of
4508 but each binding must be passed as a separate argument;
4509 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the
4517 as the keymap to be affected by the subsequent bindings.
4521 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4524 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4525 equivalent to \fIemacs\-standard\fP.
4528 List the names of all \fBreadline\fP functions.
4531 Display \fBreadline\fP function names and bindings in such a way
4532 that they can be re-read.
4535 List current \fBreadline\fP function names and bindings.
4538 Display \fBreadline\fP variable names and values in such a way that they
4542 List current \fBreadline\fP variable names and values.
4545 Display \fBreadline\fP key sequences bound to macros and the strings
4546 they output in such a way that they can be re-read.
4549 Display \fBreadline\fP key sequences bound to macros and the strings
4552 .B \-f \fIfilename\fP
4553 Read key bindings from \fIfilename\fP.
4555 .B \-q \fIfunction\fP
4556 Query about which keys invoke the named \fIfunction\fP.
4559 Remove any current binding for \fIkeyseq\fP.
4562 The return value is 0 unless an unrecognized option is given or an
4566 \fBbreak\fP [\fIn\fP]
4573 loop. If \fIn\fP is specified, break \fIn\fP levels.
4577 is greater than the number of enclosing loops, all enclosing loops
4578 are exited. The return value is 0 unless the shell is not executing
4583 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
4584 Execute the specified shell builtin, passing it
4586 and return its exit status.
4587 This is useful when you wish to define a
4588 function whose name is the same as a shell builtin,
4589 but need the functionality of the
4590 builtin within the function itself. The \fBcd\fP builtin is
4591 commonly redefined this way. The return status is false if
4593 is not a shell builtin command.
4595 \fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
4596 Change the current directory to \fIdir\fP. The variable
4605 defines the search path for the directory containing
4607 Alternative directory names in
4610 are separated by a colon (:). A null directory name in
4613 is the same as the current directory, i.e., ``\fB.\fP''. If
4615 begins with a slash (/),
4621 option says to use the physical directory structure instead of
4622 following symbolic links (see also the
4626 builtin command); the
4628 option forces symbolic links to be followed. An argument of
4633 The return value is true if the directory was successfully changed;
4636 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
4641 suppressing the normal shell function lookup. Only builtin
4642 commands or commands found in the
4645 are executed. If the
4647 option is given, the search for
4649 is performed using a default value for
4651 that is guaranteed to find all of the standard utilities.
4656 option is supplied, a description of
4660 option causes a single word indicating the command or file name
4665 option produces a more verbose description.
4670 option is supplied, the exit status is 0 if
4672 was found, and 1 if not. If neither option is supplied and
4673 an error occurred or
4675 cannot be found, the exit status is 127. Otherwise, the exit status of the
4677 builtin is the exit status of
4680 \fBcontinue\fP [\fIn\fP]
4681 Resume the next iteration of the enclosing
4690 is specified, resume at the \fIn\fPth enclosing loop.
4694 is greater than the number of enclosing loops, the last enclosing loop
4695 (the ``top-level'' loop) is resumed. The return value is 0 unless the
4696 shell is not executing a loop when
4701 \fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
4703 \fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
4705 Declare variables and/or give them attributes.
4706 If no \fIname\fPs are given then display the values of variables.
4709 option will display the attributes and values of each
4713 is used, additional options are ignored.
4716 option inhibits the display of function definitions; only the
4717 function name and attributes are printed.
4722 The following options can
4723 be used to restrict output to variables with the specified attribute or
4724 to give variables attributes:
4729 Each \fIname\fP is an array variable (see
4734 Use function names only.
4737 The variable is treated as an integer; arithmetic evaluation (see
4739 .B "ARITHMETIC EVALUATION" ") "
4740 is performed when the variable is assigned a value.
4743 Make \fIname\fPs readonly. These names cannot then be assigned values
4744 by subsequent assignment statements.
4747 Mark \fIname\fPs for export to subsequent commands via the environment.
4750 Using `+' instead of `\-'
4751 turns off the attribute instead, with the exception that \fB+a\fP
4752 may not be used to destroy an array variable. When used in a function,
4754 \fIname\fP local, as with the
4756 command. The return value is 0 unless an illegal option is encountered,
4757 an attempt is made to define a function using "\-f foo=bar",
4758 an attempt is made to assign a value to a readonly variable,
4759 an attempt is made to assign a value to an array variable without
4760 using the compound assignment syntax (see
4762 above), one of the \fInames\fP is not a legal shell variable name,
4763 an attempt is made to turn off readonly status for a readonly variable,
4764 an attempt is made to turn off array status for an array variable,
4765 or an attempt is made to display a non-existent function with \-f.
4768 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
4769 Without options, displays the list of currently remembered directories.
4770 The default display is on a single line with directory names separated
4772 Directories are added to the list with the
4776 command removes entries from the list.
4781 Displays the \fIn\fPth entry counting from the left of the list
4784 when invoked without options, starting with zero.
4787 Displays the \fIn\fPth entry counting from the right of the list
4790 when invoked without options, starting with zero.
4793 Clears the directory stack by deleting all of the entries.
4796 Produces a longer listing; the default listing format uses a
4797 tilde to denote the home directory.
4800 Print the directory stack with one entry per line.
4803 Print the directory stack with one entry per line,
4804 prefixing each entry with its index in the stack.
4807 The return value is 0 unless an
4808 illegal option is supplied or \fIn\fP indexes beyond the end
4809 of the directory stack.
4812 \fBdisown\fP [\fB\-h\fP] [\fIjobspec\fP ...]
4813 Without options, each
4815 is removed from the table of active jobs.
4816 If the \fB\-h\fP option is given, the job is not removed from the table,
4817 but is marked so that
4820 is not sent to the job if the shell receives a
4825 is present, the \fIcurrent job\fP is used. The return value is
4828 does not specify a valid job.
4830 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
4831 Output the \fIarg\fPs, separated by spaces, followed by a newline.
4832 The return status is always 0.
4833 If \fB\-n\fP is specified, the trailing newline is
4834 suppressed. If the \fB\-e\fP option is given, interpretation of
4835 the following backslash-escaped characters is enabled. The
4837 option disables the interpretation of these escape characters,
4838 even on systems where they are interpreted by default.
4842 to mean the end of options.
4844 interprets the following escape sequences:
4855 suppress trailing newline
4879 the character whose ASCII code is \fInnn\fP (octal)
4883 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
4884 Enable and disable builtin shell commands. This allows
4885 the execution of a disk command which has the same name as a shell
4886 builtin without specifying a full file name.
4887 If \fB\-n\fP is used, each \fIname\fP
4888 is disabled; otherwise,
4889 \fInames\fP are enabled. For example, to use the
4891 binary found via the
4894 instead of the shell builtin version, run
4895 \f(CWenable -n test\fP.
4898 option means to load the new builtin command
4902 on systems that support dynamic loading. The
4904 option will delete a builtin previously loaded with
4906 If no \fIname\fP arguments are given, or if the
4908 option is supplied, a list of shell builtins is printed.
4909 With no other option arguments, the list consists of all enabled
4911 If \fB\-n\fP is supplied, only disabled builtins are printed.
4912 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
4913 indication of whether or not each is enabled.
4914 If \fB\-s\fP is supplied, the output is restricted to the POSIX
4915 \fIspecial\fP builtins.
4916 The return value is 0 unless a
4918 is not a shell builtin or there is a problem loading a new builtin
4919 from a shared object.
4921 \fBeval\fP [\fIarg\fP ...]
4922 The \fIarg\fPs are read and concatenated together into a single
4923 command. This command is then read and executed by the shell, and
4924 its exit status is returned as the value of
4928 or only null arguments,
4932 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP] [\fIarguments\fP]
4935 is specified, it replaces the shell.
4936 No new process is created. The
4938 become the arguments to \fIcommand\fP.
4942 the shell places a dash in the zeroth arg passed to
4950 to be executed with an empty environment. If
4952 is supplied, the shell passes
4954 as the zeroth argument to the executed command. If
4956 cannot be executed for some reason, a non-interactive shell exits,
4957 unless the shell option
4959 is enabled, in which case it returns failure.
4960 An interactive shell returns failure if the file cannot be executed.
4963 is not specified, any redirections take effect in the current shell,
4964 and the return status is 0.
4966 \fBexit\fP [\fIn\fP]
4967 Cause the shell to exit
4968 with a status of \fIn\fP. If
4970 is omitted, the exit status
4971 is that of the last command executed.
4975 is executed before the shell terminates.
4978 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
4984 are marked for automatic export to the environment of
4985 subsequently executed commands. If the
4993 are given, or if the
4995 option is supplied, a list
4996 of all names that are exported in this shell is printed.
4999 option causes the export property to be removed from the
5002 returns an exit status of 0 unless an illegal option is
5004 one of the \fInames\fP is not a legal shell variable name, or
5008 that is not a function.
5011 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
5013 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
5015 Fix Command. In the first form, a range of commands from
5019 is selected from the history list.
5023 may be specified as a string (to locate the last command beginning
5024 with that string) or as a number (an index into the history list,
5025 where a negative number is used as an offset from the current
5028 is not specified it is set to
5029 the current command for listing (so that
5031 prints the last 10 commands) and to
5036 is not specified it is set to the previous
5037 command for editing and \-16 for listing.
5042 the command numbers when listing. The
5044 flag reverses the order of
5045 the commands. If the
5048 the commands are listed on
5049 standard output. Otherwise, the editor given by
5052 on a file containing those commands. If
5058 variable is used, and
5065 is not set. If neither variable is set,
5067 is used. When editing is complete, the edited commands are
5068 echoed and executed.
5070 In the second form, \fIcommand\fP is re-executed after each instance
5071 of \fIpat\fP is replaced by \fIrep\fP.
5072 A useful alias to use with this is
5074 .if t \f(CWr='fc \-s'\fP,
5078 runs the last command beginning with
5084 re-executes the last command.
5086 If the first form is used, the return value is 0 unless an illegal
5087 option is encountered or
5091 specify history lines out of range.
5094 option is supplied, the return value is the value of the last
5095 command executed or failure if an error occurs with the temporary
5096 file of commands. If the second form is used, the return status
5097 is that of the command re-executed, unless
5099 does not specify a valid history line, in which case
5103 \fBfg\fP [\fIjobspec\fP]
5106 in the foreground, and make it the current job. If
5108 is not present, the shell's notion of the \fIcurrent job\fP is used.
5109 The return value is that of the command placed into the foreground,
5110 or failure if run when job control is disabled or, when run with
5111 job control enabled, if
5113 does not specify a valid job or
5115 specifies a job that was started without job control.
5117 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
5119 is used by shell procedures to parse positional parameters.
5121 contains the option letters to be recognized; if a letter
5122 is followed by a colon, the option is expected to have an
5123 argument, which should be separated from it by white space.
5124 Each time it is invoked,
5126 places the next option in the shell variable
5130 if it does not exist,
5131 and the index of the next argument to be processed into the
5137 is initialized to 1 each time the shell or a shell script
5138 is invoked. When an option requires an argument,
5140 places that argument into the variable
5143 The shell does not reset
5146 automatically; it must be manually reset between multiple
5149 within the same shell invocation if a new set of parameters
5153 can report errors in two ways. If the first character of
5157 error reporting is used. In normal operation diagnostic messages
5158 are printed when illegal options or missing option arguments are
5163 is set to 0, no error message will be displayed, even if the first
5168 If an illegal option is seen,
5173 prints an error message and unsets
5179 the option character found is placed in
5182 and no diagnostic message is printed.
5184 If a required argument is not found, and
5187 a question mark (\^\fB?\fP\^) is placed in
5190 is unset, and a diagnostic message is printed.
5193 is silent, then a colon (\^\fB:\fP\^) is placed in
5198 is set to the option character found.
5201 normally parses the positional parameters, but if more arguments are
5205 parses those instead.
5207 returns true if an option, specified or unspecified, is found.
5208 It returns false if the end of options is encountered or an
5211 \fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fIname\fP]
5214 the full file name of the command is determined by searching
5220 option is supplied, no path search is performed, and
5222 is used as the full file name of the command.
5225 option causes the shell to forget all
5226 remembered locations. If no arguments are given, information
5227 about remembered commands is printed.
5228 The return status is true unless a
5230 is not found or an illegal option is supplied.
5232 \fBhelp\fP [\fIpattern\fP]
5233 Display helpful information about builtin commands. If
5237 gives detailed help on all commands matching
5239 otherwise help for all the builtins and shell control structures
5240 is printed. The return status is 0 unless no command matches
5244 \fBhistory\fP [\fB\-c\fP] [\fIn\fP]
5246 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
5248 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
5250 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
5252 With no options, display the command
5253 history list with line numbers. Lines listed
5256 have been modified. An argument of
5260 lines. If \fIfilename\fP is supplied, it is used as the
5261 name of the history file; if not, the value of
5264 is used. Options, if supplied, have the following meanings:
5269 Append the ``new'' history lines (history lines entered since the
5270 beginning of the current \fBbash\fP session) to the history file.
5273 Read the history lines not already read from the history
5274 file into the current history list. These are lines
5275 appended to the history file since the beginning of the
5276 current \fBbash\fP session.
5279 Read the contents of the history file
5280 and use them as the current history.
5283 Write the current history to the history file, overwriting the
5284 history file's contents.
5287 Clear the history list by deleting all the entries.
5290 Perform history substitution on the following \fIargs\fP and display
5291 the result on the standard output.
5292 Does not store the results in the history list.
5293 Each \fIarg\fP must be quoted to disable normal history expansion.
5298 in the history list as a single entry. The last command in the
5299 history list is removed before the
5304 The return value is 0 unless an illegal option is encountered or an
5305 error occurs while reading or writing the history file.
5309 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
5311 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
5313 The first form lists the active jobs. The options have the following
5320 in addition to the normal information.
5323 List only the process ID of the job's process group
5327 Display information only about jobs that have changed status since
5328 the user was last notified of their status.
5331 Restrict output to running jobs.
5334 Restrict output to stopped jobs.
5339 is given, output is restricted to information about that job.
5340 The return status is 0 unless an illegal option is encountered
5355 with the corresponding process group ID, and executes
5359 returning its exit status.
5363 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
5365 \fBkill\fP \fB\-l\fP [\fIsignum\fP | \fIsigspec\fP]
5367 Send the signal named by
5371 to the processes named by
5376 is either a signal name such as
5381 is a signal number. If
5383 is a signal name, the name may be
5384 given with or without the
5390 is not present, then
5393 is assumed. An argument of
5395 lists the signal names. If any arguments are supplied when
5397 is given, the names of the specified signals are listed, and
5398 the return status is 0. The arguments to
5400 may be either signal names or signal numbers; if signal names
5401 are given, the corresponding signal number is displayed.
5403 returns true if at least one signal was successfully sent, or false
5404 if an error occurs or an illegal option is encountered.
5406 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
5409 is an arithmetic expression to be evaluated (see
5411 .BR "ARITHMETIC EVALUATION" ).
5416 returns 1; 0 is returned otherwise.
5418 \fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...]
5419 For each argument, create a local variable named
5425 is used within a function, it causes the variable
5427 to have a visible scope restricted to that function and its children.
5430 writes a list of local variables to the standard output. It is
5433 when not within a function. The return status is 0 unless
5435 is used outside a function, or an illegal
5442 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
5443 Removes entries from the directory stack. With no arguments,
5444 removes the top directory from the stack, and performs a
5446 to the new top directory.
5447 Arguments, if supplied, have the following meanings:
5452 Removes the \fIn\fPth entry counting from the left of the list
5455 starting with zero. For example: ``popd +0''
5456 removes the first directory, ``popd +1'' the second.
5459 Removes the \fIn\fPth entry counting from the right of the list
5462 starting with zero. For example: ``popd -0''
5463 removes the last directory, ``popd -1'' the next to last.
5466 Suppresses the normal change of directory when removing directories
5467 from the stack, so that only the stack is manipulated.
5472 command is successful, a
5474 is performed as well, and the return status is 0.
5476 returns false if an illegal option is encountered, the directory stack
5477 is empty, a non-existent directory stack entry is specified, or the
5478 directory change fails.
5482 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
5484 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
5486 Adds a directory to the top of the directory stack, or rotates
5487 the stack, making the new top of the stack the current working
5488 directory. With no arguments, exchanges the top two directories
5489 and returns 0, unless the directory stack is empty.
5490 Arguments, if supplied, have the following meanings:
5495 Rotates the stack so that the \fIn\fPth directory
5496 (counting from the left of the list shown by
5501 Rotates the stack so that the \fIn\fPth directory
5502 (counting from the right) is at the top.
5505 Suppresses the normal change of directory when adding directories
5506 to the stack, so that only the stack is manipulated.
5511 to the directory stack at the top, making it the
5512 new current working directory.
5517 command is successful, a
5519 is performed as well.
5520 If the first form is used,
5522 returns 0 unless the cd to
5524 fails. With the second form,
5526 returns 0 unless the directory stack is empty,
5527 a non-existent directory stack element is specified,
5528 or the directory change to the specified new current directory
5532 \fBpwd\fP [\fB\-LP\fP]
5533 Print the absolute file name of the current working directory.
5534 The file name printed contains no symbolic links if the
5536 option is supplied or the
5540 builtin command is enabled.
5543 option is used, symbolic links are followed.
5544 The return status is 0 unless an error occurs while
5545 reading the name of the current directory.
5547 \fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...]
5548 One line is read from the standard input, and the first word
5549 is assigned to the first
5551 the second word to the second
5553 and so on, with leftover words assigned to the last
5555 Only the characters in
5558 are recognized as word delimiters. Options, if supplied, have the
5564 A backslash-newline pair is not ignored, and
5565 the backslash is considered to be part of the line.
5568 Display \fIprompt\fP, without a
5569 trailing newline, before attempting to read any input. The prompt
5570 is displayed only if input is coming from a terminal.
5573 The words are assigned to sequential indices
5574 of the array variable
5578 is unset before any new values are assigned.
5581 If the standard input
5582 is coming from a terminal,
5587 above) is used to obtain the line.
5592 are supplied, the line read is assigned to the variable
5595 The return code is zero, unless end-of-file is encountered.
5598 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
5601 \fInames\fP are marked readonly; the values of these
5603 may not be changed by subsequent assignment.
5606 option is supplied, the functions corresponding to the
5611 option restricts the variables to arrays.
5614 arguments are given, or if the
5616 option is supplied, a list of all readonly names is printed.
5617 The return status is 0 unless an illegal option is encountered,
5620 is not a legal shell variable name, or
5624 that is not a function.
5626 \fBreturn\fP [\fIn\fP]
5627 Causes a function to exit with the return value specified by
5631 is omitted, the return status is that of the last command
5632 executed in the function body. If used outside a function,
5633 but during execution of a script by the
5635 (\fBsource\fP) command, it causes the shell to stop executing
5636 that script and return either
5638 or the exit status of the last command executed within the
5639 script as the exit status of the script. If used outside a
5640 function and not during execution of a script by \fB.\fP\^,
5641 the return status is false.
5643 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
5644 Without options, the name and value of each shell variable are displayed
5645 in a format that can be re-used as input.
5646 When options are specified, they set or unset shell attributes.
5647 Any arguments remaining after the options are processed are treated
5648 as values for the positional parameters and are assigned, in order, to
5653 Options, if specified, have the following meanings:
5658 Automatically mark variables which are modified or created for export
5659 to the environment of subsequent commands.
5662 Report the status of terminated background jobs
5663 immediately, rather than before the next primary prompt. This is
5664 effective only when job control is enabled.
5667 Exit immediately if a \fIsimple command\fP (see
5670 above) exits with a non-zero status. The shell does not exit if the
5671 command that fails is part of an
5678 statement, part of a
5682 list, or if the command's return value is
5687 Disable pathname expansion.
5690 Remember the location of commands as they are looked up for execution.
5691 This is on by default.
5694 All arguments in the form of assignment statements
5695 are placed in the environment for a command, not just
5696 those that precede the command name.
5699 Monitor mode. Job control is enabled. This flag is on
5700 by default for interactive shells on systems that support
5704 above). Background processes run in a separate process
5705 group and a line containing their exit status is printed
5706 upon their completion.
5709 Read commands but do not execute them. This may be used to
5710 check a shell script for syntax errors. This is ignored by
5713 .B \-o \fIoption\-name\fP
5714 The \fIoption\-name\fP can be one of the following:
5726 Use an emacs-style command line editing interface. This is enabled
5727 by default when the shell is interactive, unless the shell is started
5745 Enable command history, as described above under
5748 This option is on by default in interactive shells.
5751 The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed
5793 Change the behavior of
5795 where the default operation differs
5796 from the POSIX 1003.2 standard to match the standard.
5807 Use a vi-style command line editing interface.
5816 is supplied with no \fIoption\-name\fP, the values of the current options are
5820 is supplied with no \fIoption\-name\fP, a series of
5822 commands to recreate the current option settings is displayed on
5823 the standard output.
5829 mode. In this mode, the
5831 file is not processed, and shell functions
5832 are not inherited from the environment. This is enabled automatically
5833 on startup if the effective user (group) id is not equal to the real
5834 user (group) id. Turning this option off causes the effective user
5835 and group ids to be set to the real user and group ids.
5838 Exit after reading and executing one command.
5841 Treat unset variables as an error when performing
5842 parameter expansion. If expansion is attempted on an
5843 unset variable, the shell prints an error message, and,
5844 if not interactive, exits with a non-zero status.
5847 Print shell input lines as they are read.
5850 After expanding each \fIsimple command\fP,
5851 display the expanded value of
5854 followed by the command and its expanded arguments.
5857 The shell performs brace expansion (see
5859 above). This is on by default.
5864 does not overwrite an existing file with the
5869 redirection operators. This may be overridden when
5870 creating output files by using the redirection operator
5878 style history substitution. This flag is on by
5879 default when the shell is interactive.
5882 If set, the shell does not follow symbolic links when executing
5885 that change the current working directory. It uses the
5886 physical directory structure instead. By default,
5888 follows the logical chain of directories when performing commands
5889 which change the current directory.
5892 If no arguments follow this flag, then the positional parameters are
5893 unset. Otherwise, the positional parameters are set to the
5894 \fIarg\fPs, even if some of them begin with a
5898 Signal the end of options, cause all remaining \fIarg\fPs to be
5899 assigned to the positional parameters. The
5903 options are turned off.
5904 If there are no \fIarg\fPs,
5905 the positional parameters remain unchanged.
5908 The flags are off by default
5909 unless otherwise noted.
5910 Using + rather than \- causes these flags
5911 to be turned off. The
5912 flags can also be specified as options to an
5913 invocation of the shell. The current
5914 set of flags may be found in
5916 The return status is always true
5917 unless an illegal option is encountered.
5920 \fBshift\fP [\fIn\fP]
5921 The positional parameters from \fIn\fP+1 ... are renamed to
5924 Parameters represented by the numbers \fB$#\fP
5925 down to \fB$#\fP\-\fIn\fP+1 are unset.
5927 must be a non-negative number less than or equal to \fB$#\fP.
5930 is 0, no parameters are changed.
5933 is not given, it is assumed to be 1.
5936 is greater than \fB$#\fP, the positional parameters are not changed.
5937 The return status is greater than zero if
5941 or less than zero; otherwise 0.
5943 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
5944 Toggle the values of variables controlling optional shell behavior.
5945 With no options, or with the
5947 option, a list of all settable options is displayed, with
5948 an indication of whether or not each is set. Other options have
5949 the following meanings:
5954 Enable (set) each \fIoptname\fP.
5957 Disable (unset) each \fIoptname\fP.
5960 Suppresses normal output (quiet mode); the return status indicates
5961 whether the \fIoptname\fP is set or unset.
5962 If multiple \fIoptname\fP arguments are given with
5964 the return status is zero if all \fIoptnames\fP are enabled; non-zero
5968 Restricts the values of \fIoptname\fP to be those defined for the
5979 is used with no \fIoptname\fP arguments, the display is limited to
5980 those options which are set or unset, respectively.
5981 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
5984 The return status when listing options is zero if all \fIoptnames\fP
5985 are enabled, non-zero otherwise. When setting or unsetting options,
5986 the return status is zero unless an \fIoptname\fP is not a legal shell
5989 The list of \fBshopt\fP options is:
5995 If set, an argument to the
5997 builtin command that
5998 is not a directory is assumed to be the name of a variable whose
5999 value is the directory to change to.
6002 If set, minor errors in the spelling of a directory component in a
6004 command will be corrected.
6005 The errors checked for are transposed characters,
6006 a missing character, and one character too many.
6007 If a correction is found, the corrected file name is printed,
6008 and the command proceeds.
6009 This option is enabled by default, but is only used by interactive shells.
6012 If set, \fBbash\fP checks that a command found in the hash
6013 table exists before trying to execute it. If a hashed command no
6014 longer exists, a normal path search is performed.
6017 If set, \fBbash\fP checks the window size after each command
6018 and, if necessary, updates the values of
6028 attempts to save all lines of a multiple-line
6029 command in the same history entry. This allows
6030 easy re-editing of multi-line commands.
6035 includes filenames beginning with a `.' in the results of pathname
6039 If set, a non-interactive shell will not exit if
6040 it cannot execute the file specified as an argument to the
6042 builtin command. An interactive shell does not exit if
6047 If set, aliases are expanded as described above under
6050 This option is enabled by default for interactive shells.
6053 If set, the history list is appended to the file named by the value
6056 variable when the shell exits, rather than overwriting the file.
6061 is being used, a user is given the opportunity to re-edit a
6062 failed history substitution.
6067 is being used, the results of history substitution are not immediately
6068 passed to the shell parser. Instead, the resulting line is loaded into
6069 the \fBreadline\fP editing buffer, allowing further modification.
6074 is being used, bash will attempt to perform hostname completion when a
6075 word beginning with \fB@\fP is being completed (see
6081 This is enabled by default.
6083 .B interactive_comments
6084 If set, allow a word beginning with
6086 to cause that word and all remaining characters on that
6087 line to be ignored in an interactive shell (see
6090 above). This option is enabled by default.
6095 option is enabled, multi-line commands are saved to the history with
6096 embedded newlines rather than using semicolon separators where possible.
6099 If set, and a file that \fBbash\fP is checking for mail has been
6100 accessed since the last time it was checked, the message ``The mail in
6101 \fImailfile\fP has been read'' is displayed.
6106 allows patterns which match no
6108 .B Pathname Expansion
6110 to expand to a null string, rather than themselves.
6113 If set, prompt strings undergo variable and parameter expansion after
6114 being expanded as described in
6117 above. This option is enabled by default.
6122 builtin prints an error message when the shift count exceeds the
6123 number of positional parameters.
6127 \fBsource\fP (\fB.\fP) builtin uses the value of
6130 to find the directory containing the file supplied as an argument.
6131 This is enabled by default.
6134 \fBsuspend\fP [\fB\-f\fP]
6135 Suspend the execution of this shell until it receives a
6140 option says not to complain if this is
6141 a login shell; just suspend anyway. The return status is 0 unless
6142 the shell is a login shell and
6144 is not supplied, or if job control is not enabled.
6147 \fBtest\fP \fIexpr\fP
6149 \fB[\fP \fIexpr\fP \fB]\fP
6150 Return a status of 0 or 1 depending on
6151 the evaluation of the conditional expression
6153 Expressions may be unary or binary. Unary
6154 expressions are often used to examine the status of a file. There
6155 are string operators and numeric comparison operators as well. Each
6156 operator and operand must be a separate argument. If \fIfile\fP
6157 is of the form /dev/fd/\fIn\fP, then file descriptor \fIn\fP is
6158 checked. Expressions are composed of the following primaries:
6163 True if \fIfile\fP exists and is a block special file.
6166 True if \fIfile\fP exists and is a character special file.
6169 True if \fIfile\fP exists and is a directory.
6172 True if \fIfile\fP exists.
6175 True if \fIfile\fP exists and is a regular file.
6178 True if \fIfile\fP exists and is set-group-id.
6181 True if \fIfile\fP has its ``sticky'' bit set.
6184 True if \fIfile\fP exists and is a symbolic link.
6187 True if \fIfile\fP exists and is a named pipe.
6190 True if \fIfile\fP exists and is readable.
6193 True if \fIfile\fP exists and has a size greater than zero.
6196 True if \fIfile\fP exists and is a socket.
6201 is opened on a terminal.
6204 True if \fIfile\fP exists and its set-user-id bit is set.
6207 True if \fIfile\fP exists and is writable.
6210 True if \fIfile\fP exists and is executable.
6213 True if \fIfile\fP exists and is owned by the effective user id.
6216 True if \fIfile\fP exists and is owned by the effective group id.
6218 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
6219 True if \fIfile1\fP is newer (according to
6220 modification date) than \fIfile2\fP.
6222 \fIfile1\fP \-\fBot\fP \fIfile2\fP
6223 True if \fIfile1\fP is older than \fIfile2\fP.
6225 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
6226 True if \fIfile1\fP and \fIfile2\fP have the same device and
6229 .B \-o \fIoptname\fP
6230 True if shell option
6233 See the list of options under the description of the
6240 True if the length of \fIstring\fP is zero.
6245 True if the length of
6249 \fIstring1\fP \fB=\fP \fIstring2\fP
6250 True if the strings are equal. \fB==\fP may be used in place of
6253 \fIstring1\fP \fB!=\fP \fIstring2\fP
6254 True if the strings are not equal.
6256 \fIstring1\fP \fB<\fP \fIstring2\fP
6257 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically.
6259 \fIstring1\fP \fB>\fP \fIstring2\fP
6260 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically.
6267 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
6274 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
6281 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
6292 These arithmetic binary operators return true if \fIarg1\fP
6293 is equal to, not equal to, less than, less than or equal to,
6294 greater than, or greater than or equal to \fIarg2\fP, respectively.
6298 may be positive or negative integers.
6303 Print the accumulated user and system times for the shell and
6304 for processes run from the shell. The return status is 0.
6306 \fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP]
6309 is to be read and executed when the shell receives
6316 all specified signals are
6317 reset to their original values (the values they had
6318 upon entrance to the shell). If
6320 is the null string this
6321 signal is ignored by the shell and by the
6322 commands it invokes.
6327 then the trap commands associated with
6330 are displayed. If no arguments are supplied or if
6335 prints the list of commands associated with each signal number.
6338 a signal name defined in <\fIsignal.h\fP>, or a signal number. If
6345 is executed on exit from the shell. If
6352 is executed after every \fIsimple command\fP (see
6358 option causes the shell to print a list of signal names and
6359 their corresponding numbers.
6360 Signals ignored upon entry to the shell cannot be trapped or reset.
6361 Trapped signals are reset to their original values in a child
6362 process when it is created. The return status is false if any
6364 is invalid; otherwise
6368 \fBtype\fP [\fB\-all\fP] [\fB\-type\fP | \fB\-path\fP] \fIname\fP [\fIname\fP ...]
6372 would be interpreted if used as a command name.
6377 prints a string which is one of
6386 is an alias, shell reserved word, function, builtin, or disk file,
6390 is not found, then nothing is printed, and an exit status of false
6396 either returns the name of the disk file
6397 that would be executed if
6399 were specified as a command name,
6404 If a command is hashed,
6406 prints the hashed value, not necessarily the file that appears
6414 prints all of the places that contain
6417 This includes aliases and functions,
6420 flag is not also used.
6421 The table of hashed commands is not consulted
6437 returns true if any of the arguments are found, false if
6440 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
6441 Provides control over the resources available to the shell and to
6442 processes started by it, on systems that allow such control. The
6445 can be a number in the unit specified for the resource, or the
6448 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
6449 set for the given resource. A hard limit cannot be increased once it
6450 is set; a soft limit may be increased up to the value of the hard limit.
6451 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
6455 is omitted, the current value of the soft limit of the resource is
6456 printed, unless the \fB\-H\fP option is given. When more than one
6457 resource is specified, the limit name and unit are printed before the value.
6458 Other options are interpreted as follows:
6463 All current limits are reported
6466 The maximum size of core files created
6469 The maximum size of a process's data segment
6472 The maximum size of files created by the shell
6475 The maximum size that may be locked into memory
6478 The maximum resident set size
6481 The maximum number of open file descriptors (most systems do not
6482 allow this value to be set)
6485 The pipe size in 512-byte blocks (this may not be set)
6488 The maximum stack size
6491 The maximum amount of cpu time in seconds
6494 The maximum number of processes available to a single user
6497 The maximum amount of virtual memory available to the shell
6502 is given, it is the new value of the specified resource (the
6504 option is display only).
6505 If no option is given, then
6507 is assumed. Values are in 1024-byte increments, except for
6509 which is in seconds,
6511 which is in units of 512-byte blocks,
6516 which are unscaled values. The return status is 0
6517 unless an illegal option is encountered, a non-numeric argument
6518 other than \fBunlimited\fP is supplied as \fIlimit\fP, or an
6519 error occurs while setting a new limit.
6522 \fBumask\fP [\fB\-S\fP] [\fImode\fP]
6523 The user file-creation mask is set to
6527 begins with a digit, it
6528 is interpreted as an octal number; otherwise
6529 it is interpreted as a symbolic mode mask similar
6534 is omitted, or if the
6536 option is supplied, the
6537 current value of the mask is printed.
6540 option causes the mask to be printed in symbolic form; the
6541 default output is an octal number.
6542 The return status is 0 if the mode was successfully changed or if
6543 no \fImode\fP argument was supplied, and false otherwise.
6545 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
6546 Remove \fIname\fPs from the list of defined aliases. If
6548 is supplied, all alias definitions are removed. The return
6549 value is true unless a supplied
6551 is not a defined alias.
6553 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
6556 remove the corresponding variable or function.
6557 If no options are supplied, or the
6559 option is given, each
6561 refers to a shell variable.
6562 Read-only variables may not be unset.
6568 refers to a shell function, and the function definition
6570 Each unset variable or function is removed from the environment
6571 passed to subsequent commands.
6584 are unset, they lose their special properties, even if they are
6585 subsequently reset. The exit status is true unless a
6587 does not exist or is readonly.
6589 \fBwait\fP [\fIn\fP]
6590 Wait for the specified process and return its termination
6594 ID or a job specification; if a job spec is given, all processes
6595 in that job's pipeline are waited for. If
6597 is not given, all currently active child processes
6598 are waited for, and the return status is zero. If
6600 specifies a non-existent process or job, the return status is
6601 127. Otherwise, the return status is the exit status of the last
6602 process or job waited for.
6605 .SH "RESTRICTED SHELL"
6609 is started with the name
6613 option is supplied at invocation,
6614 the shell becomes restricted.
6615 A restricted shell is used to
6616 set up an environment more controlled than the standard shell.
6617 It behaves identically to
6619 with the exception that the following are disallowed:
6621 changing directories with \fBcd\fP
6623 setting or unsetting the values of
6628 specifying command names containing
6631 specifying a file name containing a
6633 as an argument to the
6637 importing function definitions from the shell environment at startup
6639 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
6643 builtin command to replace the shell with another command
6645 adding or deleting builtin commands with the
6659 turning off restricted mode with
6662 These restrictions are enforced after any startup files are read.
6664 When a command that is found to be a shell script is executed (see
6666 .B "COMMAND EXECUTION"
6669 turns off any restrictions in the shell spawned to execute the
6674 \fIBash Features\fP, Brian Fox and Chet Ramey
6676 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
6678 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
6680 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
6682 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
6684 \fIemacs\fP(1), \fIvi\fP(1)
6692 The \fBbash\fP executable
6695 The systemwide initialization file, executed for login shells
6698 The personal initialization file, executed for login shells
6701 The individual per-interactive-shell startup file
6704 Individual \fIreadline\fP initialization file
6707 Brian Fox, Free Software Foundation
6711 Chet Ramey, Case Western Reserve University
6715 If you find a bug in
6717 you should report it. But first, you should
6718 make sure that it really is a bug, and that it appears in the latest
6723 Once you have determined that a bug actually exists, use the
6725 command to submit a bug report.
6726 If you have a fix, you are welcome to mail that
6728 Suggestions and `philosophical' bug reports may be mailed
6729 to \fPbug-bash\fP@\fIprep.ai.MIT.Edu\fP or posted to the Usenet
6733 ALL bug reports should include:
6737 The version number of \fBbash\fR
6739 The hardware and operating system
6741 The compiler used to compile
6743 A description of the bug behaviour
6745 A short script or `recipe' which exercises the bug
6749 inserts the first three items automatically into the template
6750 it provides for filing a bug report.
6752 Comments and bug reports concerning
6753 this manual page should be directed to
6754 .IR chet@ins.CWRU.Edu .
6757 It's too big and too slow.
6759 There are some subtle differences between
6761 and traditional versions of
6763 mostly because of the
6768 Aliases are confusing in some uses.
6770 Shell builtin commands and functions are not stoppable/restartable.
6772 Compound commands and command sequences of the form `a ; b ; c'
6773 are not handled gracefully when process suspension is attempted.
6774 When a process is stopped, the shell immediately executes the next
6775 command in the sequence.
6776 It suffices to place the sequence of commands between
6777 parentheses to force it into a subshell, which may be stopped as
6780 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
6781 parsed until substitution is attempted. This will delay error
6782 reporting until some time after the command is entered.
6784 Array variables may not (yet) be exported.