1 This is Info file bashref.info, produced by Makeinfo version 1.67 from
2 the input file /usr/homes/chet/src/bash/bash-2.01.1/doc/bashref.texi.
4 INFO-DIR-SECTION Utilities
6 * Bash: (bash). GNU Bourne-Again SHell
9 This text is a brief description of the features that are present in
12 This is Edition 2.0, last updated 19 May 1997,
13 of `The GNU Bash Reference Manual',
14 for `Bash', Version 2.01.
16 Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
18 Permission is granted to make and distribute verbatim copies of
19 this manual provided the copyright notice and this permission notice
20 are preserved on all copies.
22 Permission is granted to copy and distribute modified versions of this
23 manual under the conditions for verbatim copying, provided that the entire
24 resulting derived work is distributed under the terms of a permission
25 notice identical to this one.
27 Permission is granted to copy and distribute translations of this manual
28 into another language, under the above conditions for modified versions,
29 except that this permission notice may be stated in a translation approved
33 File: bashref.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
38 This text is a brief description of the features that are present in
41 This is Edition 2.0, last updated 19 May 1997, of `The GNU Bash
42 Reference Manual', for `Bash', Version 2.01.
44 Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
46 Bash contains features that appear in other popular shells, and some
47 features that only appear in Bash. Some of the shells that Bash has
48 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
49 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
50 following menu breaks the features up into categories based upon which
51 one of these other shells inspired the feature.
53 This manual is meant as a brief introduction to features found in
54 Bash. The Bash manual page should be used as the definitive reference
59 * Introduction:: An introduction to the shell.
61 * Definitions:: Some definitions used in the rest of this
64 * Basic Shell Features:: The shell "building blocks".
66 * Bourne Shell Features:: Features similar to those found in the
69 * Csh Features:: Features originally found in the
72 * Korn Shell Features:: Features originally found in the Korn
75 * Bash Features:: Features found only in Bash.
77 * Job Control:: A chapter describing what job control is
78 and how Bash allows you to use it.
80 * Using History Interactively:: Chapter dealing with history expansion
83 * Command Line Editing:: Chapter describing the command line
86 * Installing Bash:: How to build and install Bash on your system.
88 * Reporting Bugs:: How to report bugs in Bash.
90 * Builtin Index:: Index of Bash builtin commands.
92 * Reserved Word Index:: Index of Bash reserved words.
94 * Variable Index:: Quick reference helps you find the
97 * Function Index:: Index of bindable Readline functions.
99 * Concept Index:: General index for concepts described in
103 File: bashref.info, Node: Introduction, Next: Definitions, Prev: Top, Up: Top
110 * What is Bash?:: A short description of Bash.
112 * What is a shell?:: A brief introduction to shells.
115 File: bashref.info, Node: What is Bash?, Next: What is a shell?, Up: Introduction
120 Bash is the shell, or command language interpreter, that will appear
121 in the GNU operating system. The name is an acronym for the
122 `Bourne-Again SHell', a pun on Steve Bourne, the author of the direct
123 ancestor of the current Unix shell `/bin/sh', which appeared in the
124 Seventh Edition Bell Labs Research version of Unix.
126 Bash is an `sh'-compatible shell that incorporates useful features
127 from the Korn shell `ksh' and the C shell `csh'. It is ultimately
128 intended to be a conformant implementation of the IEEE POSIX Shell and
129 Tools specification (IEEE Working Group 1003.2). It offers functional
130 improvements over `sh' for both interactive and programming use.
132 While the GNU operating system will include a version of `csh', Bash
133 will be the default shell. Like other GNU software, Bash is quite
134 portable. It currently runs on nearly every version of Unix and a few
135 other operating systems - independently-supported ports exist for OS/2
139 File: bashref.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction
144 At its base, a shell is simply a macro processor that executes
145 commands. A Unix shell is both a command interpreter, which provides
146 the user interface to the rich set of Unix utilities, and a programming
147 language, allowing these utilitites to be combined. The shell reads
148 commands either from a terminal or a file. Files containing commands
149 can be created, and become commands themselves. These new commands
150 have the same status as system commands in directories like `/bin',
151 allowing users or groups to establish custom environments.
153 A shell allows execution of Unix commands, both synchronously and
154 asynchronously. The "redirection" constructs permit fine-grained
155 control of the input and output of those commands, and the shell allows
156 control over the contents of their environment. Unix shells also
157 provide a small set of built-in commands ("builtins") implementing
158 functionality impossible (e.g., `cd', `break', `continue', and `exec'),
159 or inconvenient (`history', `getopts', `kill', or `pwd', for example)
160 to obtain via separate utilities. Shells may be used interactively or
161 non-interactively: they accept input typed from the keyboard or from a
162 file. All of the shell builtins are described in subsequent sections.
164 While executing commands is essential, most of the power (and
165 complexity) of shells is due to their embedded programming languages.
166 Like any high-level language, the shell provides variables, flow
167 control constructs, quoting, and functions.
169 Shells have begun offering features geared specifically for
170 interactive use rather than to augment the programming language. These
171 interactive features include job control, command line editing, history
172 and aliases. Each of these features is described in this manual.
175 File: bashref.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top
180 These definitions are used throughout the remainder of this manual.
183 A family of open system standards based on Unix. Bash is
184 concerned with POSIX 1003.2, the Shell and Tools Standard.
187 A space or tab character.
190 A command that is implemented internally by the shell itself,
191 rather than by an executable program somewhere in the file system.
194 A `word' that performs a control function. It is a `newline' or
195 one of the following: `||', `&&', `&', `;', `;;', `|', `(', or `)'.
198 The value returned by a command to its caller.
201 A unit of text that is the result of one of the shell expansions.
202 After expansion, when executing a command, the resulting fields
203 are used as the command name and arguments.
206 A string of characters used to identify a file.
209 A set of processes comprising a pipeline, and any processes
210 descended from it, that are all in the same process group.
213 A mechanism by which users can selectively stop (suspend) and
214 restart (resume) execution of processes.
217 A character that, when unquoted, separates words. A metacharacter
218 is a `blank' or one of the following characters: `|', `&', `;',
219 `(', `)', `<', or `>'.
222 A `word' consisting solely of letters, numbers, and underscores,
223 and beginning with a letter or underscore. `Name's are used as
224 shell variable and function names. Also referred to as an
228 A `control operator' or a `redirection operator'. *Note
229 Redirections::, for a list of redirection operators.
232 A collection of related processes each having the same process
236 A unique identifer that represents a `process group' during its
240 A `word' that has a special meaning to the shell. Most reserved
241 words introduce shell flow control constructs, such as `for' and
245 A synonym for `exit status'.
248 A mechanism by which a process may be notified by the kernal of an
249 event occurring in the system.
252 A shell builtin command that has been classified as special by the
256 A sequence of characters considered a single unit by the shell.
257 It is either a `word' or an `operator'.
260 A `token' that is not an `operator'.
263 File: bashref.info, Node: Basic Shell Features, Next: Bourne Shell Features, Prev: Definitions, Up: Top
268 Bash is an acronym for `Bourne-Again SHell'. The Bourne shell is
269 the traditional Unix shell originally written by Stephen Bourne. All
270 of the Bourne shell builtin commands are available in Bash, and the
271 rules for evaluation and quoting are taken from the POSIX 1003.2
272 specification for the `standard' Unix shell.
274 This chapter briefly summarizes the shell's "building blocks":
275 commands, control structures, shell functions, shell parameters, shell
276 expansions, redirections, which are a way to direct input and output
277 from and to named files, and how the shell executes commands.
281 * Shell Syntax:: What your input means to the shell.
282 * Simple Commands:: The most common type of command.
283 * Pipelines:: Connecting the input and output of several
285 * Lists:: How to execute commands sequentially.
286 * Looping Constructs:: Shell commands for iterative action.
287 * Conditional Constructs:: Shell commands for conditional execution.
288 * Command Grouping:: Ways to group commands.
289 * Shell Functions:: Grouping commands by name.
290 * Shell Parameters:: Special shell variables.
291 * Shell Expansions:: How Bash expands variables and the various
292 expansions available.
293 * Redirections:: A way to control where input and output go.
294 * Executing Commands:: What happens when you run a command.
295 * Shell Scripts:: Executing files of shell commands.
298 File: bashref.info, Node: Shell Syntax, Next: Simple Commands, Up: Basic Shell Features
305 * Shell Operation:: The basic operation of the shell.
307 * Quoting:: How to remove the special meaning from characters.
309 * Comments:: How to specify comments.
312 File: bashref.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax
317 The following is a brief description of the shell's operation when it
318 reads and executes a command. Basically, the shell does the following:
320 1. Reads its input from a file (*note Shell Scripts::.), from a string
321 supplied as an argument to the `-c' invocation option (*note
322 Invoking Bash::.), or from the user's terminal.
324 2. Breaks the input into words and operators, obeying the quoting
325 rules described in *Note Quoting::. Tokens are separated by
326 `metacharacters'. Alias expansion is performed by this step
329 3. Parses the tokens into simple and compound commands.
331 4. Performs the various shell expansions (*note Shell Expansions::.),
332 breaking the expanded tokens into lists of filenames (*note
333 Filename Expansion::.) and commands and arguments.
335 5. Performs any necessary redirections (*note Redirections::.) and
336 removes the redirection operators and their operands from the
339 6. Executes the command (*note Executing Commands::.).
341 7. Optionally waits for the command to complete and collects its exit
346 File: bashref.info, Node: Quoting, Next: Comments, Prev: Shell Operation, Up: Shell Syntax
353 * Escape Character:: How to remove the special meaning from a single
355 * Single Quotes:: How to inhibit all interpretation of a sequence
357 * Double Quotes:: How to suppress most of the interpretation of a
358 sequence of characters.
359 * ANSI-C Quoting:: How to expand ANSI-C sequences in quoted strings.
361 * Locale Translation:: How to translate strings into different languages.
363 Quoting is used to remove the special meaning of certain characters
364 or words to the shell. Quoting can be used to disable special
365 treatment for special characters, to prevent reserved words from being
366 recognized as such, and to prevent parameter expansion.
368 Each of the shell `metacharacters' (*note Definitions::.) has
369 special meaning to the shell and must be quoted if they are to
370 represent themselves. There are three quoting mechanisms: the ESCAPE
371 CHARACTER, single quotes, and double quotes.
374 File: bashref.info, Node: Escape Character, Next: Single Quotes, Up: Quoting
379 A non-quoted backslash `\' is the Bash escape character. It
380 preserves the literal value of the next character that follows, with
381 the exception of `newline'. If a `\newline' pair appears, and the
382 backslash is not quoted, the `\newline' is treated as a line
383 continuation (that is, it is effectively ignored).
386 File: bashref.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting
391 Enclosing characters in single quotes preserves the literal value of
392 each character within the quotes. A single quote may not occur between
393 single quotes, even when preceded by a backslash.
396 File: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting
401 Enclosing characters in double quotes preserves the literal value of
402 all characters within the quotes, with the exception of `$', ``', and
403 `\'. The characters `$' and ``' retain their special meaning within
404 double quotes. The backslash retains its special meaning only when
405 followed by one of the following characters: `$', ``', `"', `\', or
406 `newline'. A double quote may be quoted within double quotes by
407 preceding it with a backslash.
409 The special parameters `*' and `@' have special meaning when in
410 double quotes (*note Shell Parameter Expansion::.).
413 File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double Quotes, Up: Quoting
418 Words of the form `$'STRING'' are treated specially. The word
419 expands to STRING, with backslash-escaped characters replaced as
420 specifed by the ANSI C standard. Backslash escape sequences, if
421 present, are decoded as follows:
430 an escape character (not ANSI C)
451 the character whose `ASCII' code is NNN in octal
453 The result is single-quoted, as if the dollar sign had not been present.
456 File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting
458 Locale-Specific Translation
459 ...........................
461 A double-quoted string preceded by a dollar sign (`$') will cause
462 the string to be translated according to the current locale. If the
463 current locale is `C' or `POSIX', the dollar sign is ignored. If the
464 string is translated and replaced, the replacement is double-quoted.
467 File: bashref.info, Node: Comments, Prev: Quoting, Up: Shell Syntax
472 In a non-interactive shell, or an interactive shell in which the
473 `interactive_comments' option to the `shopt' builtin is enabled (*note
474 Bash Builtins::.), a word beginning with `#' causes that word and all
475 remaining characters on that line to be ignored. An interactive shell
476 without the `interactive_comments' option enabled does not allow
477 comments. The `interactive_comments' option is on by default in
481 File: bashref.info, Node: Simple Commands, Next: Pipelines, Prev: Shell Syntax, Up: Basic Shell Features
486 A simple command is the kind of command you'll encounter most often.
487 It's just a sequence of words separated by `blank's, terminated by one
488 of the shell control operators (*note Definitions::.). The first word
489 generally specifies a command to be executed.
491 The return status (*note Exit Status::.) of a simple command is its
492 exit status as provided by the POSIX.1 `waitpid' function, or 128+N if
493 the command was terminated by signal N.
496 File: bashref.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Basic Shell Features
501 A `pipeline' is a sequence of simple commands separated by `|'.
503 The format for a pipeline is
504 [`time' [`-p']] [`!'] COMMAND1 [`|' COMMAND2 ...]
506 The output of each command in the pipeline is connected to the input of
507 the next command. That is, each command reads the previous command's
510 The reserved word `time' causes timing statistics to be printed for
511 the pipeline once it finishes. The `-p' option changes the output
512 format to that specified by POSIX. The `TIMEFORMAT' variable may be
513 set to a format string that specifies how the timing information should
514 be displayed. *Note Bash Variables::, for a description of the
517 Each command in a pipeline is executed in its own subshell. The exit
518 status of a pipeline is the exit status of the last command in the
519 pipeline. If the reserved word `!' precedes the pipeline, the exit
520 status is the logical NOT of the exit status of the last command.
523 File: bashref.info, Node: Lists, Next: Looping Constructs, Prev: Pipelines, Up: Basic Shell Features
528 A `list' is a sequence of one or more pipelines separated by one of
529 the operators `;', `&', `&&', or `||', and optionally terminated by one
530 of `;', `&', or a `newline'.
532 Of these list operators, `&&' and `||' have equal precedence,
533 followed by `;' and `&', which have equal precedence.
535 If a command is terminated by the control operator `&', the shell
536 executes the command in the BACKGROUND in a subshell. The shell does
537 not wait for the command to finish, and the return status is 0 (true).
538 Commands separated by a `;' are executed sequentially; the shell waits
539 for each command to terminate in turn. The return status is the exit
540 status of the last command executed.
542 The control operators `&&' and `||' denote AND lists and OR lists,
543 respectively. An AND list has the form
546 COMMAND2 is executed if, and only if, COMMAND returns an exit status of
549 An OR list has the form
552 COMMAND2 is executed if and only if COMMAND returns a non-zero exit
555 The return status of AND and OR lists is the exit status of the last
556 command executed in the list.
559 File: bashref.info, Node: Looping Constructs, Next: Conditional Constructs, Prev: Lists, Up: Basic Shell Features
564 Note that wherever you see a `;' in the description of a command's
565 syntax, it may be replaced indiscriminately with one or more newlines.
567 Bash supports the following looping constructs.
570 The syntax of the `until' command is:
571 until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
572 Execute CONSEQUENT-COMMANDS as long as the final command in
573 TEST-COMMANDS has an exit status which is not zero.
576 The syntax of the `while' command is:
577 while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
579 Execute CONSEQUENT-COMMANDS as long as the final command in
580 TEST-COMMANDS has an exit status of zero.
583 The syntax of the `for' command is:
585 for NAME [in WORDS ...]; do COMMANDS; done
586 Execute COMMANDS for each member in WORDS, with NAME bound to the
587 current member. If `in WORDS' is not present, `in "$@"' is
590 The `break' and `continue' builtins (*note Bourne Shell Builtins::.)
591 may be used to control loop execution.
594 File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Basic Shell Features
596 Conditional Constructs
597 ======================
600 The syntax of the `if' command is:
602 if TEST-COMMANDS; then
604 [elif MORE-TEST-COMMANDS; then
606 [else ALTERNATE-CONSEQUENTS;]
609 Execute CONSEQUENT-COMMANDS only if the final command in
610 TEST-COMMANDS has an exit status of zero. Otherwise, each `elif'
611 list is executed in turn, and if its exit status is zero, the
612 corresponding MORE-CONSEQUENTS is executed and the command
613 completes. If `else ALTERNATE-CONSEQUENTS' is present, and the
614 final command in the final `if' or `elif' clause has a non-zero
615 exit status, then execute ALTERNATE-CONSEQUENTS.
618 The syntax of the `case' command is:
620 `case WORD in [ ( PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
622 Selectively execute COMMANDS based upon WORD matching PATTERN.
623 The `|' is used to separate multiple patterns.
625 Here is an example using `case' in a script that could be used to
626 describe one interesting feature of an animal:
628 echo -n "Enter the name of an animal: "
630 echo -n "The $ANIMAL has "
632 horse | dog | cat) echo -n "four";;
633 man | kangaroo ) echo -n "two";;
634 *) echo -n "an unknown number of";;
641 The EXPRESSION is evaluated according to the rules described below
642 (*note Arithmetic Evaluation::.). If the value of the expression
643 is non-zero, the return status is 0; otherwise the return status
644 is 1. This is exactly equivalent to
647 The `select' construct, which allows users to choose from a list of
648 items presented as a menu, is also available. *Note Korn Shell
649 Constructs::, for a full description of `select'.
652 File: bashref.info, Node: Command Grouping, Next: Shell Functions, Prev: Conditional Constructs, Up: Basic Shell Features
657 Bash provides two ways to group a list of commands to be executed as
658 a unit. When commands are grouped, redirections may be applied to the
659 entire command list. For example, the output of all the commands in
660 the list may be redirected to a single stream.
665 Placing a list of commands between parentheses causes a subshell
666 to be created, and each of the commands to be executed in that
667 subshell. Since the LIST is executed in a subshell, variable
668 assignments do not remain in effect after the subshell completes.
673 Placing a list of commands between curly braces causes the list to
674 be executed in the current shell context. No subshell is created.
675 The semicolon following LIST is required.
677 In addition to the creation of a subshell, there is a subtle
678 difference between these two constructs due to historical reasons. The
679 braces are `reserved words', so they must be separated from the LIST by
680 `blank's. The parentheses are `operators', and are recognized as
681 separate tokens by the shell even if they are not separated from the
684 The exit status of both of these constructs is the exit status of
688 File: bashref.info, Node: Shell Functions, Next: Shell Parameters, Prev: Command Grouping, Up: Basic Shell Features
693 Shell functions are a way to group commands for later execution
694 using a single name for the group. They are executed just like a
695 "regular" command. Shell functions are executed in the current shell
696 context; no new process is created to interpret them.
698 Functions are declared using this syntax:
699 [ `function' ] NAME () { COMMAND-LIST; }
701 This defines a shell function named NAME. The reserved word
702 `function' is optional. The BODY of the function is the COMMAND-LIST
703 between { and }. This list is executed whenever NAME is specified as
704 the name of a command. The exit status of a function is the exit
705 status of the last command executed in the body.
707 When a function is executed, the arguments to the function become
708 the positional parameters during its execution (*note Positional
709 Parameters::.). The special parameter `#' that expands to the number of
710 positional parameters is updated to reflect the change. Positional
711 parameter `0' is unchanged.
713 If the builtin command `return' is executed in a function, the
714 function completes and execution resumes with the next command after
715 the function call. When a function completes, the values of the
716 positional parameters and the special parameter `#' are restored to the
717 values they had prior to function execution. If a numeric argument is
718 given to `return', that is the function return status.
720 Variables local to the function may be declared with the `local'
721 builtin. These variables are visible only to the function and the
724 Functions may be recursive. No limit is placed on the number of
728 File: bashref.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell Functions, Up: Basic Shell Features
735 * Positional Parameters:: The shell's command-line arguments.
736 * Special Parameters:: Parameters with special meanings.
738 A PARAMETER is an entity that stores values. It can be a `name', a
739 number, or one of the special characters listed below. For the shell's
740 purposes, a VARIABLE is a parameter denoted by a `name'.
742 A parameter is set if it has been assigned a value. The null string
743 is a valid value. Once a variable is set, it may be unset only by using
744 the `unset' builtin command.
746 A variable may be assigned to by a statement of the form
749 If VALUE is not given, the variable is assigned the null string. All
750 VALUEs undergo tilde expansion, parameter and variable expansion,
751 command substitution, arithmetic expansion, and quote removal (detailed
752 below). If the variable has its `-i' attribute set (see the
753 description of the `declare' builtin in *Note Bash Builtins::), then
754 VALUE is subject to arithmetic expansion even if the `$((...))' syntax
755 does not appear (*note Arithmetic Expansion::.). Word splitting is not
756 performed, with the exception of `"$@"' as explained below. Filename
757 expansion is not performed.
760 File: bashref.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters
762 Positional Parameters
763 ---------------------
765 A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
766 other than the single digit `0'. Positional parameters are assigned
767 from the shell's arguments when it is invoked, and may be reassigned
768 using the `set' builtin command. Positional parameters may not be
769 assigned to with assignment statements. The positional parameters are
770 temporarily replaced when a shell function is executed (*note Shell
773 When a positional parameter consisting of more than a single digit
774 is expanded, it must be enclosed in braces.
777 File: bashref.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters
782 The shell treats several parameters specially. These parameters may
783 only be referenced; assignment to them is not allowed.
786 Expands to the positional parameters, starting from one. When the
787 expansion occurs within double quotes, it expands to a single word
788 with the value of each parameter separated by the first character
789 of the `IFS' special variable. That is, `"$*"' is equivalent to
790 `"$1C$2C..."', where C is the first character of the value of the
791 `IFS' variable. If `IFS' is unset, the parameters are separated
792 by spaces. If `IFS' is null, the parameters are joined without
793 intervening separators.
796 Expands to the positional parameters, starting from one. When the
797 expansion occurs within double quotes, each parameter expands as a
798 separate word. That is, `"$@"' is equivalent to `"$1" "$2" ...'.
799 When there are no positional parameters, `"$@"' and `$@' expand to
800 nothing (i.e., they are removed).
803 Expands to the number of positional parameters in decimal.
806 Expands to the exit status of the most recently executed foreground
810 Expands to the current option flags as specified upon invocation,
811 by the `set' builtin command, or those set by the shell itself
812 (such as the `-i' option).
815 Expands to the process ID of the shell. In a `()' subshell, it
816 expands to the process ID of the current shell, not the subshell.
819 Expands to the process ID of the most recently executed background
820 (asynchronous) command.
823 Expands to the name of the shell or shell script. This is set at
824 shell initialization. If Bash is invoked with a file of commands,
825 `$0' is set to the name of that file. If Bash is started with the
826 `-c' option, then `$0' is set to the first argument after the
827 string to be executed, if one is present. Otherwise, it is set to
828 the filename used to invoke Bash, as given by argument zero.
831 At shell startup, set to the absolute filename of the shell or
832 shell script being executed as passed in the argument list.
833 Subsequently, expands to the last argument to the previous command,
834 after expansion. Also set to the full filename of each command
835 executed and placed in the environment exported to that command.
836 When checking mail, this parameter holds the name of the mail file.
839 File: bashref.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features
844 Expansion is performed on the command line after it has been split
845 into `token's. There are seven kinds of expansion performed:
850 * parameter and variable expansion
852 * command substitution
854 * arithmetic expansion
862 * Shell Parameter Expansion:: How Bash expands variables to their values.
863 * Command Substitution:: Using the output of a command as an argument.
864 * Process Substitution:: A way to write and read to and from a
866 * Word Splitting:: How the results of expansion are split into separate
868 * Filename Expansion:: A shorthand for specifying filenames matching patterns.
869 * Quote Removal:: How and when quote characters are removed from
872 Brace expansion, tilde expansion, and arithmetic expansion are
873 described in other sections. For brace expansion, see *Note Brace
874 Expansion::; for tilde expansion, see *Note Tilde Expansion::; and for
875 arithmetic expansion, see *Note Arithmetic Expansion::.
877 The order of expansions is: brace expansion, tilde expansion,
878 parameter, variable, and arithmetic expansion and command substitution
879 (done in a left-to-right fashion), word splitting, and filename
882 On systems that can support it, there is an additional expansion
883 available: PROCESS SUBSTITUTION. This is performed at the same time as
884 parameter, variable, and arithemtic expansion and command substitution.
886 Only brace expansion, word splitting, and filename expansion can
887 change the number of words of the expansion; other expansions expand a
888 single word to a single word. The only exceptions to this are the
889 expansions of `"$@"' (*note Special Parameters::.) and `"${NAME[@]}"'
892 After all expansions, `quote removal' (*note Quote Removal::.) is
896 File: bashref.info, Node: Shell Parameter Expansion, Next: Command Substitution, Up: Shell Expansions
898 Shell Parameter Expansion
899 -------------------------
901 The `$' character introduces parameter expansion, command
902 substitution, or arithmetic expansion. The parameter name or symbol to
903 be expanded may be enclosed in braces, which are optional but serve to
904 protect the variable to be expanded from characters immediately
905 following it which could be interpreted as part of the name.
907 The basic form of parameter expansion is ${PARAMETER}. The value of
908 PARAMETER is substituted. The braces are required when PARAMETER is a
909 positional parameter with more than one digit, or when PARAMETER is
910 followed by a character that is not to be interpreted as part of its
913 If the first character of PARAMETER is an exclamation point, a level
914 of variable indirection is introduced. Bash uses the value of the
915 variable formed from the rest of PARAMETER as the name of the variable;
916 this variable is then expanded and that value is used in the rest of
917 the substitution, rather than the value of PARAMETER itself. This is
918 known as `indirect expansion'.
920 In each of the cases below, WORD is subject to tilde expansion,
921 parameter expansion, command substitution, and arithmetic expansion.
922 When not performing substring expansion, Bash tests for a parameter
923 that is unset or null; omitting the colon results in a test only for a
924 parameter that is unset.
927 If PARAMETER is unset or null, the expansion of WORD is
928 substituted. Otherwise, the value of PARAMETER is substituted.
931 If PARAMETER is unset or null, the expansion of WORD is assigned
932 to PARAMETER. The value of PARAMETER is then substituted.
933 Positional parameters and special parameters may not be assigned
937 If PARAMETER is null or unset, the expansion of WORD (or a message
938 to that effect if WORD is not present) is written to the standard
939 error and the shell, if it is not interactive, exits. Otherwise,
940 the value of PARAMETER is substituted.
943 If PARAMETER is null or unset, nothing is substituted, otherwise
944 the expansion of WORD is substituted.
946 `${PARAMETER:OFFSET}'
947 `${PARAMETER:OFFSET:LENGTH}'
948 Expands to up to LENGTH characters of PARAMETER, starting at
949 OFFSET. If LENGTH is omitted, expands to the substring of
950 PARAMETER, starting at the character specified by OFFSET. LENGTH
951 and OFFSET are arithmetic expressions (*note Arithmetic
952 Evaluation::.). This is referred to as Substring Expansion.
954 LENGTH must evaluate to a number greater than or equal to zero.
955 If OFFSET evaluates to a number less than zero, the value is used
956 as an offset from the end of the value of PARAMETER. If PARAMETER
957 is `@', the result is LENGTH positional parameters beginning at
958 OFFSET. If PARAMETER is an array name indexed by `@' or `*', the
959 result is the LENGTH members of the array beginning with
960 ${PARAMETER[OFFSET]}. Substring indexing is zero-based unless the
961 positional parameters are used, in which case the indexing starts
965 The length in characters of the value of PARAMETER is substituted.
966 If PARAMETER is `*' or `@', the length substituted is the number
967 of positional parameters. If PARAMETER is an array name
968 subscripted by `*' or `@', the length substituted is the number of
969 elements in the array.
973 The WORD is expanded to produce a pattern just as in filename
974 expansion (*note Filename Expansion::.). If the pattern matches
975 the beginning of the value of PARAMETER, then the expansion is the
976 value of PARAMETER with the shortest matching pattern (the `#'
977 case) or the longest matching pattern (the `##' case) deleted. If
978 PARAMETER is `@' or `*', the pattern removal operation is applied
979 to each positional parameter in turn, and the expansion is the
980 resultant list. If PARAMETER is an array variable subscripted with
981 `@' or `*', the pattern removal operation is applied to each
982 member of the array in turn, and the expansion is the resultant
987 The WORD is expanded to produce a pattern just as in filename
988 expansion. If the pattern matches a trailing portion of the value
989 of PARAMETER, then the expansion is the value of PARAMETER with
990 the shortest matching pattern (the `%' case) or the longest
991 matching pattern (the `%%' case) deleted. If PARAMETER is `@' or
992 `*', the pattern removal operation is applied to each positional
993 parameter in turn, and the expansion is the resultant list. If
994 PARAMETER is an array variable subscripted with `@' or `*', the
995 pattern removal operation is applied to each member of the array
996 in turn, and the expansion is the resultant list.
998 `${PARAMETER/PATTERN/STRING}'
999 `${PARAMETER//PATTERN/STRING}'
1000 The PATTERN is expanded to produce a pattern just as in filename
1001 expansion. PARAMETER is expanded and the longest match of PATTERN
1002 against its value is replaced with STRING. In the first form,
1003 only the first match is replaced. The second form causes all
1004 matches of PATTERN to be replaced with STRING. If PATTERN begins
1005 with `#', it must match at the beginning of STRING. If PATTERN
1006 begins with `%', it must match at the end of STRING. If STRING is
1007 null, matches of PATTERN are deleted and the `/' following PATTERN
1008 may be omitted. If PARAMETER is `@' or `*', the substitution
1009 operation is applied to each positional parameter in turn, and the
1010 expansion is the resultant list. If PARAMETER is an array
1011 variable subscripted with `@' or `*', the substitution operation
1012 is applied to each member of the array in turn, and the expansion
1013 is the resultant list.
1016 File: bashref.info, Node: Command Substitution, Next: Process Substitution, Prev: Shell Parameter Expansion, Up: Shell Expansions
1018 Command Substitution
1019 --------------------
1021 Command substitution allows the output of a command to replace the
1022 command name. There are two forms:
1028 Bash performs the expansion by executing COMMAND and replacing the
1029 command substitution with the standard output of the command, with any
1030 trailing newlines deleted.
1032 When the old-style backquote form of substitution is used, backslash
1033 retains its literal meaning except when followed by `$', ``', or `\'.
1034 When using the `$(COMMAND)' form, all characters between the
1035 parentheses make up the command; none are treated specially.
1037 Command substitutions may be nested. To nest when using the old
1038 form, escape the inner backquotes with backslashes.
1040 If the substitution appears within double quotes, word splitting and
1041 filename expansion are not performed on the results.
1044 File: bashref.info, Node: Process Substitution, Next: Word Splitting, Prev: Command Substitution, Up: Shell Expansions
1046 Process Substitution
1047 --------------------
1049 Process substitution is supported on systems that support named
1050 pipes (FIFOs) or the `/dev/fd' method of naming open files. It takes
1057 The process LIST is run with its input or output connected to a FIFO or
1058 some file in `/dev/fd'. The name of this file is passed as an argument
1059 to the current command as the result of the expansion. If the
1060 `>(LIST)' form is used, writing to the file will provide input for
1061 LIST. If the `<(LIST)' form is used, the file passed as an argument
1062 should be read to obtain the output of LIST.
1064 On systems that support it, process substitution is performed
1065 simultaneously with parameter and variable expansion, command
1066 substitution, and arithmetic expansion.
1069 File: bashref.info, Node: Word Splitting, Next: Filename Expansion, Prev: Process Substitution, Up: Shell Expansions
1074 The shell scans the results of parameter expansion, command
1075 substitution, and arithmetic expansion that did not occur within double
1076 quotes for word splitting.
1078 The shell treats each character of `$IFS' as a delimiter, and splits
1079 the results of the other expansions into words on these characters. If
1080 `IFS' is unset, or its value is exactly `<space><tab><newline>', the
1081 default, then any sequence of `IFS' characters serves to delimit words.
1082 If `IFS' has a value other than the default, then sequences of the
1083 whitespace characters `space' and `tab' are ignored at the beginning
1084 and end of the word, as long as the whitespace character is in the
1085 value of `IFS' (an `IFS' whitespace character). Any character in `IFS'
1086 that is not `IFS' whitespace, along with any adjacent `IFS' whitespace
1087 characters, delimits a field. A sequence of `IFS' whitespace
1088 characters is also treated as a delimiter. If the value of `IFS' is
1089 null, no word splitting occurs.
1091 Explicit null arguments (`""' or `''') are retained. Unquoted
1092 implicit null arguments, resulting from the expansion of PARAMETERs
1093 that have no values, are removed. If a parameter with no value is
1094 expanded within double quotes, a null argument results and is retained.
1096 Note that if no expansion occurs, no splitting is performed.
1099 File: bashref.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions
1104 After word splitting, unless the `-f' option has been set (*note The
1105 Set Builtin::.), Bash scans each word for the characters `*', `?', and
1106 `['. If one of these characters appears, then the word is regarded as
1107 a PATTERN, and replaced with an alphabetically sorted list of file
1108 names matching the pattern. If no matching file names are found, and
1109 the shell option `nullglob' is disabled, the word is left unchanged. If
1110 the option is set, and no matches are found, the word is removed. When
1111 a pattern is used for filename generation, the character `.' at the
1112 start of a filename or immediately following a slash must be matched
1113 explicitly, unless the shell option `dotglob' is set. The slash
1114 character must always be matched explicitly. In other cases, the `.'
1115 character is not treated specially. See the description of `shopt' in
1116 *Note Bash Builtins::, for a description of the `nullglob' and
1119 The `GLOBIGNORE' shell variable may be used to restrict the set of
1120 filenames matching a PATTERN. If `GLOBIGNORE' is set, each matching
1121 filename that also matches one of the patterns in `GLOBIGNORE' is
1122 removed from the list of matches. The filenames `.' and `..' are
1123 always ignored, even when `GLOBIGNORE'. is set. However, setting
1124 `GLOBIGNORE' has the effect of enabling the `dotglob' shell option, so
1125 all other filenames beginning with a `.' will match. To get the old
1126 behavior of ignoring filenames beginning with a `.', make `.*' one of
1127 the patterns in `GLOBIGNORE'. The `dotglob' option is disabled when
1128 `GLOBIGNORE' is unset.
1130 The special pattern characters have the following meanings:
1132 Matches any string, including the null string.
1135 Matches any single character.
1138 Matches any one of the enclosed characters. A pair of characters
1139 separated by a minus sign denotes a RANGE; any character lexically
1140 between those two characters, inclusive, is matched. If the first
1141 character following the `[' is a `!' or a `^' then any character
1142 not enclosed is matched. A `-' may be matched by including it as
1143 the first or last character in the set. A `]' may be matched by
1144 including it as the first character in the set.
1147 File: bashref.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Expansions
1152 After the preceding expansions, all unquoted occurrences of the
1153 characters `\', `'', and `"' that did not result from one of the above
1154 expansions are removed.
1157 File: bashref.info, Node: Redirections, Next: Executing Commands, Prev: Shell Expansions, Up: Basic Shell Features
1162 Before a command is executed, its input and output may be REDIRECTED
1163 using a special notation interpreted by the shell. Redirection may
1164 also be used to open and close files for the current shell execution
1165 environment. The following redirection operators may precede or appear
1166 anywhere within a simple command or may follow a command. Redirections
1167 are processed in the order they appear, from left to right.
1169 In the following descriptions, if the file descriptor number is
1170 omitted, and the first character of the redirection operator is `<',
1171 the redirection refers to the standard input (file descriptor 0). If
1172 the first character of the redirection operator is `>', the redirection
1173 refers to the standard output (file descriptor 1).
1175 The word that follows the redirection operator in the following
1176 descriptions is subjected to brace expansion, tilde expansion,
1177 parameter expansion, command substitution, arithmetic expansion, quote
1178 removal, and filename expansion. If it expands to more than one word,
1179 Bash reports an error.
1181 Note that the order of redirections is significant. For example,
1185 directs both standard output and standard error to the file DIRLIST,
1189 directs only the standard output to file DIRLIST, because the standard
1190 error was duplicated as standard output before the standard output was
1191 redirected to DIRLIST.
1196 Redirection of input causes the file whose name results from the
1197 expansion of WORD to be opened for reading on file descriptor `n', or
1198 the standard input (file descriptor 0) if `n' is not specified.
1200 The general format for redirecting input is:
1206 Redirection of output causes the file whose name results from the
1207 expansion of WORD to be opened for writing on file descriptor `n', or
1208 the standard output (file descriptor 1) if `n' is not specified. If
1209 the file does not exist it is created; if it does exist it is truncated
1212 The general format for redirecting output is:
1215 If the redirection operator is `>', and the `-C' option to the `set'
1216 builtin has been enabled, the redirection will fail if the filename
1217 whose name results from the expansion of WORD exists. If the
1218 redirection operator is `>|', then the value of the `-C' option to the
1219 `set' builtin command is not tested, and the redirection is attempted
1220 even if the file named by WORD exists.
1222 Appending Redirected Output
1223 ---------------------------
1225 Redirection of output in this fashion causes the file whose name
1226 results from the expansion of WORD to be opened for appending on file
1227 descriptor `n', or the standard output (file descriptor 1) if `n' is
1228 not specified. If the file does not exist it is created.
1230 The general format for appending output is:
1233 Redirecting Standard Output and Standard Error
1234 ----------------------------------------------
1236 Bash allows both the standard output (file descriptor 1) and the
1237 standard error output (file descriptor 2) to be redirected to the file
1238 whose name is the expansion of WORD with this construct.
1240 There are two formats for redirecting standard output and standard
1247 Of the two forms, the first is preferred. This is semantically
1254 This type of redirection instructs the shell to read input from the
1255 current source until a line containing only WORD (with no trailing
1256 blanks) is seen. All of the lines read up to that point are then used
1257 as the standard input for a command.
1259 The format of here-documents is as follows:
1264 No parameter expansion, command substitution, filename expansion, or
1265 arithmetic expansion is performed on WORD. If any characters in WORD
1266 are quoted, the DELIMITER is the result of quote removal on WORD, and
1267 the lines in the here-document are not expanded. Otherwise, all lines
1268 of the here-document are subjected to parameter expansion, command
1269 substitution, and arithmetic expansion. In the latter case, the pair
1270 `\newline' is ignored, and `\' must be used to quote the characters
1273 If the redirection operator is `<<-', then all leading tab
1274 characters are stripped from input lines and the line containing
1275 DELIMITER. This allows here-documents within shell scripts to be
1276 indented in a natural fashion.
1278 Duplicating File Descriptors
1279 ----------------------------
1281 The redirection operator
1284 is used to duplicate input file descriptors. If WORD expands to one or
1285 more digits, the file descriptor denoted by `n' is made to be a copy of
1286 that file descriptor. If WORD evaluates to `-', file descriptor `n' is
1287 closed. If `n' is not specified, the standard input (file descriptor
1293 is used similarly to duplicate output file descriptors. If `n' is not
1294 specified, the standard output (file descriptor 1) is used. As a
1295 special case, if `n' is omitted, and WORD does not expand to one or
1296 more digits, the standard output and standard error are redirected as
1297 described previously.
1299 Opening File Descriptors for Reading and Writing
1300 ------------------------------------------------
1302 The redirection operator
1305 causes the file whose name is the expansion of WORD to be opened for
1306 both reading and writing on file descriptor `n', or on file descriptor
1307 0 if `n' is not specified. If the file does not exist, it is created.
1310 File: bashref.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features
1317 * Command Search and Execution:: How Bash finds commands and runs them.
1319 * Environment:: The environment given to a command.
1321 * Exit Status:: The status returned by commands and how Bash
1324 * Signals:: What happens when Bash or a command it runs
1328 File: bashref.info, Node: Command Search and Execution, Next: Environment, Up: Executing Commands
1330 Command Search and Execution
1331 ----------------------------
1333 After a command has been split into words, if it results in a simple
1334 command and an optional list of arguments, the following actions are
1337 1. If the command name contains no slashes, the shell attempts to
1338 locate it. If there exists a shell function by that name, that
1339 function is invoked as described above in *Note Shell Functions::.
1341 2. If the name does not match a function, the shell searches for it
1342 in the list of shell builtins. If a match is found, that builtin
1345 3. If the name is neither a shell function nor a builtin, and
1346 contains no slashes, Bash searches each element of `$PATH' for a
1347 directory containing an executable file by that name. Bash uses a
1348 hash table to remember the full filenames of executable files (see
1349 the description of `hash' in *Note Bourne Shell Builtins::) to
1350 avoid multiple `PATH' searches. A full search of the directories
1351 in `$PATH' is performed only if the command is not found in the
1352 hash table. If the search is unsuccessful, the shell prints an
1353 error message and returns a nonzero exit status.
1355 4. If the search is successful, or if the command name contains one
1356 or more slashes, the shell executes the named program. Argument 0
1357 is set to the name given, and the remaining arguments to the
1358 command are set to the arguments supplied, if any.
1360 5. If this execution fails because the file is not in executable
1361 format, and the file is not a directory, it is assumed to be SHELL
1362 SCRIPT (*note Shell Scripts::.).
1365 File: bashref.info, Node: Environment, Next: Exit Status, Prev: Command Search and Execution, Up: Executing Commands
1370 When a program is invoked it is given an array of strings called the
1371 ENVIRONMENT. This is a list of name-value pairs, of the form
1374 Bash allows you to manipulate the environment in several ways. On
1375 invocation, the shell scans its own environment and creates a parameter
1376 for each name found, automatically marking it for EXPORT to child
1377 processes. Executed commands inherit the environment. The `export'
1378 and `declare -x' commands allow parameters and functions to be added to
1379 and deleted from the environment. If the value of a parameter in the
1380 environment is modified, the new value becomes part of the environment,
1381 replacing the old. The environment inherited by any executed command
1382 consists of the shell's initial environment, whose values may be
1383 modified in the shell, less any pairs removed by the `unset' command,
1384 plus any additions via the `export' and `declare -x' commands.
1386 The environment for any simple command or function may be augmented
1387 temporarily by prefixing it with parameter assignments, as described in
1388 *Note Shell Parameters::. These assignment statements affect only the
1389 environment seen by that command.
1391 If the `-k' flag is set (*note The Set Builtin::., then all
1392 parameter assignments are placed in the environment for a command, not
1393 just those that precede the command name.
1395 When Bash invokes an external command, the variable `$_' is set to
1396 the full path name of the command and passed to that command in its
1400 File: bashref.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Executing Commands
1405 For the purposes of the shell, a command which exits with a zero
1406 exit status has succeeded. A non-zero exit status indicates failure.
1407 This seemingly counter-intuitive scheme is used so there is one
1408 well-defined way to indicate success and a variety of ways to indicate
1409 various failure modes. When a command terminates on a fatal signal
1410 whose number is N, Bash uses the value 128+N as the exit status.
1412 If a command is not found, the child process created to execute it
1413 returns a status of 127. If a command is found but is not executable,
1414 the return status is 126.
1416 The exit status is used by the Bash conditional commands (*note
1417 Conditional Constructs::.) and some of the list constructs (*note
1420 All of the Bash builtins return an exit status of zero if they
1421 succeed and a non-zero status on failure, so they may be used by the
1422 conditional and list constructs.
1425 File: bashref.info, Node: Signals, Prev: Exit Status, Up: Executing Commands
1430 When Bash is interactive, it ignores `SIGTERM' (so that `kill 0'
1431 does not kill an interactive shell), and `SIGINT' is caught and handled
1432 (so that the `wait' builtin is interruptible). When Bash receives a
1433 `SIGINT', it breaks out of any executing loops. In all cases, Bash
1434 ignores `SIGQUIT'. If job control is in effect (*note Job Control::.),
1435 Bash ignores `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
1437 Synchronous jobs started by Bash have signals set to the values
1438 inherited by the shell from its parent. When job control is not in
1439 effect, background jobs (commands terminated with `&') ignore `SIGINT'
1440 and `SIGQUIT'. Commands run as a result of command substitution ignore
1441 the keyboard-generated job control signals `SIGTTIN', `SIGTTOU', and
1444 The shell exits by default upon receipt of a `SIGHUP'. Before
1445 exiting, it resends the `SIGHUP' to all jobs, running or stopped. To
1446 prevent the shell from sending the `SIGHUP' signal to a particular job,
1447 remove it from the jobs table with the `disown' builtin (*note Job
1448 Control Builtins::.) or use `disown -h' to mark it to not receive
1452 File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
1457 A shell script is a text file containing shell commands. When such
1458 a file is used as the first non-option argument when invoking Bash, and
1459 neither the `-c' nor `-s' option is supplied (*note Invoking Bash::.),
1460 Bash reads and executes commands from the file, then exits. This mode
1461 of operation creates a non-interactive shell. When Bash runs a shell
1462 script, it sets the special parameter `0' to the name of the file,
1463 rather than the name of the shell, and the positional parameters are
1464 set to the remaining arguments, if any are given. If no additional
1465 arguments are supplied, the positional parameters are unset.
1467 A shell script may be made executable by using the `chmod' command
1468 to turn on the execute bit. When Bash finds such a file while
1469 searching the `$PATH' for a command, it spawns a subshell to execute
1470 it. In other words, executing
1473 is equivalent to executing
1474 bash filename ARGUMENTS
1476 if `filename' is an executable shell script. This subshell
1477 reinitializes itself, so that the effect is as if a new shell had been
1478 invoked to interpret the script.
1480 Most versions of Unix make this a part of the kernel's command
1481 execution mechanism. If the first line of a script begins with the two
1482 characters `#!', the remainder of the line specifies an interpreter for
1483 the program. The arguments to the interpreter consist of a single
1484 optional argument following the interpreter name on the first line of
1485 the script file, followed by the name of the script file, followed by
1486 the rest of the arguments. Bash will perform this action on operating
1487 systems that do not handle it themselves. Note that some older
1488 versions of Unix limit the interpreter name and argument to a maximum
1492 File: bashref.info, Node: Bourne Shell Features, Next: Csh Features, Prev: Basic Shell Features, Up: Top
1494 Bourne Shell Style Features
1495 ***************************
1499 * Bourne Shell Builtins:: Builtin commands inherited from the Bourne
1501 * Bourne Shell Variables:: Variables which Bash uses in the same way
1502 as the Bourne Shell.
1503 * Other Bourne Shell Features:: Addtional aspects of Bash which behave in
1504 the same way as the Bourne Shell.
1506 This section briefly summarizes things which Bash inherits from the
1507 Bourne Shell: builtins, variables, and other features. It also lists
1508 the significant differences between Bash and the Bourne Shell.
1511 File: bashref.info, Node: Bourne Shell Builtins, Next: Bourne Shell Variables, Up: Bourne Shell Features
1513 Bourne Shell Builtins
1514 =====================
1516 The following shell builtin commands are inherited from the Bourne
1517 Shell. These commands are implemented as specified by the POSIX 1003.2
1522 Do nothing beyond expanding ARGUMENTS and performing redirections.
1526 Read and execute commands from the FILENAME argument in the
1527 current shell context.
1531 Exit from a `for', `while', `until', or `select' loop. If N is
1532 supplied, the Nth enclosing loop is exited.
1535 cd [-LP] [DIRECTORY]
1536 Change the current working directory to DIRECTORY. If DIRECTORY
1537 is not given, the value of the `HOME' shell variable is used. If
1538 the shell variable `CDPATH' exists, it is used as a search path.
1539 If DIRECTORY begins with a slash, `CDPATH' is not used. The `-P'
1540 option means to not follow symbolic links; symlinks are followed
1541 by default or with the `-L' option.
1545 Resume the next iteration of an enclosing `for', `while', `until',
1546 or `select' loop. If N is supplied, the execution of the Nth
1547 enclosing loop is resumed.
1551 The arguments are concatenated together into a single command,
1552 which is then read and executed.
1555 exec [-cl] [-a NAME] [COMMAND] [ARGUMENTS]
1556 If COMMAND is supplied, it replaces the shell. If the `-l' option
1557 is supplied, the shell places a dash in the zeroth arg passed to
1558 COMMAND. This is what the `login' program does. The `-c' option
1559 causes COMMAND to be executed with an empty environment. If `-a'
1560 is supplied, the shell passes NAME as the zeroth argument to
1561 COMMAND. If no COMMAND is specified, redirections may be used to
1562 affect the current shell environment.
1566 Exit the shell, returning a status of N to the shell's parent.
1569 export [-fn] [-p] [NAME[=VALUE]]
1570 Mark each NAME to be passed to child processes in the environment.
1571 If the `-f' option is supplied, the NAMEs refer to shell
1572 functions. The `-n' option means to no longer mark each NAME for
1573 export. If no NAMES are supplied, or if the `-p' option is given,
1574 a list of exported names is displayed.
1577 getopts OPTSTRING NAME [ARGS]
1578 `getopts' is used by shell scripts to parse positional parameters.
1579 OPTSTRING contains the option letters to be recognized; if a letter
1580 is followed by a colon, the option is expected to have an
1581 argument, which should be separated from it by white space. Each
1582 time it is invoked, `getopts' places the next option in the shell
1583 variable NAME, initializing NAME if it does not exist, and the
1584 index of the next argument to be processed into the variable
1585 `OPTIND'. `OPTIND' is initialized to 1 each time the shell or a
1586 shell script is invoked. When an option requires an argument,
1587 `getopts' places that argument into the variable `OPTARG'. The
1588 shell does not reset `OPTIND' automatically; it must be manually
1589 reset between multiple calls to `getopts' within the same shell
1590 invocation if a new set of parameters is to be used.
1592 `getopts' can report errors in two ways. If the first character of
1593 OPTSTRING is a colon, SILENT error reporting is used. In normal
1594 operation diagnostic messages are printed when illegal options or
1595 missing option arguments are encountered. If the variable `OPTERR'
1596 is set to 0, no error message will be displayed, even if the first
1597 character of `optstring' is not a colon.
1599 If an illegal option is seen, `getopts' places `?' into NAME and,
1600 if not silent, prints an error message and unsets `OPTARG'. If
1601 `getopts' is silent, the option character found is placed in
1602 `OPTARG' and no diagnostic message is printed.
1604 If a required argument is not found, and `getopts' is not silent,
1605 a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
1606 diagnostic message is printed. If `getopts' is silent, then a
1607 colon (`:') is placed in NAME and `OPTARG' is set to the option
1610 `getopts' normally parses the positional parameters, but if more
1611 arguments are given in ARGS, `getopts' parses those instead.
1614 hash [-r] [-p FILENAME] [NAME]
1615 Remember the full filenames of commands specified as arguments, so
1616 they need not be searched for on subsequent invocations. The
1617 commands are found by searching through the directories listed in
1618 `$PATH'. The `-p' option inhibits the path search, and FILENAME
1619 is used as the location of NAME. The `-r' option causes the shell
1620 to forget all remembered locations. If no arguments are given,
1621 information about remembered commands is printed.
1625 Print the current working directory. If the `-P' option is
1626 supplied, the path printed will not contain symbolic links. If
1627 the `-L' option is supplied, the path printed may contain symbolic
1631 readonly [-apf] [NAME] ...
1632 Mark each NAME as unchangable. The values of these names may not
1633 be changed by subsequent assignment. If the `-f' option is
1634 supplied, each NAME refers to a shell function. The `-a' option
1635 means each NAME refers to an array variable. If no NAME arguments
1636 are given, or if the `-p' option is supplied, a list of all
1637 readonly names is printed.
1641 Cause a shell function to exit with value N. This may also be used
1642 to terminate execution of a script being executed with the `.'
1647 Shift positional parameters to the left by N. The positional
1648 parameters from N+1 ... are renamed to `$1' ... . Parameters
1649 represented by the numbers `$#' to N+1 are unset. N must be a
1650 non-negative number less than or equal to `$#'.
1654 Evaluate a conditional expression (*note Bash Conditional
1659 Print out the user and system times used by the shell and its
1663 trap [-lp] [ARG] [SIGSPEC ...]
1664 The commands in ARG are to be read and executed when the shell
1665 receives signal SIGSPEC. If ARG is absent or equal to `-', all
1666 specified signals are reset to the values they had when the shell
1667 was started. If ARG is the null string, then the signal specified
1668 by each SIGSPEC is ignored by the shell and commands it invokes.
1669 If ARG is `-p', the shell displays the trap commands associated
1670 with each SIGSPEC. If no arguments are supplied, or only `-p' is
1671 given, `trap' prints the list of commands associated with each
1672 signal number. Each SIGSPEC is either a signal name such as
1673 `SIGINT' (with or without the `SIG' prefix) or a signal number.
1674 If a SIGSPEC is `0' or `EXIT', ARG is executed when the shell
1675 exits. If a SIGSPEC is `DEBUG', the command ARG is executed after
1676 every simple command. The `-l' option causes the shell to print a
1677 list of signal names and their corresponding numbers.
1679 Signals ignored upon entry to the shell cannot be trapped or reset.
1680 Trapped signals are reset to their original values in a child
1681 process when it is created.
1685 Set the shell process's file creation mask to MODE. If MODE
1686 begins with a digit, it is interpreted as an octal number; if not,
1687 it is interpreted as a symbolic mode mask similar to that accepted
1688 by the `chmod' command. If MODE is omitted, the current value of
1689 the mask is printed. If the `-S' option is supplied without a
1690 MODE argument, the mask is printed in a symbolic format.
1694 Each variable or function NAME is removed. If no options are
1695 supplied, or the `-v' option is given, each NAME refers to a shell
1696 variable. If the `-f' option is given, the NAMEs refer to shell
1697 functions, and the function definition is removed. Read-only
1698 variables and functions may not be unset.
1701 File: bashref.info, Node: Bourne Shell Variables, Next: Other Bourne Shell Features, Prev: Bourne Shell Builtins, Up: Bourne Shell Features
1703 Bourne Shell Variables
1704 ======================
1706 Bash uses certain shell variables in the same way as the Bourne
1707 shell. In some cases, Bash assigns a default value to the variable.
1710 A list of characters that separate fields; used when the shell
1711 splits words as part of expansion.
1714 A colon-separated list of directories in which the shell looks for
1718 The current user's home directory; the default for the `cd' builtin
1722 A colon-separated list of directories used as a search path for
1726 A colon-separated list of files which the shell periodically checks
1727 for new mail. You can also specify what message is printed by
1728 separating the file name from the message with a `?'. When used
1729 in the text of the message, `$_' stands for the name of the
1733 If this parameter is set to a filename and the `MAILPATH' variable
1734 is not set, Bash informs the user of the arrival of mail in the
1738 The primary prompt string. The default value is `\s-\v\$ '.
1741 The secondary prompt string. The default value is `> '.
1744 The index of the last option processed by the `getopts' builtin.
1747 The value of the last option argument processed by the `getopts'
1751 File: bashref.info, Node: Other Bourne Shell Features, Prev: Bourne Shell Variables, Up: Bourne Shell Features
1753 Other Bourne Shell Features
1754 ===========================
1758 * Major Differences From The Bourne Shell:: Major differences between
1759 Bash and the Bourne shell.
1761 Bash implements essentially the same grammar, parameter and variable
1762 expansion, redirection, and quoting as the Bourne Shell. Bash uses the
1763 POSIX 1003.2 standard as the specification of how these features are to
1764 be implemented. There are some differences between the traditional
1765 Bourne shell and the POSIX standard; this section quickly details the
1766 differences of significance. A number of these differences are
1767 explained in greater depth in subsequent sections.
1770 File: bashref.info, Node: Major Differences From The Bourne Shell, Up: Other Bourne Shell Features
1772 Major Differences From The SVR4.2 Bourne Shell
1773 ----------------------------------------------
1775 Bash is POSIX-conformant, even where the POSIX specification differs
1776 from traditional `sh' behavior.
1778 Bash has multi-character invocation options (*note Invoking Bash::.).
1780 Bash has command-line editing (*note Command Line Editing::.) and
1783 Bash has command history (*note Bash History Facilities::.) and the
1784 `history' and `fc' builtins to manipulate it.
1786 Bash implements `csh'-like history expansion (*note History
1789 Bash has one-dimensional array variables (*note Arrays::.), and the
1790 appropriate variable expansions and assignment syntax to use them.
1791 Some of the Bash builtins take options to act on arrays. Bash provides
1792 some built-in array variables.
1794 Bash implements the `!' keyword to negate the return value of a
1795 pipeline (*note Pipelines::.). Very useful when an `if' statement
1796 needs to act only if a test fails.
1798 Bash includes the `select' compound command, which allows the
1799 generation of simple menus (*note Korn Shell Constructs::.).
1801 Bash includes brace expansion (*note Brace Expansion::.) and tilde
1802 expansion (*note Tilde Expansion::.).
1804 Bash implements command aliases and the `alias' and `unalias'
1805 builtins (*note Aliases::.).
1807 Bash provides shell arithmetic and arithmetic expansion (*note Shell
1810 The POSIX and `ksh'-style `$()' form of command substitution is
1811 implemented (*note Command Substitution::.), and preferred to the
1812 Bourne shell's ```' (which is also implemented for backwards
1815 Variables present in the shell's initial environment are
1816 automatically exported to child processes. The Bourne shell does not
1817 normally do this unless the variables are explicitly marked using the
1820 Bash includes the POSIX and `ksh'-style pattern removal `%', `#',
1821 `%%' and `##' constructs to remove leading or trailing substrings from
1822 variable values (*note Shell Parameter Expansion::.).
1824 The expansion `${#xx}', which returns the length of `$xx', is
1825 supported (*note Shell Parameter Expansion::.).
1827 The `$'...'' quoting syntax, which expands ANSI-C backslash-escaped
1828 characters in the text between the single quotes, is supported (*note
1831 Bash supports the `$"..."' quoting syntax to do locale-specific
1832 translation of the characters between the double quotes. The `-D' and
1833 `--dump-strings' invocation options list the translatable strings found
1834 in a script (*note Locale Translation::.).
1836 The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
1837 substring of `var''s value of length LENGTH, optionally beginning at
1838 OFFSET, is present (*note Shell Parameter Expansion::.).
1840 The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
1841 PATTERN and replaces it with REPLACEMENT in the value of `var', is
1842 available (*note Shell Parameter Expansion::.).
1844 Bash has INDIRECT variable expansion using `${!word}' (*note Shell
1845 Parameter Expansion::.).
1847 Bash can expand positional parameters beyond `$9' using `${NUM}'.
1849 Bash has process substitution (*note Process Substitution::.).
1851 Bash automatically assigns variables that provide information about
1852 the current user (`UID', `EUID', and `GROUPS'), the current host
1853 (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the instance of
1854 Bash that is running (`BASH', `BASH_VERSION', and `BASH_VERSINFO'.
1855 *Note Bash Variables::, for details.
1857 The `IFS' variable is used to split only the results of expansion,
1858 not all words (*note Word Splitting::.). This closes a longstanding
1859 shell security hole.
1861 It is possible to have a variable and a function with the same name;
1862 `sh' does not separate the two name spaces.
1864 Bash functions are permitted to have local variables using the
1865 `local' builtin, and thus useful recursive functions may be written.
1867 Variable assignments preceding commands affect only that command,
1868 even builtins and functions (*note Environment::.). In `sh', all
1869 variable assignments preceding commands are global unless the command
1870 is executed from the file system.
1872 Bash performs filename expansion on filenames specified as operands
1873 to output redirection operators.
1875 Bash contains the `<>' redirection operator, allowing a file to be
1876 opened for both reading and writing, and the `&>' redirection operator,
1877 for directing standard output and standard error to the same file
1878 (*note Redirections::.).
1880 The `noclobber' option is available to avoid overwriting existing
1881 files with output redirection (*note The Set Builtin::.). The `>|'
1882 redirection operator may be used to override `noclobber'.
1884 Bash interprets special backslash-escaped characters in the prompt
1885 strings when interactive (*note Printing a Prompt::.).
1887 Bash allows you to write a function to override a builtin, and
1888 provides access to that builtin's functionality within the function via
1889 the `builtin' and `command' builtins (*note Bash Builtins::.).
1891 The `command' builtin allows selective disabling of functions when
1892 command lookup is performed (*note Bash Builtins::.).
1894 Individual builtins may be enabled or disabled using the `enable'
1895 builtin (*note Bash Builtins::.).
1897 The Bash `hash' builtin allows a name to be associated with an
1898 arbitrary filename, even when that filename cannot be found by
1899 searching the `$PATH', using `hash -p'.
1901 Shell functions may be exported to children via the environment
1902 (*note Shell Functions::.).
1904 Bash includes a `help' builtin for quick reference to shell
1905 facilities (*note Bash Builtins::.).
1907 The Bash `read' builtin (*note Bash Builtins::.) will read a line
1908 ending in `\' with the `-r' option, and will use the `REPLY' variable
1909 as a default if no arguments are supplied. The Bash `read' builtin
1910 also accepts a prompt string with the `-p' option and will use Readline
1911 to obtain the line when given the `-e' option.
1913 Bash includes the `shopt' builtin, for finer control of shell
1914 optional capabilities (*note Bash Builtins::.).
1916 Bash has much more optional behavior controllable with the `set'
1917 builtin (*note The Set Builtin::.).
1919 The `disown' builtin can remove a job from the internal shell job
1920 table (*note Job Control Builtins::.).
1922 The `return' builtin may be used to abort execution of scripts
1923 executed with the `.' or `source' builtins (*note Bourne Shell
1926 The `test' builtin (*note Bourne Shell Builtins::.) is slightly
1927 different, as it implements the POSIX 1003.2 algorithm, which specifies
1928 the behavior based on the number of arguments.
1930 The `trap' builtin (*note Bourne Shell Builtins::.) allows a `DEBUG'
1931 pseudo-signal specification, similar to `EXIT'. Commands specified
1932 with a `DEBUG' trap are executed after every simple command. The
1933 `DEBUG' trap is not inherited by shell functions.
1935 The Bash `export', `readonly', and `declare' builtins can take a
1936 `-f' option to act on shell functions, a `-p' option to display
1937 variables with various attributes set in a format that can be used as
1938 shell input, a `-n' option to remove various variable attributes, and
1939 `name=value' arguments to set variable attributes and values
1942 The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::.)
1943 each take `-L' and `-P' builtins to switch between logical and physical
1946 The Bash `type' builtin is more extensive and gives more information
1947 about the names it finds (*note Bash Builtins::.).
1949 Bash implements a `csh'-like directory stack, and provides the
1950 `pushd', `popd', and `dirs' builtins to manipulate it (*note C Shell
1951 Builtins::.). Bash also makes the directory stack visible as the value
1952 of the `DIRSTACK' shell variable.
1954 The Bash restricted mode is more useful (*note The Restricted
1955 Shell::.); the SVR4.2 shell restricted mode is too limited.
1957 Bash has the `time' reserved word and command timing (*note
1958 Pipelines::.). The display of the timing statistics may be controlled
1959 with the `TIMEFORMAT' variable.
1961 The SVR4.2 shell has two privilege-related builtins (`mldmode' and
1962 `priv') not present in Bash.
1964 Bash does not have the `stop' or `newgrp' builtins.
1966 Bash does not use the `SHACCT' variable or perform shell accounting.
1968 The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
1970 More features unique to Bash may be found in *Note Bash Features::.
1972 Implementation Differences From The SVR4.2 Shell
1973 ------------------------------------------------
1975 Since Bash is a completely new implementation, it does not suffer
1976 from many of the limitations of the SVR4.2 shell. For instance:
1978 * Bash does not fork a subshell when redirecting into or out of a
1979 shell control structure such as an `if' or `while' statement.
1981 * Bash does not allow unbalanced quotes. The SVR4.2 shell will
1982 silently insert a needed closing quote at `EOF' under certain
1983 circumstances. This can be the cause of some hard-to-find errors.
1985 * The SVR4.2 shell uses a baroque memory management scheme based on
1986 trapping `SIGSEGV'. If the shell is started from a process with
1987 `SIGSEGV' blocked (e.g., by using the `system()' C library
1988 function call), the shell misbehaves badly.
1990 * In a questionable attempt at security, the SVR4.2 shell, when
1991 invoked without the `-p' option, will alter its real and effective
1992 UID and GID if they are less than some magic threshold value,
1993 commonly 100. This can lead to unexpected results.
1995 * The SVR4.2 shell does not allow users to trap `SIGALRM' or
1998 * For some reason, the SVR4.2 shell does not allow the `MAILCHECK'
1999 variable to be unset.
2001 * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
2003 * Bash allows multiple option arguments when it is invoked (`-x -v');
2004 the SVR4.2 shell allows only one option argument (`-xv'). In
2005 fact, some versions of the shell dump core if the second argument
2008 * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
2009 script only if one of the POSIX.2 special builtins fails, and only
2010 for certain failures, as enumerated in the POSIX.2 standard.
2012 * The SVR4.2 shell behaves differently when invoked as `jsh' (it
2013 turns on job control).
2016 File: bashref.info, Node: Csh Features, Next: Korn Shell Features, Prev: Bourne Shell Features, Up: Top
2018 C-Shell Style Features
2019 **********************
2021 The C-Shell ("`csh'") was created by Bill Joy at The University of
2022 California at Berkeley. It is generally considered to have better
2023 features for interactive use than the original Bourne shell. Some of
2024 the `csh' features present in Bash include job control, history
2025 expansion, `protected' redirection, and several variables to control
2026 the interactive behaviour of the shell (e.g., `IGNOREEOF').
2028 *Note Using History Interactively::, for details on history
2033 * Brace Expansion:: Expansion of expressions within braces.
2034 * Tilde Expansion:: Expansion of the ~ character.
2035 * C Shell Builtins:: Builtin commands adopted from the C Shell.
2036 * C Shell Variables:: Variables which Bash uses in essentially
2037 the same way as the C Shell.
2040 File: bashref.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Csh Features
2045 Brace expansion is a mechanism by which arbitrary strings may be
2046 generated. This mechanism is similar to FILENAME EXPANSION (*note
2047 Filename Expansion::.), but the file names generated need not exist.
2048 Patterns to be brace expanded take the form of an optional PREAMBLE,
2049 followed by a series of comma-separated strings between a pair of
2050 braces, followed by an optional POSTAMBLE. The preamble is prepended
2051 to each string contained within the braces, and the postamble is then
2052 appended to each resulting string, expanding left to right.
2054 Brace expansions may be nested. The results of each expanded string
2055 are not sorted; left to right order is preserved. For example,
2056 bash$ echo a{d,c,b}e
2059 Brace expansion is performed before any other expansions, and any
2060 characters special to other expansions are preserved in the result. It
2061 is strictly textual. Bash does not apply any syntactic interpretation
2062 to the context of the expansion or the text between the braces.
2064 A correctly-formed brace expansion must contain unquoted opening and
2065 closing braces, and at least one unquoted comma. Any incorrectly
2066 formed brace expansion is left unchanged.
2068 This construct is typically used as shorthand when the common prefix
2069 of the strings to be generated is longer than in the above example:
2070 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2072 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2075 File: bashref.info, Node: Tilde Expansion, Next: C Shell Builtins, Prev: Brace Expansion, Up: Csh Features
2080 Bash has tilde (~) expansion, similar, but not identical, to that of
2081 `csh'. The following table shows what unquoted words beginning with a
2085 The current value of `$HOME'.
2091 The subdirectory `foo' of the home directory of the user `fred'.
2099 Bash will also tilde expand words following redirection operators
2100 and words following `=' in assignment statements.
2103 File: bashref.info, Node: C Shell Builtins, Next: C Shell Variables, Prev: Tilde Expansion, Up: Csh Features
2108 Bash has several builtin commands whose definition is very similar
2112 pushd [DIR | +N | -N] [-n]
2114 Save the current directory on a list and then `cd' to DIR. With no
2115 arguments, exchanges the top two directories.
2118 Brings the Nth directory (counting from the left of the list
2119 printed by `dirs', starting with zero) to the top of the list
2120 by rotating the stack.
2123 Brings the Nth directory (counting from the right of the list
2124 printed by `dirs', starting with zero) to the top of the list
2125 by rotating the stack.
2128 Suppresses the normal change of directory when adding
2129 directories to the stack, so that only the stack is
2133 Makes the current working directory be the top of the stack,
2134 and then `cd's to DIR. You can see the saved directory list
2135 with the `dirs' command.
2140 Pop the directory stack, and `cd' to the new top directory. When
2141 no arguments are given, `popd' removes the top directory from the
2142 stack and performs a `cd' to the new top directory. The elements
2143 are numbered from 0 starting at the first directory listed with
2144 `dirs'; i.e., `popd' is equivalent to `popd +0'.
2146 Removes the Nth directory (counting from the left of the list
2147 printed by `dirs'), starting with zero.
2150 Removes the Nth directory (counting from the right of the
2151 list printed by `dirs'), starting with zero.
2154 Suppresses the normal change of directory when removing
2155 directories from the stack, so that only the stack is
2159 dirs [+N | -N] [-clvp]
2160 Display the list of currently remembered directories. Directories
2161 find their way onto the list with the `pushd' command; you can get
2162 back up through the list with the `popd' command.
2164 Displays the Nth directory (counting from the left of the
2165 list printed by `dirs' when invoked without options), starting
2169 Displays the Nth directory (counting from the right of the
2170 list printed by `dirs' when invoked without options), starting
2174 Clears the directory stack by deleting all of the elements.
2177 Produces a longer listing; the default listing format uses a
2178 tilde to denote the home directory.
2181 Causes `dirs' to print the directory stack with one entry per
2185 Causes `dirs' to print the directory stack with one entry per
2186 line, prepending each entry with its index in the stack.
2190 history [-anrw] [FILENAME]
2193 Display the history list with line numbers. Lines prefixed with
2194 with a `*' have been modified. An argument of N says to list only
2195 the last N lines. Options, if supplied, have the following
2199 Write out the current history to the history file.
2202 Read the current history file and append its contents to the
2206 Append the new history lines (history lines entered since the
2207 beginning of the current Bash session) to the history file.
2210 Append the history lines not already read from the history
2211 file to the current history list. These are lines appended
2212 to the history file since the beginning of the current Bash
2216 Clear the history list. This may be combined with the other
2217 options to replace the history list completely.
2220 The ARGs are added to the end of the history list as a single
2224 Perform history substitution on the ARGs and display the
2225 result on the standard output, without storing the results in
2228 When the `-w', `-r', `-a', or `-n' option is used, if FILENAME is
2229 given, then it is used as the history file. If not, then the
2230 value of the `HISTFILE' variable is used.
2236 A synonym for `.' (*note Bourne Shell Builtins::.).
2239 File: bashref.info, Node: C Shell Variables, Prev: C Shell Builtins, Up: Csh Features
2245 If this variable is set, its value is used the number of
2246 consecutive `EOF's Bash will read before exiting. By default,
2247 Bash will exit upon reading a single `EOF'. If `IGNOREEOF' is not
2248 set to a numeric value, Bash acts as if its value were 10.
2251 File: bashref.info, Node: Korn Shell Features, Next: Bash Features, Prev: Csh Features, Up: Top
2253 Korn Shell Style Features
2254 *************************
2256 This section describes features primarily inspired by the Korn Shell
2257 (`ksh'). In some cases, the POSIX 1003.2 standard has adopted these
2258 commands and variables from the Korn Shell; Bash implements those
2259 features using the POSIX standard as a guide.
2263 * Korn Shell Constructs:: Shell grammar constructs adopted from the
2265 * Korn Shell Builtins:: Builtin commands adopted from the Korn Shell.
2266 * Korn Shell Variables:: Variables which Bash uses in essentially
2267 the same way as the Korn Shell.
2268 * Aliases:: Substituting one command for another.
2271 File: bashref.info, Node: Korn Shell Constructs, Next: Korn Shell Builtins, Up: Korn Shell Features
2273 Korn Shell Constructs
2274 =====================
2276 Bash includes the Korn Shell `select' construct. This construct
2277 allows the easy generation of menus. It has almost the same syntax as
2280 The syntax of the `select' command is:
2281 select NAME [in WORDS ...]; do COMMANDS; done
2283 The list of words following `in' is expanded, generating a list of
2284 items. The set of expanded words is printed on the standard error,
2285 each preceded by a number. If the `in WORDS' is omitted, the
2286 positional parameters are printed. The `PS3' prompt is then displayed
2287 and a line is read from the standard input. If the line consists of a
2288 number corresponding to one of the displayed words, then the value of
2289 NAME is set to that word. If the line is empty, the words and prompt
2290 are displayed again. If `EOF' is read, the `select' command completes.
2291 Any other value read causes NAME to be set to null. The line read is
2292 saved in the variable `REPLY'.
2294 The COMMANDS are executed after each selection until a `break' or
2295 `return' command is executed, at which point the `select' command
2298 Bash also has adopted command timing from the Korn shell. If the
2299 `time' reserved word precedes a pipeline, which may consist of a single
2300 command, timing statistics for the pipeline are displayed when it
2301 completes. The statistics currently consist of elapsed (wall-clock)
2302 time and user and system time consumed by the command's execution.
2304 The use of `time' as a reserved word permits the timing of shell
2305 builtins, shell functions, and pipelines. An external `time' command
2306 cannot time these easily.
2309 File: bashref.info, Node: Korn Shell Builtins, Next: Korn Shell Variables, Prev: Korn Shell Constructs, Up: Korn Shell Features
2314 This section describes Bash builtin commands taken from `ksh'.
2317 `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
2318 `fc -s [PAT=REP] [COMMAND]'
2320 Fix Command. In the first form, a range of commands from FIRST to
2321 LAST is selected from the history list. Both FIRST and LAST may
2322 be specified as a string (to locate the most recent command
2323 beginning with that string) or as a number (an index into the
2324 history list, where a negative number is used as an offset from the
2325 current command number). If LAST is not specified it is set to
2326 FIRST. If FIRST is not specified it is set to the previous
2327 command for editing and -16 for listing. If the `-l' flag is
2328 given, the commands are listed on standard output. The `-n' flag
2329 suppresses the command numbers when listing. The `-r' flag
2330 reverses the order of the listing. Otherwise, the editor given by
2331 ENAME is invoked on a file containing those commands. If ENAME is
2332 not given, the value of the following variable expansion is used:
2333 `${FCEDIT:-${EDITOR:-vi}}'. This says to use the value of the
2334 `FCEDIT' variable if set, or the value of the `EDITOR' variable if
2335 that is set, or `vi' if neither is set. When editing is complete,
2336 the edited commands are echoed and executed.
2338 In the second form, COMMAND is re-executed after each instance of
2339 PAT in the selected command is replaced by REP.
2341 A useful alias to use with the `fc' command is `r='fc -s'', so
2342 that typing `r cc' runs the last command beginning with `cc' and
2343 typing `r' re-executes the last command (*note Aliases::.).
2346 The `let' builtin allows arithmetic to be performed on shell
2347 variables. For details, refer to *Note Arithmetic Builtins::.
2350 The `typeset' command is supplied for compatibility with the Korn
2351 shell; however, it has been deprecated in favor of the `declare'
2352 command (*note Bash Builtins::.).
2355 File: bashref.info, Node: Korn Shell Variables, Next: Aliases, Prev: Korn Shell Builtins, Up: Korn Shell Features
2357 Korn Shell Variables
2358 ====================
2361 The default variable for the `read' builtin.
2364 Each time this parameter is referenced, a random integer between 0
2365 and 32767 is generated. Assigning a value to this variable seeds
2366 the random number generator.
2369 This variable expands to the number of seconds since the shell was
2370 started. Assignment to this variable resets the count to the
2371 value assigned, and the expanded value becomes the value assigned
2372 plus the number of seconds since the assignment.
2375 The value of this variable is used as the prompt for the `select'
2376 command. If this variable is not set, the `select' command
2380 This is the prompt printed before the command line is echoed when
2381 the `-x' option is set (*note The Set Builtin::.). The default is
2385 The current working directory as set by the `cd' builtin.
2388 The previous working directory as set by the `cd' builtin.
2391 If set to a value greater than zero, the value is interpreted as
2392 the number of seconds to wait for input after issuing the primary
2393 prompt. Bash terminates after that number of seconds if input does
2397 The line number in the script or shell function currently
2401 The editor used as a default by the `fc' builtin command.
2404 File: bashref.info, Node: Aliases, Prev: Korn Shell Variables, Up: Korn Shell Features
2411 * Alias Builtins:: Builtins commands to maniuplate aliases.
2413 The shell maintains a list of ALIASES that may be set and unset with
2414 the `alias' and `unalias' builtin commands.
2416 The first word of each command, if unquoted, is checked to see if it
2417 has an alias. If so, that word is replaced by the text of the alias.
2418 The alias name and the replacement text may contain any valid shell
2419 input, including shell metacharacters, with the exception that the
2420 alias name may not contain <=>. The first word of the replacement text
2421 is tested for aliases, but a word that is identical to an alias being
2422 expanded is not expanded a second time. This means that one may alias
2423 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
2424 expand the replacement text. If the last character of the alias value
2425 is a space or tab character, then the next command word following the
2426 alias is also checked for alias expansion.
2428 Aliases are created and listed with the `alias' command, and removed
2429 with the `unalias' command.
2431 There is no mechanism for using arguments in the replacement text,
2432 as in `csh'. If arguments are needed, a shell function should be used
2433 (*note Shell Functions::.).
2435 Aliases are not expanded when the shell is not interactive, unless
2436 the `expand_aliases' shell option is set using `shopt' (*note Bash
2439 The rules concerning the definition and use of aliases are somewhat
2440 confusing. Bash always reads at least one complete line of input
2441 before executing any of the commands on that line. Aliases are
2442 expanded when a command is read, not when it is executed. Therefore, an
2443 alias definition appearing on the same line as another command does not
2444 take effect until the next line of input is read. The commands
2445 following the alias definition on that line are not affected by the new
2446 alias. This behavior is also an issue when functions are executed.
2447 Aliases are expanded when the function definition is read, not when the
2448 function is executed, because a function definition is itself a
2449 compound command. As a consequence, aliases defined in a function are
2450 not available until after that function is executed. To be safe,
2451 always put alias definitions on a separate line, and do not use `alias'
2452 in compound commands.
2454 Note that for almost every purpose, aliases are superseded by shell
2458 File: bashref.info, Node: Alias Builtins, Up: Aliases
2464 alias [`-p'] [NAME[=VALUE] ...]
2466 Without arguments or with the `-p' option, `alias' prints the list
2467 of aliases on the standard output in a form that allows them to be
2468 reused as input. If arguments are supplied, an alias is defined
2469 for each NAME whose VALUE is given. If no VALUE is given, the name
2470 and value of the alias is printed.
2473 unalias [-a] [NAME ... ]
2475 Remove each NAME from the list of aliases. If `-a' is supplied,
2476 all aliases are removed.
2479 File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Korn Shell Features, Up: Top
2484 This section describes features unique to Bash.
2488 * Invoking Bash:: Command line options that you can give
2490 * Bash Startup Files:: When and how Bash executes scripts.
2491 * Is This Shell Interactive?:: Determining the state of a running Bash.
2492 * Bash Builtins:: Table of builtins specific to Bash.
2493 * The Set Builtin:: This builtin is so overloaded it
2494 deserves its own section.
2495 * Bash Conditional Expressions:: Primitives used in composing expressions for
2497 * Bash Variables:: List of variables that exist in Bash.
2498 * Shell Arithmetic:: Arithmetic on shell variables.
2499 * Arrays:: Array Variables
2500 * Printing a Prompt:: Controlling the PS1 string.
2501 * The Restricted Shell:: A more controlled mode of shell execution.
2502 * Bash POSIX Mode:: Making Bash behave more closely to what
2503 the POSIX standard specifies.
2506 File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
2511 bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2512 bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] -c STRING [ARGUMENT ...]
2513 bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2515 In addition to the single-character shell command-line options
2516 (*note The Set Builtin::.), there are several multi-character options
2517 that you can use. These options must appear on the command line before
2518 the single-character options in order for them to be recognized.
2524 Display a usage message on standard output and exit sucessfully.
2527 Make this shell act as if it were directly invoked by login. This
2528 is equivalent to `exec -l bash' but can be issued from another
2529 shell, such as `csh'. If you wanted to replace your current login
2530 shell with a Bash login shell, you would say `exec bash --login'.
2533 Do not use the GNU Readline library (*note Command Line Editing::.)
2534 to read interactive command lines.
2537 Don't load the system-wide startup file `/etc/profile' or any of
2538 the personal initialization files `~/.bash_profile',
2539 `~/.bash_login', or `~/.profile' when Bash is invoked as a login
2543 Don't read the `~/.bashrc' initialization file in an interactive
2544 shell. This is on by default if the shell is invoked as `sh'.
2547 Change the behavior of Bash where the default operation differs
2548 from the POSIX 1003.2 standard to match the standard. This is
2549 intended to make Bash behave as a strict superset of that
2550 standard. *Note Bash POSIX Mode::, for a description of the Bash
2554 Execute commands from FILENAME (instead of `~/.bashrc') in an
2558 Make the shell a restricted shell (*note The Restricted Shell::.).
2564 Show version information for this instance of Bash on the standard
2565 output and exit successfully.
2567 There are several single-character options you can give which are
2568 not available with the `set' builtin.
2571 Read and execute commands from STRING after processing the
2572 options, then exit. Any remaining arguments are assigned to the
2573 positional parameters, starting with `$0'.
2576 Force the shell to run interactively.
2579 Make the shell restricted.
2582 If this flag is present, or if no arguments remain after option
2583 processing, then commands are read from the standard input. This
2584 option allows the positional parameters to be set when invoking an
2588 A list of all double-quoted strings preceded by `$' is printed on
2589 the standard ouput. These are the strings that are subject to
2590 language translation when the current locale is not `C' or `POSIX'
2591 (*note Locale Translation::.). This implies the `-n' option; no
2592 commands will be executed.
2594 An *interactive* shell is one whose input and output are both
2595 connected to terminals (as determined by `isatty()'), or one started
2596 with the `-i' option.
2598 If arguments remain after option processing, and neither the `-c'
2599 nor the `-s' option has been supplied, the first argument is assumed to
2600 be the name of a file containing shell commands (*note Shell
2601 Scripts::.). When Bash is invoked in this fashion, `$0' is set to the
2602 name of the file, and the positional parameters are set to the
2603 remaining arguments. Bash reads and executes commands from this file,
2604 then exits. Bash's exit status is the exit status of the last command
2605 executed in the script. If no commands are executed, the exit status
2609 File: bashref.info, Node: Bash Startup Files, Next: Is This Shell Interactive?, Prev: Invoking Bash, Up: Bash Features
2614 This section describs how Bash executes its startup files. If any
2615 of the files exist but cannot be read, Bash reports an error. Tildes
2616 are expanded in file names as described above under Tilde Expansion
2617 (*note Tilde Expansion::.).
2619 When Bash is invoked as an interactive login shell, it first reads
2620 and executes commands from the file `/etc/profile', if that file exists.
2621 After reading that file, it looks for `~/.bash_profile',
2622 `~/.bash_login', and `~/.profile', in that order, and reads and
2623 executes commands from the first one that exists and is readable. The
2624 `--noprofile' option may be used when the shell is started to inhibit
2627 When a login shell exits, Bash reads and executes commands from the
2628 file `~/.bash_logout', if it exists.
2630 When an interactive shell that is not a login shell is started, Bash
2631 reads and executes commands from `~/.bashrc', if that file exists.
2632 This may be inhibited by using the `--norc' option. The `--rcfile
2633 FILE' option will force Bash to read and execute commands from FILE
2634 instead of `~/.bashrc'.
2636 So, typically, your `~/.bash_profile' contains the line
2637 `if [ -f `~/.bashrc' ]; then . `~/.bashrc'; fi'
2639 after (or before) any login-specific initializations.
2641 When Bash is started non-interactively, to run a shell script, for
2642 example, it looks for the variable `BASH_ENV' in the environment,
2643 expands its value if it appears there, and uses the expanded value as
2644 the name of a file to read and execute. Bash behaves as if the
2645 following command were executed:
2646 `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
2648 but the value of the `PATH' variable is not used to search for the file
2651 If Bash is invoked with the name `sh', it tries to mimic the startup
2652 behavior of historical versions of `sh' as closely as possible, while
2653 conforming to the POSIX standard as well.
2655 When invoked as a login shell, it first attempts to read and execute
2656 commands from `/etc/profile' and `~/.profile', in that order. The
2657 `--noprofile' option may be used to inhibit this behavior. When
2658 invoked as an interactive shell with the name `sh', `bash' looks for
2659 the variable `ENV', expands its value if it is defined, and uses the
2660 expanded value as the name of a file to read and execute. Since a
2661 shell invoked as `sh' does not attempt to read and execute commands
2662 from any other startup files, the `--rcfile' option has no effect. A
2663 non-interactive shell invoked with the name `sh' does not attempt to
2664 read any startup files.
2666 When invoked as `sh', Bash enters POSIX mode after the startup files
2669 When Bash is started in POSIX mode, as with the `--posix' command
2670 line option, it follows the POSIX standard for startup files. In this
2671 mode, the `ENV' variable is expanded and commands are read and executed
2672 from the file whose name is the expanded value. No other startup files
2673 are read. This is done by interactive shells only.
2675 Bash attempts to determine when it is being run by the remote shell
2676 daemon, usually `rshd'. If Bash determines it is being run by rshd, it
2677 reads and executes commands from `~/.bashrc', if that file exists and
2678 is readable. It will not do this if invoked as `sh'. The `--norc'
2679 option may be used to inhibit this behavior, and the `--rcfile' option
2680 may be used to force another file to be read, but rshd does not
2681 generally invoke the shell with those options or allow them to be
2685 File: bashref.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Features
2687 Is This Shell Interactive?
2688 ==========================
2690 As defined in *Note Invoking Bash::, an interactive shell is one
2691 whose input and output are both connected to terminals (as determined
2692 by `isatty(3)'), or one started with the `-i' option.
2694 You may wish to determine within a startup script whether Bash is
2695 running interactively or not. To do this, examine the variable `$PS1';
2696 it is unset in non-interactive shells, and set in interactive shells.
2699 if [ -z "$PS1" ]; then
2700 echo This shell is not interactive
2702 echo This shell is interactive
2705 Alternatively, you may test the value of the `-' special parameter.
2706 It contains `i' when the shell is interactive. For example:
2709 *i*) echo This shell is interactive ;;
2710 *) echo This shell is not interactive ;;
2714 File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Is This Shell Interactive?, Up: Bash Features
2716 Bash Builtin Commands
2717 =====================
2719 This section describes builtin commands which are unique to or have
2720 been extended in Bash.
2723 bind [-m KEYMAP] [-lpsvPSV] [-q NAME] [-r KEYSEQ]
2724 bind [-m KEYMAP] -f FILENAME
2725 bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
2727 Display current Readline (*note Command Line Editing::.) key and
2728 function bindings, or bind a key sequence to a Readline function
2729 or macro. The binding syntax accepted is identical to that of
2730 `.inputrc' (*note Readline Init File::.), but each binding must be
2731 passed as a separate argument: e.g.,
2732 `"\C-x\C-r":re-read-init-file'. Options, if supplied, have the
2736 Use KEYMAP as the keymap to be affected by the subsequent
2737 bindings. Acceptable KEYMAP names are `emacs',
2738 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
2739 `vi-command', and `vi-insert'. `vi' is equivalent to
2740 `vi-command'; `emacs' is equivalent to `emacs-standard'.
2743 List the names of all Readline functions
2746 Display Readline function names and bindings in such a way
2747 that they can be re-read
2750 List current Readline function names and bindings
2753 Display Readline variable names and values in such a way that
2757 List current Readline variable names and values
2760 Display Readline key sequences bound to macros and the
2761 strings they output in such a way that they can be re-read
2764 Display Readline key sequences bound to macros and the
2768 Read key bindings from FILENAME
2771 Query about which keys invoke the named FUNCTION
2774 Remove any current binding for KEYSEQ
2777 builtin [SHELL-BUILTIN [ARGS]]
2778 Run a shell builtin. This is useful when you wish to define a
2779 shell function with the same name as a shell builtin, but need the
2780 functionality of the builtin within the function itself.
2783 command [-pVv] COMMAND [ARGS ...]
2784 Runs COMMAND with ARG ignoring shell functions. If you have a
2785 shell function called `ls', and you wish to call the command `ls',
2786 you can say `command ls'. The `-p' option means to use a default
2787 value for `$PATH' that is guaranteed to find all of the standard
2790 If either the `-V' or `-v' option is supplied, a description of
2791 COMMAND is printed. The `-v' option causes a single word
2792 indicating the command or file name used to invoke COMMAND to be
2793 printed; the `-V' option produces a more verbose description.
2796 declare [-afFrxi] [-p] [NAME[=VALUE]]
2798 Declare variables and give them attributes. If no NAMEs are
2799 given, then display the values of variables instead.
2801 The `-p' option will display the attributes and values of each
2802 NAME. When `-p' is used, additional options are ignored. The
2803 `-F' option inhibits the display of function definitions; only the
2804 function name and attributes are printed. `-F' implies `-f'. The
2805 following options can be used to restrict output to variables with
2806 the specified attributes or to give variables attributes:
2809 Each NAME is an array variable (*note Arrays::.).
2812 Use function names only.
2815 The variable is to be treated as an integer; arithmetic
2816 evaluation (*note Shell Arithmetic::.) is performed when the
2817 variable is assigned a value.
2820 Make NAMEs readonly. These names cannot then be assigned
2821 values by subsequent assignment statements.
2824 Mark each NAME for export to subsequent commands via the
2827 Using `+' instead of `-' turns off the attribute instead. When
2828 used in a function, `declare' makes each NAME local, as with the
2832 echo [-neE] [arg ...]
2833 Output the `arg's, separated by spaces, terminated with a newline.
2834 The return status is always 0. If `-n' is specified, the
2835 trailing newline is suppressed. If the `-e' option is given,
2836 interpretation of the following backslash-escaped characters is
2837 enabled. The `-E' option disables the interpretation of these
2838 escape characters, even on systems where they are interpreted by
2839 default. `echo' interprets the following escape sequences:
2847 suppress trailing newline
2871 the character whose ASCII code is `nnn' (octal)
2874 enable [-n] [-p] [-f FILENAME] [-ads] [NAME ...]
2875 Enable and disable builtin shell commands. This allows you to use
2876 a disk command which has the same name as a shell builtin. If
2877 `-n' is used, the NAMEs become disabled. Otherwise NAMEs are
2878 enabled. For example, to use the `test' binary found via `$PATH'
2879 instead of the shell builtin version, type `enable -n test'.
2881 If the `-p' option is supplied, or no NAME arguments appear, a
2882 list of shell builtins is printed. With no other arguments, the
2883 list consists of all enabled shell builtins. The `-a' option
2884 means to list each builtin with an indication of whether or not it
2887 The `-f' option means to load the new builtin command NAME from
2888 shared object FILENAME, on systems that support dynamic loading.
2889 The `-d' option will delete a builtin loaded with `-f'. If there
2890 are no options, a list of the shell builtins is displayed. The
2891 `-s' option restricts `enable' to the POSIX.2 special builtins.
2892 If `-s' is used with `-f', the new builtin becomes a special
2897 Display helpful information about builtin commands. If PATTERN is
2898 specified, `help' gives detailed help on all commands matching
2899 PATTERN, otherwise a list of the builtins is printed.
2903 For each argument, create a local variable called NAME, and give
2904 it VALUE. `local' can only be used within a function; it makes
2905 the variable NAME have a visible scope restricted to that function
2910 Exit a login shell, returning a status of N to the shell's parent.
2913 read [-a ANAME] [-p PROMPT] [-er] [NAME ...]
2914 One line is read from the standard input, and the first word is
2915 assigned to the first NAME, the second word to the second NAME,
2916 and so on, with leftover words assigned to the last NAME. Only
2917 the characters in the value of the `IFS' variable are recognized
2918 as word delimiters. If no names are supplied, the line read is
2919 assigned to the variable `REPLY'. The return code is zero, unless
2920 end-of-file is encountered. Options, if supplied, have the
2924 If this option is given, a backslash-newline pair is not
2925 ignored, and the backslash is considered to be part of the
2929 Display `prompt', without a trailing newline, before
2930 attempting to read any input. The prompt is displayed only
2931 if input is coming from a terminal.
2934 The words are assigned to sequential indices of the array
2935 variable ANAME, starting at 0.
2938 Readline (*note Command Line Editing::.) is used to obtain
2942 shopt [-pqsu] [-o] [OPTNAME ...]
2943 Toggle the values of variables controlling optional shell behavior.
2944 With no options, or with the `-p' option, a list of all settable
2945 options is displayed, with an indication of whether or not each is
2946 set. Other options have the following meanings:
2949 Enable (set) each OPTNAME
2952 Disable (unset) each OPTNAME.
2955 Suppresses normal output; the return status indicates whether
2956 the OPTNAME is set or unset. If multiple OPTNAME arguments
2957 are given with `-q', the return status is zero if all
2958 OPTNAMES are enabled; non-zero otherwise.
2961 Restricts the values of OPTNAME to be those defined for the
2962 `-o' option to the `set' builtin (*note The Set Builtin::.).
2964 If either of `-s' or `-u' is used with no OPTNAME arguments, the
2965 display is limited to those options which are set or unset,
2968 Unless otherwise noted, the `shopt' options are disabled (off) by
2971 The return status when listing options is zero if all OPTNAMES are
2972 enabled, non-zero otherwise. When setting or unsetting options,
2973 the return status is zero unless an OPTNAME is not a legal shell
2976 The list of `shopt' options is:
2978 If this is set, an argument to the `cd' builtin command that
2979 is not a directory is assumed to be the name of a variable
2980 whose value is the directory to change to.
2983 If set, minor errors in the spelling of a directory component
2984 in a `cd' command will be corrected. The errors checked for
2985 are transposed characters, a missing character, and a
2986 character too many. If a correction is found, the corrected
2987 path is printed, and the command proceeds. This option is
2988 only used by interactive shells.
2991 If this is set, Bash checks that a command found in the hash
2992 table exists before trying to execute it. If a hashed
2993 command no longer exists, a normal path search is performed.
2996 If set, Bash checks the window size after each command and,
2997 if necessary, updates the values of `LINES' and `COLUMNS'.
3000 If set, Bash attempts to save all lines of a multiple-line
3001 command in the same history entry. This allows easy
3002 re-editing of multi-line commands.
3005 If set, Bash includes filenames beginning with a `.' in the
3006 results of filename expansion.
3009 If this is set, a non-interactive shell will not exit if it
3010 cannot execute the file specified as an argument to the `exec'
3011 builtin command. An interactive shell does not exit if `exec'
3015 If set, the history list is appended to the file named by the
3016 value of the `HISTFILE' variable when the shell exits, rather
3017 than overwriting the file.
3020 If set, and Readline is being used, a user is given the
3021 opportunity to re-edit a failed history substitution.
3024 If set, and Readline is being used, the results of history
3025 substitution are not immediately passed to the shell parser.
3026 Instead, the resulting line is loaded into the Readline
3027 editing buffer, allowing further modification.
3030 If set, and Readline is being used, Bash will attempt to
3031 perform hostname completion when a word beginning with `@' is
3032 being completed (*note Commands For Completion::.). This
3033 option is enabled by default.
3035 `interactive_comments'
3036 Allow a word beginning with `#' to cause that word and all
3037 remaining characters on that line to be ignored in an
3038 interactive shell. This option is enabled by default.
3041 If enabled, and the `cmdhist' option is enabled, multi-line
3042 commands are saved to the history with embedded newlines
3043 rather than using semicolon separators where possible.
3046 If set, and a file that Bash is checking for mail has been
3047 accessed since the last time it was checked, the message
3048 `"The mail in MAILFILE has been read"' is displayed.
3051 If set, Bash allows filename patterns which match no files to
3052 expand to a null string, rather than themselves.
3055 If set, prompt strings undergo variable and parameter
3056 expansion after being expanded (*note Printing a Prompt::.).
3057 This option is enabled by default.
3060 If this is set, the `shift' builtin prints an error message
3061 when the shift count exceeds the number of positional
3065 If set, the `source' builtin uses the value of `PATH' to find
3066 the directory containing the file supplied as an argument.
3067 This is enabled by default.
3070 type [-all] [-type | -path] [NAME ...]
3071 For each NAME, indicate how it would be interpreted if used as a
3074 If the `-type' flag is used, `type' returns a single word which is
3075 one of `alias', `function', `builtin', `file' or `keyword', if
3076 NAME is an alias, shell function, shell builtin, disk file, or
3077 shell reserved word, respectively. If the NAME is not found, then
3078 nothing is printed, and `type' returns a failure status.
3080 If the `-path' flag is used, `type' either returns the name of the
3081 disk file that would be executed, or nothing if `-type' would not
3084 If the `-all' flag is used, returns all of the places that contain
3085 an executable named FILE. This includes aliases and functions, if
3086 and only if the `-path' flag is not also used.
3088 `type' accepts `-a', `-t', and `-p' as equivalent to `-all',
3089 `-type', and `-path', respectively.
3092 ulimit [-acdflmnpstuvSH] [LIMIT]
3093 `ulimit' provides control over the resources available to processes
3094 started by the shell, on systems that allow such control. If an
3095 option is given, it is interpreted as follows:
3097 change and report the soft limit associated with a resource.
3100 change and report the hard limit associated with a resource.
3103 all current limits are reported.
3106 the maximum size of core files created.
3109 the maximum size of a process's data segment.
3112 the maximum size of files created by the shell.
3115 The maximum size that may be locked into memory.
3118 the maximum resident set size.
3121 the maximum number of open file descriptors.
3124 the pipe buffer size.
3127 the maximum stack size.
3130 the maximum amount of cpu time in seconds.
3133 the maximum number of processes available to a single user.
3136 the maximum amount of virtual memory available to the process.
3138 If LIMIT is given, it is the new value of the specified resource.
3139 Otherwise, the current value of the soft limit for the specified
3140 resource is printed, unless the `-H' option is supplied. When
3141 setting new limits, if neither `-H' nor `-S' is supplied, both the
3142 hard and soft limits are set. If no option is given, then `-f' is
3143 assumed. Values are in 1024-byte increments, except for `-t',
3144 which is in seconds, `-p', which is in units of 512-byte blocks,
3145 and `-n' and `-u', which are unscaled values.
3148 File: bashref.info, Node: The Set Builtin, Next: Bash Conditional Expressions, Prev: Bash Builtins, Up: Bash Features
3153 This builtin is so overloaded that it deserves its own section.
3156 set [-abefhkmnptuvxdBCHP] [-o OPTION] [ARGUMENT ...]
3159 Mark variables which are modified or created for export.
3162 Cause the status of terminated background jobs to be reported
3163 immediately, rather than before printing the next primary
3167 Exit immediately if a simple command exits with a non-zero
3171 Disable file name generation (globbing).
3174 Locate and remember (hash) commands as they are looked up for
3178 All arguments in the form of assignment statements are placed
3179 in the environment for a command, not just those that precede
3183 Job control is enabled (*note Job Control::.).
3186 Read commands but do not execute them.
3189 Set the flag corresponding to OPTION-NAME:
3198 use an `emacs'-style line editing interface (*note
3199 Command Line Editing::.).
3211 Enable command history, as described in *Note Bash
3212 History Facilities::. This option is on by default in
3216 the shell will not exit upon reading EOF.
3246 change the behavior of Bash where the default operation
3247 differs from the POSIX 1003.2 standard to match the
3248 standard. This is intended to make Bash behave as a
3249 strict superset of that standard.
3258 use a `vi'-style line editing interface.
3264 Turn on privileged mode. In this mode, the `$BASH_ENV' file
3265 is not processed, and shell functions are not inherited from
3266 the environment. This is enabled automatically on startup if
3267 the effective user (group) id is not equal to the real user
3268 (group) id. Turning this option off causes the effective user
3269 and group ids to be set to the real user and group ids.
3272 Exit after reading and executing one command.
3275 Treat unset variables as an error when substituting.
3278 Print shell input lines as they are read.
3281 Print commands and their arguments as they are executed.
3284 The shell will perform brace expansion (*note Brace
3285 Expansion::.). This option is on by default.
3288 Disallow output redirection to existing files.
3291 Enable `!' style history substitution (*note History
3292 Interaction::.). This flag is on by default for interactive
3296 If set, do not follow symbolic links when performing commands
3297 such as `cd' which change the current directory. The
3298 physical directory is used instead. By default, Bash follows
3299 the logical chain of directories when performing commands
3300 which change the current directory.
3302 For example, if `/usr/sys' is a link to `/usr/local/sys' then:
3303 $ cd /usr/sys; echo $PWD
3308 If `set -P' is on, then:
3309 $ cd /usr/sys; echo $PWD
3315 If no arguments follow this flag, then the positional
3316 parameters are unset. Otherwise, the positional parameters
3317 are set to the ARGUMENTS, even if some of them begin with a
3321 Signal the end of options, cause all remaining ARGUMENTS to
3322 be assigned to the positional parameters. The `-x' and `-v'
3323 options are turned off. If there are no arguments, the
3324 positional parameters remain unchanged.
3326 Using `+' rather than `-' causes these flags to be turned off.
3327 The flags can also be used upon invocation of the shell. The
3328 current set of flags may be found in `$-'.
3330 The remaining N ARGUMENTS are positional parameters and are
3331 assigned, in order, to `$1', `$2', ... `$N'. If no arguments are
3332 given, all shell variables are printed.
3335 File: bashref.info, Node: Bash Conditional Expressions, Next: Bash Variables, Prev: The Set Builtin, Up: Bash Features
3337 Bash Conditional Expressions
3338 ============================
3340 Conditional expressions are used by the `test' and `[' builtins.
3342 Expressions may be unary or binary. Unary expressions are often
3343 used to examine the status of a file. There are string operators and
3344 numeric comparison operators as well. Each operator and operand must
3345 be a separate argument. If FILE is of the form `/dev/fd/N', then file
3346 descriptor N is checked. Expressions are composed of the following
3350 True if FILE exists and is a block special file.
3353 True if FILE exists and is a character special file.
3356 True if FILE exists and is a directory.
3359 True if FILE exists.
3362 True if FILE exists and is a regular file.
3365 True if FILE exists and is set-group-id.
3368 True if FILE has its "sticky" bit set.
3371 True if FILE exists and is a symbolic link.
3374 True if FILE exists and is a named pipe.
3377 True if FILE exists and is readable.
3380 True if FILE exists and has a size greater than zero.
3383 True if FILE exists and is a socket.
3386 True if FD is opened on a terminal.
3389 True if FILE exists and its set-user-id bit is set.
3392 True if FILE exists and is writable.
3395 True if FILE exists and is executable.
3398 True if FILE exists and is owned by the effective user id.
3401 True if FILE exists and is owned by the effective group id.
3404 True if FILE1 is newer (according to modification date) than FILE2.
3407 True if FILE1 is older than FILE2.
3410 True if FILE1 and FILE2 have the same device and inode numbers.
3413 True if shell option OPTNAME is enabled. The list of options
3414 appears in the description of the `-o' option to the `set' builtin
3415 (*note The Set Builtin::.).
3418 True if the length of STRING is zero.
3422 True if the length of STRING is non-zero.
3425 True if the strings are equal. `==' may be used in place of `='.
3427 `STRING1 != STRING2'
3428 True if the strings are not equal.
3431 True if STRING1 sorts before STRING2 lexicographically.
3434 True if STRING1 sorts after STRING2 lexicographically.
3437 True if EXPR is false.
3440 True if both EXPR1 and EXPR2 are true.
3443 True if either EXPR1 and EXPR2 is true.
3446 `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'. These
3447 arithmetic binary operators return true if ARG1 is equal to, not
3448 equal to, less than, less than or equal to, greater than, or
3449 greater than or equal to ARG2, respectively. ARG1 and ARG2 may be
3450 positive or negative integers.
3452 The Bash `test' and `[' builtins evaluate conditional expressions
3453 using a set of rules based on the number of arguments. These are the
3457 The expression is false.
3460 The expression is true if and only if the argument is not null.
3463 If the first argument is `!', the expression is true if and only
3464 if the second argument is null. If the first argument is one of
3465 the listed unary operators, the expression is true if the unary
3466 test is true. If the first argument is not a legal unary
3467 operator, the expression is false.
3470 If the first argument is `!', the value is the negation of the
3471 two-argument test using the second and third arguments. If the
3472 second argument is one of the binary operators, the result of the
3473 expression is the result of the binary test using the first and
3474 third arguments as operands. If the first argument is exactly `('
3475 and the third argument is exactly `)', the result is the
3476 one-argument test of the second argument. Otherwise, the
3477 expression is false. The `-a' and `-o' operators are considered
3478 binary operators in this case.
3481 If the first argument is `!', the result is the negation of the
3482 three-argument expression composed of the remaining arguments.
3483 Otherwise, the expression is parsed and evaluated according to
3484 precedence. `-a' has a higher precedence than `-o'.
3487 The expression is parsed and evaluated according to precedence,
3488 with `-a' having a higher precedence than `-o'.
3491 File: bashref.info, Node: Bash Variables, Next: Shell Arithmetic, Prev: Bash Conditional Expressions, Up: Bash Features
3496 These variables are set or used by Bash, but other shells do not
3497 normally treat them specially.
3500 If this variable is set when Bash is invoked to execute a shell
3501 script, its value is expanded and used as the name of a startup
3502 file to read before executing the script. *Note Bash Startup
3506 The value of this parameter is used as a format string specifying
3507 how the timing information for pipelines prefixed with the `time'
3508 reserved word should be displayed. The `%' character introduces an
3509 escape sequence that is expanded to a time value or other
3510 information. The escape sequences and their meanings are as
3511 follows; the braces denote optional portions.
3517 The elapsed time in seconds.
3520 The number of CPU seconds spent in user mode.
3523 The number of CPU seconds spent in system mode.
3526 The CPU percentage, computed as (%U + %S) / %R.
3528 The optional P is a digit specifying the precision, the number of
3529 fractional digits after a decimal point. A value of 0 causes no
3530 decimal point or fraction to be output. At most three places
3531 after the decimal point may be specified; values of P greater than
3532 3 are changed to 3. If P is not specified, the value 3 is used.
3534 The optional `l' specifies a longer format, including minutes, of
3535 the form MMmSS.FFs. The value of P determines whether or not the
3536 fraction is included.
3538 If this variable is not set, bash acts as if it had the value
3539 `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''.
3540 If the value is null, no timing information is displayed. A
3541 trailing newline is added when the format string is displayed.
3544 Set to a value of `ignorespace', it means don't enter lines which
3545 begin with a space or tab into the history list. Set to a value
3546 of `ignoredups', it means don't enter lines which match the last
3547 entered line. A value of `ignoreboth' combines the two options.
3548 Unset, or set to any other value than those above, means to save
3549 all lines on the history list.
3552 A colon-separated list of patterns used to decide which command
3553 lines should be saved on the history list. Each pattern is
3554 anchored at the beginning of the line and must fully specify the
3555 line (no implicit `*' is appended). Each pattern is tested
3556 against the line after the checks specified by `HISTCONTROL' are
3557 applied. In addition to the normal shell pattern matching
3558 characters, `&' matches the previous history line. `&' may be
3559 escaped using a backslash. The backslash is removed before
3562 `HISTIGNORE' subsumes the function of `HISTCONTROL'. A pattern of
3563 `&' is identical to `ignoredups', and a pattern of `[ ]*' is
3564 identical to `ignorespace'. Combining these two patterns,
3565 separating them with a colon, provides the functionality of
3569 The name of the file to which the command history is saved. The
3570 default is `~/.bash_history'.
3573 If set, this is the maximum number of commands to remember in the
3577 The maximum number of lines contained in the history file. When
3578 this variable is assigned a value, the history file is truncated,
3579 if necessary, to contain no more than that number of lines. The
3580 default value is 500. The history file is also truncated to this
3581 size after writing it when an interactive shell exits.
3584 Up to three characters which control history expansion, quick
3585 substitution, and tokenization (*note History Interaction::.).
3586 The first character is the "history-expansion-char", that is, the
3587 character which signifies the start of a history expansion,
3588 normally `!'. The second character is the character which
3589 signifies `quick substitution' when seen as the first character on
3590 a line, normally `^'. The optional third character is the
3591 character which signifies the remainder of the line is a comment,
3592 when found as the first character of a word, usually `#'. The
3593 history comment character causes history substitution to be
3594 skipped for the remaining words on the line. It does not
3595 necessarily cause the shell parser to treat the rest of the line
3599 The history number, or index in the history list, of the current
3600 command. If `HISTCMD' is unset, it loses its special properties,
3601 even if it is subsequently reset.
3604 Contains the name of a file in the same format as `/etc/hosts' that
3605 should be read when the shell needs to complete a hostname. You
3606 can change the file interactively; the next time you attempt to
3607 complete a hostname, Bash will add the contents of the new file to
3608 the already existing database.
3611 How often (in seconds) that the shell should check for mail in the
3612 files specified in `MAILPATH'.
3615 If present, this contains a string which is a command to execute
3616 before the printing of each primary prompt (`$PS1').
3619 The numeric real user id of the current user.
3622 The numeric effective user id of the current user.
3625 An array variable containing the list of groups of which the
3626 current user is a member.
3629 The process id of the shell's parent process.
3632 The name of the current host.
3635 A string describing the machine Bash is running on.
3638 A string describing the operating system Bash is running on.
3641 A string that fully describes the system type on which Bash is
3642 executing, in the standard GNU CPU-COMPANY-SYSTEM format.
3645 A colon-separated list of enabled shell options. Each word in the
3646 list is a valid argument for the `-o' option to the `set' builtin
3647 command (*note The Set Builtin::.). The options appearing in
3648 `SHELLOPTS' are those reported as `on' by `set -o'. If this
3649 variable is in the environment when Bash starts up, each shell
3650 option in the list will be enabled before reading any startup
3651 files. This variable is readonly.
3654 A colon-separated list of suffixes to ignore when performing
3655 filename completion. A file name whose suffix matches one of the
3656 entries in `FIGNORE' is excluded from the list of matched file
3657 names. A sample value is `.o:~'
3660 A colon-separated list of patterns defining the set of filenames to
3661 be ignored by filename expansion. If a filename matched by a
3662 filename expansion pattern also matches one of the patterns in
3663 `GLOBIGNORE', it is removed from the list of matches.
3666 An array variable (*note Arrays::.) containing the current
3667 contents of the directory stack. Directories appear in the stack
3668 in the order they are displayed by the `dirs' builtin. Assigning
3669 to members of this array variable may be used to modify
3670 directories already in the stack, but the `pushd' and `popd'
3671 builtins must be used to add and remove directories. Assignment
3672 to this variable will not change the current directory. If
3673 `DIRSTACK' is unset, it loses its special properties, even if it
3674 is subsequently reset.
3677 An array variable (*note Arrays::.) containing a list of exit
3678 status values from the processes in the most-recently-executed
3679 foreground pipeline (which may contain only a single command).
3682 The name of the Readline startup file, overriding the default of
3686 The full filename used to execute the current instance of Bash.
3689 The version number of the current instance of Bash.
3692 An array variable whose members hold version information for this
3693 instance of Bash. The values assigned to the array members are as
3697 The major version number (the RELEASE).
3700 The minor version number (the VERSION).
3709 The release status (e.g., BETA1).
3712 The value of `MACHTYPE'.
3715 Incremented by one each time a new instance of Bash is started.
3716 This is intended to be a count of how deeply your Bash shells are
3720 If set to the value 1, Bash displays error messages generated by
3721 the `getopts' builtin command.
3724 Used to determine the locale category for any category not
3725 specifically selected with a variable starting with `LC_'.
3728 This variable overrides the value of `LANG' and any other `LC_'
3729 variable specifying a locale category.
3732 This variable determines the collation order used when sorting the
3733 results of filename expansion (*note Filename Expansion::.).
3736 This variable determines the locale used to translate double-quoted
3737 strings preceded by a `$' (*note Locale Translation::.).
3740 Controls the action of the shell on receipt of an `EOF' character
3741 as the sole input. If set, then the value of it is the number of
3742 consecutive `EOF' characters that can be read as the first
3743 character on an input line before the shell will exit. If the
3744 variable exists but does not have a numeric value (or has no
3745 value) then the default is 10. If the variable does not exist,
3746 then `EOF' signifies the end of input to the shell. This is only
3747 in effect for interactive shells.
3750 File: bashref.info, Node: Shell Arithmetic, Next: Arrays, Prev: Bash Variables, Up: Bash Features
3757 * Arithmetic Evaluation:: How shell arithmetic works.
3758 * Arithmetic Expansion:: How to use arithmetic in shell expansions.
3759 * Arithmetic Builtins:: Builtin commands that use shell arithmetic.
3761 Bash includes several mechanisms to evaluate arithmetic expressions
3762 and display the result or use it as part of a command.
3765 File: bashref.info, Node: Arithmetic Evaluation, Next: Arithmetic Expansion, Up: Shell Arithmetic
3767 Arithmetic Evaluation
3768 ---------------------
3770 The shell allows arithmetic expressions to be evaluated, as one of
3771 the shell expansions or by the `let' builtin.
3773 Evaluation is done in long integers with no check for overflow,
3774 though division by 0 is trapped and flagged as an error. The following
3775 list of operators is grouped into levels of equal-precedence operators.
3776 The levels are listed in order of decreasing precedence.
3779 unary minus and plus
3782 logical and bitwise negation
3785 multiplication, division, remainder
3788 addition, subtraction
3791 left and right bitwise shifts
3797 equality and inequality
3803 bitwise exclusive OR
3814 `expr ? expr : expr'
3815 conditional evaluation
3817 `= *= /= %= += -= <<= >>= &= ^= |='
3820 Shell variables are allowed as operands; parameter expansion is
3821 performed before the expression is evaluated. The value of a parameter
3822 is coerced to a long integer within an expression. A shell variable
3823 need not have its integer attribute turned on to be used in an
3826 Constants with a leading 0 are interpreted as octal numbers. A
3827 leading `0x' or `0X' denotes hexadecimal. Otherwise, numbers take the
3828 form [BASE`#']N, where BASE is a decimal number between 2 and 64
3829 representing the arithmetic base, and N is a number in that base. If
3830 BASE is omitted, then base 10 is used. The digits greater than 9 are
3831 represented by the lowercase letters, the uppercase letters, `_', and
3832 `@', in that order. If BASE is less than or equal to 36, lowercase and
3833 uppercase letters may be used interchangably to represent numbers
3836 Operators are evaluated in order of precedence. Sub-expressions in
3837 parentheses are evaluated first and may override the precedence rules
3841 File: bashref.info, Node: Arithmetic Expansion, Next: Arithmetic Builtins, Prev: Arithmetic Evaluation, Up: Shell Arithmetic
3843 Arithmetic Expansion
3844 --------------------
3846 Arithmetic expansion allows the evaluation of an arithmetic
3847 expression and the substitution of the result. The format for
3848 arithmetic expansion is:
3852 The expression is treated as if it were within double quotes, but a
3853 double quote inside the braces or parentheses is not treated specially.
3854 All tokens in the expression undergo parameter expansion, command
3855 substitution, and quote removal. Arithmetic substitutions may be
3858 The evaluation is performed according to the rules listed above. If
3859 the expression is invalid, Bash prints a message indicating failure and
3860 no substitution occurs.
3863 File: bashref.info, Node: Arithmetic Builtins, Prev: Arithmetic Expansion, Up: Shell Arithmetic
3869 let EXPRESSION [EXPRESSION]
3870 The `let' builtin allows arithmetic to be performed on shell
3871 variables. Each EXPRESSION is evaluated according to the rules
3872 given previously (*note Arithmetic Evaluation::.). If the last
3873 EXPRESSION evaluates to 0, `let' returns 1; otherwise 0 is
3877 File: bashref.info, Node: Arrays, Next: Printing a Prompt, Prev: Shell Arithmetic, Up: Bash Features
3882 Bash provides one-dimensional array variables. Any variable may be
3883 used as an array; the `declare' builtin will explicitly declare an
3884 array. There is no maximum limit on the size of an array, nor any
3885 requirement that members be indexed or assigned contiguously. Arrays
3888 An array is created automatically if any variable is assigned to
3890 name[SUBSCRIPT]=VALUE
3892 The SUBSCRIPT is treated as an arithmetic expression that must evaluate
3893 to a number greater than or equal to zero. To explicitly declare an
3898 declare -a NAME[SUBSCRIPT]
3900 is also accepted; the SUBSCRIPT is ignored. Attributes may be
3901 specified for an array variable using the `declare' and `readonly'
3902 builtins. Each attribute applies to all members of an array.
3904 Arrays are assigned to using compound assignments of the form
3905 name=(value1 ... valueN)
3907 where each VALUE is of the form `[[SUBSCRIPT]=]'STRING. If the
3908 optional subscript is supplied, that index is assigned to; otherwise
3909 the index of the element assigned is the last index assigned to by the
3910 statement plus one. Indexing starts at zero. This syntax is also
3911 accepted by the `declare' builtin. Individual array elements may be
3912 assigned to using the `name['SUBSCRIPT`]='VALUE syntax introduced above.
3914 Any element of an array may be referenced using
3915 `${name['SUBSCRIPT`]}'. The braces are required to avoid conflicts
3916 with the shell's filename expansion operators. If the SUBSCRIPT is `@'
3917 or `*', the word expands to all members of the array NAME. These
3918 subscripts differ only when the word appears within double quotes. If
3919 the word is double-quoted, `${name[*]}' expands to a single word with
3920 the value of each array member separated by the first character of the
3921 `IFS' variable, and `${name[@]}' expands each element of NAME to a
3922 separate word. When there are no array members, `${name[@]}' expands
3923 to nothing. This is analogous to the expansion of the special
3924 parameters `@' and `*'. `${#name['SUBSCRIPT`]}' expands to the length
3925 of `${name['SUBSCRIPT`]}'. If SUBSCRIPT is `@' or `*', the expansion
3926 is the number of elements in the array. Referencing an array variable
3927 without a subscript is equivalent to referencing element zero.
3929 The `unset' builtin is used to destroy arrays. `unset'
3930 NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT. `unset'
3931 NAME, where NAME is an array, removes the entire array. A subscript of
3932 `*' or `@' also removes the entire array.
3934 The `declare', `local', and `readonly' builtins each accept a `-a'
3935 option to specify an array. The `read' builtin accepts a `-a' option
3936 to assign a list of words read from the standard input to an array, and
3937 can read values from the standard input into individual array elements.
3938 The `set' and `declare' builtins display array values in a way that
3939 allows them to be reused as input.
3942 File: bashref.info, Node: Printing a Prompt, Next: The Restricted Shell, Prev: Arrays, Up: Bash Features
3944 Controlling the Prompt
3945 ======================
3947 The value of the variable `PROMPT_COMMAND' is examined just before
3948 Bash prints each primary prompt. If it is set and non-null, then the
3949 value is executed just as if you had typed it on the command line.
3951 In addition, the following table describes the special characters
3952 which can appear in the prompt variables:
3958 the date, in "Weekday Month Date" format (e.g., "Tue May 26").
3961 an escape character.
3964 the hostname, up to the first `.'.
3973 the name of the shell, the basename of `$0' (the portion following
3977 the time, in 24-hour HH:MM:SS format.
3980 the time, in 12-hour HH:MM:SS format.
3983 the time, in 12-hour am/pm format.
3986 the version of Bash (e.g., 2.00)
3989 the release of Bash, version + patchlevel (e.g., 2.00.0)
3992 the current working directory.
3995 the basename of `$PWD'.
4001 the history number of this command.
4004 the command number of this command.
4007 if the effective uid is 0, `#', otherwise `$'.
4010 the character corresponding to the octal number `nnn'.
4016 begin a sequence of non-printing characters. This could be used to
4017 embed a terminal control sequence into the prompt.
4020 end a sequence of non-printing characters.
4023 File: bashref.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Printing a Prompt, Up: Bash Features
4025 The Restricted Shell
4026 ====================
4028 If Bash is started with the name `rbash', or the `--restricted'
4029 option is supplied at invocation, the shell becomes restricted. A
4030 restricted shell is used to set up an environment more controlled than
4031 the standard shell. A restricted shell behaves identically to `bash'
4032 with the exception that the following are disallowed:
4033 * Changing directories with the `cd' builtin.
4035 * Setting or unsetting the values of the `SHELL' or `PATH' variables.
4037 * Specifying command names containing slashes.
4039 * Specifying a filename containing a slash as an argument to the `.'
4042 * Importing function definitions from the shell environment at
4045 * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
4046 redirection operators.
4048 * Using the `exec' builtin to replace the shell with another command.
4050 * Adding or deleting builtin commands with the `-f' and `-d' options
4051 to the `enable' builtin.
4053 * Specifying the `-p' option to the `command' builtin.
4055 * Turning off restricted mode with `set +r'.
4058 File: bashref.info, Node: Bash POSIX Mode, Prev: The Restricted Shell, Up: Bash Features
4063 Starting Bash with the `--posix' command-line option or executing
4064 `set -o posix' while Bash is running will cause Bash to conform more
4065 closely to the POSIX.2 standard by changing the behavior to match that
4066 specified by POSIX.2 in areas where the Bash default differs.
4068 The following list is what's changed when `POSIX mode' is in effect:
4070 1. When a command in the hash table no longer exists, Bash will
4071 re-search `$PATH' to find the new location. This is also
4072 available with `shopt -s checkhash'.
4074 2. The `>&' redirection does not redirect stdout and stderr.
4076 3. The message printed by the job control code and builtins when a job
4077 exits with a non-zero status is `Done(status)'.
4079 4. Reserved words may not be aliased.
4081 5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
4082 number and `!!' to `!' are enabled, and parameter expansion is
4083 performed on the value regardless of the setting of the
4084 `promptvars' option.
4086 6. Interactive comments are enabled by default. (Note that Bash has
4087 them on by default anyway.)
4089 7. The POSIX.2 startup files are executed (`$ENV') rather than the
4092 8. Tilde expansion is only performed on assignments preceding a
4093 command name, rather than on all assignment statements on the line.
4095 9. The default history file is `~/.sh_history' (this is the default
4096 value of `$HISTFILE').
4098 10. The output of `kill -l' prints all the signal names on a single
4099 line, separated by spaces.
4101 11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
4104 12. Redirection operators do not perform filename expansion on the word
4105 in the redirection unless the shell is interactive.
4107 13. Function names must be valid shell `name's. That is, they may not
4108 contain characters other than letters, digits, and underscores, and
4109 may not start with a digit. Declaring a function with an illegal
4110 name causes a fatal syntax error in non-interactive shells.
4112 14. POSIX.2 `special' builtins are found before shell functions during
4115 15. If a POSIX.2 special builtin returns an error status, a
4116 non-interactive shell exits. The fatal errors are those listed in
4117 the POSIX.2 standard, and include things like passing incorrect
4118 options, redirection errors, variable assignment errors for
4119 assignments preceding the command name, and so on.
4121 16. If the `cd' builtin finds a directory to change to using
4122 `$CDPATH', the value it assigns to the `PWD' variable does not
4123 contain any symbolic links, as if `cd -P' had been executed.
4125 17. A non-interactive shell exits with an error status if a variable
4126 assignment error occurs when no command name follows the assignment
4127 statements. A variable assignment error occurs, for example, when
4128 trying to assign a value to a read-only variable.
4130 18. A non-interactive shell exits with an error status if the iteration
4131 variable in a `for' statement or the selection variable in a
4132 `select' statement is a read-only variable.
4134 19. Process substitution is not available.
4136 20. Assignment statements preceding POSIX.2 `special' builtins persist
4137 in the shell environment after the builtin completes.
4139 21. The `export' and `readonly' builtin commands display their output
4140 in the format required by POSIX.2.
4143 There is other POSIX.2 behavior that Bash does not implement.
4146 1. Assignment statements affect the execution environment of all
4147 builtins, not just special ones.
4150 File: bashref.info, Node: Job Control, Next: Using History Interactively, Prev: Bash Features, Up: Top
4155 This chapter disusses what job control is, how it works, and how
4156 Bash allows you to access its facilities.
4160 * Job Control Basics:: How job control works.
4161 * Job Control Builtins:: Bash builtin commands used to interact
4163 * Job Control Variables:: Variables Bash uses to customize job
4167 File: bashref.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control
4172 Job control refers to the ability to selectively stop (suspend) the
4173 execution of processes and continue (resume) their execution at a later
4174 point. A user typically employs this facility via an interactive
4175 interface supplied jointly by the system's terminal driver and Bash.
4177 The shell associates a JOB with each pipeline. It keeps a table of
4178 currently executing jobs, which may be listed with the `jobs' command.
4179 When Bash starts a job asynchronously (in the background), it prints a
4180 line that looks like:
4183 indicating that this job is job number 1 and that the process ID of the
4184 last process in the pipeline associated with this job is 25647. All of
4185 the processes in a single pipeline are members of the same job. Bash
4186 uses the JOB abstraction as the basis for job control.
4188 To facilitate the implementation of the user interface to job
4189 control, the system maintains the notion of a current terminal process
4190 group ID. Members of this process group (processes whose process group
4191 ID is equal to the current terminal process group ID) receive
4192 keyboard-generated signals such as `SIGINT'. These processes are said
4193 to be in the foreground. Background processes are those whose process
4194 group ID differs from the terminal's; such processes are immune to
4195 keyboard-generated signals. Only foreground processes are allowed to
4196 read from or write to the terminal. Background processes which attempt
4197 to read from (write to) the terminal are sent a `SIGTTIN' (`SIGTTOU')
4198 signal by the terminal driver, which, unless caught, suspends the
4201 If the operating system on which Bash is running supports job
4202 control, Bash allows you to use it. Typing the SUSPEND character
4203 (typically `^Z', Control-Z) while a process is running causes that
4204 process to be stopped and returns you to Bash. Typing the DELAYED
4205 SUSPEND character (typically `^Y', Control-Y) causes the process to be
4206 stopped when it attempts to read input from the terminal, and control to
4207 be returned to Bash. You may then manipulate the state of this job,
4208 using the `bg' command to continue it in the background, the `fg'
4209 command to continue it in the foreground, or the `kill' command to kill
4210 it. A `^Z' takes effect immediately, and has the additional side
4211 effect of causing pending output and typeahead to be discarded.
4213 There are a number of ways to refer to a job in the shell. The
4214 character `%' introduces a job name. Job number `n' may be referred to
4215 as `%n'. A job may also be referred to using a prefix of the name used
4216 to start it, or using a substring that appears in its command line.
4217 For example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the
4218 other hand, refers to any job containing the string `ce' in its command
4219 line. If the prefix or substring matches more than one job, Bash
4220 reports an error. The symbols `%%' and `%+' refer to the shell's
4221 notion of the current job, which is the last job stopped while it was
4222 in the foreground. The previous job may be referenced using `%-'. In
4223 output pertaining to jobs (e.g., the output of the `jobs' command), the
4224 current job is always flagged with a `+', and the previous job with a
4227 Simply naming a job can be used to bring it into the foreground:
4228 `%1' is a synonym for `fg %1', bringing job 1 from the background into
4229 the foreground. Similarly, `%1 &' resumes job 1 in the background,
4230 equivalent to `bg %1'
4232 The shell learns immediately whenever a job changes state.
4233 Normally, Bash waits until it is about to print a prompt before
4234 reporting changes in a job's status so as to not interrupt any other
4235 output. If the the `-b' option to the `set' builtin is set, Bash
4236 reports such changes immediately (*note The Set Builtin::.).
4238 If you attempt to exit Bash while jobs are stopped, the shell prints
4239 a message warning you that you have stopped jobs. You may then use the
4240 `jobs' command to inspect their status. If you do this, or try to exit
4241 again immediately, you are not warned again, and the stopped jobs are
4245 File: bashref.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control
4247 Job Control Builtins
4248 ====================
4252 Place JOBSPEC into the background, as if it had been started with
4253 `&'. If JOBSPEC is not supplied, the current job is used.
4257 Bring JOBSPEC into the foreground and make it the current job. If
4258 JOBSPEC is not supplied, the current job is used.
4261 jobs [-lpnrs] [JOBSPEC]
4262 jobs -x COMMAND [JOBSPEC]
4264 The first form lists the active jobs. The options have the
4268 List process IDs in addition to the normal information
4271 Display information only about jobs that have changed status
4272 since you were last notified of their status.
4275 List only the process ID of the job's process group leader.
4278 Restrict output to running jobs.
4281 Restrict output to stopped jobs.
4283 If JOBSPEC is given, output is restricted to information about
4284 that job. If JOBSPEC is not supplied, the status of all jobs is
4287 If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
4288 in COMMAND or ARGUMENTS with the corresponding process group ID,
4289 and executes COMMAND, passing it ARGUMENTs, returning its exit
4293 kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC
4295 Send a signal specified by SIGSPEC or SIGNUM to the process named
4296 by JOBSPEC. SIGSPEC is either a signal name such as `SIGINT'
4297 (with or without the `SIG' prefix) or a signal number; SIGNUM is a
4298 signal number. If SIGSPEC and SIGNUM are not present, `SIGTERM'
4299 is used. The `-l' option lists the signal names, or the signal
4300 name corresponding to SIGSPEC.
4304 Wait until the child process specified by process ID PID or job
4305 specification JOBSPEC exits and report its exit status. If a job
4306 spec is given, all processes in the job are waited for. If no
4307 arguments are given, all currently active child processes are
4311 disown [-h] [JOBSPEC ...]
4312 Without options, each JOBSPEC is removed from the table of active
4313 jobs. If the `-h' option is given, the job is not removed from
4314 the table, but is marked so that `SIGHUP' is not sent to the job
4315 if the shell receives a `SIGHUP'. If JOBSPEC is not present, the
4316 current job is used.
4320 Suspend the execution of this shell until it receives a `SIGCONT'
4321 signal. The `-f' option means to suspend even if the shell is a
4324 When job control is not active, the `kill' and `wait' builtins do
4325 not accept JOBSPEC arguments. They must be supplied process IDs.
4328 File: bashref.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control
4330 Job Control Variables
4331 =====================
4334 This variable controls how the shell interacts with the user and
4335 job control. If this variable exists then single word simple
4336 commands without redirects are treated as candidates for resumption
4337 of an existing job. There is no ambiguity allowed; if there is
4338 more than one job beginning with the string typed, then the most
4339 recently accessed job will be selected. The name of a stopped
4340 job, in this context, is the command line used to start it. If
4341 this variable is set to the value `exact', the string supplied
4342 must match the name of a stopped job exactly; if set to
4343 `substring', the string supplied needs to match a substring of the
4344 name of a stopped job. The `substring' value provides
4345 functionality analogous to the `%?' job ID (*note Job Control
4346 Basics::.). If set to any other value, the supplied string must
4347 be a prefix of a stopped job's name; this provides functionality
4348 analogous to the `%' job ID.
4351 File: bashref.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
4353 Using History Interactively
4354 ***************************
4356 This chapter describes how to use the GNU History Library
4357 interactively, from a user's standpoint. It should be considered a
4358 user's guide. For information on using the GNU History Library in your
4359 own programs, see the GNU Readline Library Manual.
4363 * Bash History Facilities:: How Bash lets you manipulate your command
4365 * History Interaction:: What it feels like using History as a user.
4368 File: bashref.info, Node: Bash History Facilities, Next: History Interaction, Up: Using History Interactively
4370 Bash History Facilities
4371 =======================
4373 When the `-o history' option to the `set' builtin is enabled (*note
4374 The Set Builtin::.), the shell provides access to the COMMAND HISTORY,
4375 the list of commands previously typed. The text of the last `HISTSIZE'
4376 commands (default 500) is saved in a history list. The shell stores
4377 each command in the history list prior to parameter and variable
4378 expansion but after history expansion is performed, subject to the
4379 values of the shell variables `HISTIGNORE' and `HISTCONTROL'. When the
4380 shell starts up, the history is initialized from the file named by the
4381 `HISTFILE' variable (default `~/.bash_history'). `HISTFILE' is
4382 truncated, if necessary, to contain no more than the number of lines
4383 specified by the value of the `HISTFILESIZE' variable. When an
4384 interactive shell exits, the last `HISTSIZE' lines are copied from the
4385 history list to `HISTFILE'. If the `histappend' shell option is set
4386 (*note Bash Builtins::.), the lines are appended to the history file,
4387 otherwise the history file is overwritten. If `HISTFILE' is unset, or
4388 if the history file is unwritable, the history is not saved. After
4389 saving the history, the history file is truncated to contain no more
4390 than `$HISTFILESIZE' lines. If `HISTFILESIZE' is not set, no
4391 truncation is performed.
4393 The builtin command `fc' (*note Korn Shell Builtins::.) may be used
4394 to list or edit and re-execute a portion of the history list. The
4395 `history' builtin (*note C Shell Builtins::.) can be used to display or
4396 modify the history list and manipulate the history file. When using
4397 the command-line editing, search commands are available in each editing
4398 mode that provide access to the history list.
4400 The shell allows control over which commands are saved on the history
4401 list. The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
4402 the shell to save only a subset of the commands entered. The `cmdhist'
4403 shell option, if enabled, causes the shell to attempt to save each line
4404 of a multi-line command in the same history entry, adding semicolons
4405 where necessary to preserve syntactic correctness. The `lithist' shell
4406 option causes the shell to save the command with embedded newlines
4407 instead of semicolons. *Note Bash Builtins:: for a description of
4411 File: bashref.info, Node: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
4413 Interactive History Expansion
4414 =============================
4416 The History library provides a history expansion feature that is
4417 similar to the history expansion provided by `csh'. This section
4418 describes the syntax used to manipulate the history information.
4420 History expansions introduce words from the history list into the
4421 input stream, making it easy to repeat commands, insert the arguments
4422 to a previous command into the current input line, or fix errors in
4423 previous commands quickly.
4425 History expansion takes place in two parts. The first is to
4426 determine which line from the previous history should be used during
4427 substitution. The second is to select portions of that line for
4428 inclusion into the current one. The line selected from the previous
4429 history is called the "event", and the portions of that line that are
4430 acted upon are called "words". Various "modifiers" are available to
4431 manipulate the selected words. The line is broken into words in the
4432 same fashion that Bash does, so that several English (or Unix) words
4433 surrounded by quotes are considered as one word. History expansions
4434 are introduced by the appearance of the history expansion character,
4435 which is `!' by default. Only `\' and `'' may be used to escape the
4436 history expansion character.
4438 Several shell options settable with the `shopt' builtin (*note Bash
4439 Builtins::.) may be used to tailor the behavior of history expansion.
4440 If the `histverify' shell option is enabled, and Readline is being
4441 used, history substitutions are not immediately passed to the shell
4442 parser. Instead, the expanded line is reloaded into the Readline
4443 editing buffer for further modification. If Readline is being used,
4444 and the `histreedit' shell option is enabled, a failed history
4445 expansion will be reloaded into the Readline editing buffer for
4446 correction. The `-p' option to the `history' builtin command may be
4447 used to see what a history expansion will do before using it. The `-s'
4448 option to the `history' builtin may be used to add commands to the end
4449 of the history list without actually executing them, so that they are
4450 available for subsequent recall.
4452 The shell allows control of the various characters used by the
4453 history expansion mechanism with the `histchars' variable.
4457 * Event Designators:: How to specify which history line to use.
4458 * Word Designators:: Specifying which words are of interest.
4459 * Modifiers:: Modifying the results of substitution.
4462 File: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
4467 An event designator is a reference to a command line entry in the
4471 Start a history substitution, except when followed by a space, tab,
4472 the end of the line, <=> or <(>.
4475 Refer to command line N.
4478 Refer to the command N lines back.
4481 Refer to the previous command. This is a synonym for `!-1'.
4484 Refer to the most recent command starting with STRING.
4487 Refer to the most recent command containing STRING. The trailing
4488 `?' may be omitted if the STRING is followed immediately by a
4492 Quick Substitution. Repeat the last command, replacing STRING1
4493 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'.
4496 The entire command line typed so far.
4499 File: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
4504 Word designators are used to select desired words from the event. A
4505 `:' separates the event specification from the word designator. It can
4506 be omitted if the word designator begins with a `^', `$', `*', `-', or
4507 `%'. Words are numbered from the beginning of the line, with the first
4508 word being denoted by 0 (zero). Words are inserted into the current
4509 line separated by single spaces.
4512 The `0'th word. For many applications, this is the command word.
4518 The first argument; that is, word 1.
4524 The word matched by the most recent `?STRING?' search.
4527 A range of words; `-Y' abbreviates `0-Y'.
4530 All of the words, except the `0'th. This is a synonym for `1-$'.
4531 It is not an error to use `*' if there is just one word in the
4532 event; the empty string is returned in that case.
4538 Abbreviates `X-$' like `X*', but omits the last word.
4540 If a word designator is supplied without an event specification, the
4541 previous command is used as the event.
4544 File: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
4549 After the optional word designator, you can add a sequence of one or
4550 more of the following modifiers, each preceded by a `:'.
4553 Remove a trailing pathname component, leaving only the head.
4556 Remove all leading pathname components, leaving the tail.
4559 Remove a trailing suffix of the form `.SUFFIX', leaving the
4563 Remove all but the trailing suffix.
4566 Print the new command but do not execute it.
4569 Quote the substituted words, escaping further substitutions.
4572 Quote the substituted words as with `q', but break into words at
4573 spaces, tabs, and newlines.
4576 Substitute NEW for the first occurrence of OLD in the event line.
4577 Any delimiter may be used in place of `/'. The delimiter may be
4578 quoted in OLD and NEW with a single backslash. If `&' appears in
4579 NEW, it is replaced by OLD. A single backslash will quote the
4580 `&'. The final delimiter is optional if it is the last character
4584 Repeat the previous substitution.
4587 Cause changes to be applied over the entire event line. Used in
4588 conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
4591 File: bashref.info, Node: Command Line Editing, Next: Installing Bash, Prev: Using History Interactively, Up: Top
4593 Command Line Editing
4594 ********************
4596 This chapter describes the basic features of the GNU command line
4601 * Introduction and Notation:: Notation used in this text.
4602 * Readline Interaction:: The minimum set of commands for editing a line.
4603 * Readline Init File:: Customizing Readline from a user's view.
4604 * Bindable Readline Commands:: A description of most of the Readline commands
4605 available for binding
4606 * Readline vi Mode:: A short description of how to make Readline
4607 behave like the vi editor.
4610 File: bashref.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
4612 Introduction to Line Editing
4613 ============================
4615 The following paragraphs describe the notation used to represent
4618 The text <C-k> is read as `Control-K' and describes the character
4619 produced when the <k> key is pressed while the Control key is depressed.
4621 The text <M-k> is read as `Meta-K' and describes the character
4622 produced when the meta key (if you have one) is depressed, and the <k>
4623 key is pressed. If you do not have a meta key, the identical keystroke
4624 can be generated by typing <ESC> first, and then typing <k>. Either
4625 process is known as "metafying" the <k> key.
4627 The text <M-C-k> is read as `Meta-Control-k' and describes the
4628 character produced by "metafying" <C-k>.
4630 In addition, several keys have their own names. Specifically,
4631 <DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
4632 when seen in this text, or in an init file (*note Readline Init
4636 File: bashref.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
4638 Readline Interaction
4639 ====================
4641 Often during an interactive session you type in a long line of text,
4642 only to notice that the first word on the line is misspelled. The
4643 Readline library gives you a set of commands for manipulating the text
4644 as you type it in, allowing you to just fix your typo, and not forcing
4645 you to retype the majority of the line. Using these editing commands,
4646 you move the cursor to the place that needs correction, and delete or
4647 insert the text of the corrections. Then, when you are satisfied with
4648 the line, you simply press <RETURN>. You do not have to be at the end
4649 of the line to press <RETURN>; the entire line is accepted regardless
4650 of the location of the cursor within the line.
4654 * Readline Bare Essentials:: The least you need to know about Readline.
4655 * Readline Movement Commands:: Moving about the input line.
4656 * Readline Killing Commands:: How to delete text, and how to get it back!
4657 * Readline Arguments:: Giving numeric arguments to commands.
4658 * Searching:: Searching through previous lines.
4661 File: bashref.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
4663 Readline Bare Essentials
4664 ------------------------
4666 In order to enter characters into the line, simply type them. The
4667 typed character appears where the cursor was, and then the cursor moves
4668 one space to the right. If you mistype a character, you can use your
4669 erase character to back up and delete the mistyped character.
4671 Sometimes you may miss typing a character that you wanted to type,
4672 and not notice your error until you have typed several other
4673 characters. In that case, you can type <C-b> to move the cursor to the
4674 left, and then correct your mistake. Afterwards, you can move the
4675 cursor to the right with <C-f>.
4677 When you add text in the middle of a line, you will notice that
4678 characters to the right of the cursor are `pushed over' to make room
4679 for the text that you have inserted. Likewise, when you delete text
4680 behind the cursor, characters to the right of the cursor are `pulled
4681 back' to fill in the blank space created by the removal of the text. A
4682 list of the basic bare essentials for editing the text of an input line
4686 Move back one character.
4689 Move forward one character.
4692 Delete the character to the left of the cursor.
4695 Delete the character underneath the cursor.
4698 Insert the character into the line at the cursor.
4701 Undo the last thing that you did. You can undo all the way back
4705 File: bashref.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
4707 Readline Movement Commands
4708 --------------------------
4710 The above table describes the most basic possible keystrokes that
4711 you need in order to do editing of the input line. For your
4712 convenience, many other commands have been added in addition to <C-b>,
4713 <C-f>, <C-d>, and <DEL>. Here are some commands for moving more rapidly
4717 Move to the start of the line.
4720 Move to the end of the line.
4723 Move forward a word.
4726 Move backward a word.
4729 Clear the screen, reprinting the current line at the top.
4731 Notice how <C-f> moves forward a character, while <M-f> moves
4732 forward a word. It is a loose convention that control keystrokes
4733 operate on characters while meta keystrokes operate on words.
4736 File: bashref.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
4738 Readline Killing Commands
4739 -------------------------
4741 "Killing" text means to delete the text from the line, but to save
4742 it away for later use, usually by "yanking" (re-inserting) it back into
4743 the line. If the description for a command says that it `kills' text,
4744 then you can be sure that you can get the text back in a different (or
4745 the same) place later.
4747 When you use a kill command, the text is saved in a "kill-ring".
4748 Any number of consecutive kills save all of the killed text together, so
4749 that when you yank it back, you get it all. The kill ring is not line
4750 specific; the text that you killed on a previously typed line is
4751 available to be yanked back later, when you are typing another line.
4753 Here is the list of commands for killing text.
4756 Kill the text from the current cursor position to the end of the
4760 Kill from the cursor to the end of the current word, or if between
4761 words, to the end of the next word.
4764 Kill from the cursor the start of the previous word, or if between
4765 words, to the start of the previous word.
4768 Kill from the cursor to the previous whitespace. This is
4769 different than <M-DEL> because the word boundaries differ.
4771 And, here is how to "yank" the text back into the line. Yanking
4772 means to copy the most-recently-killed text from the kill buffer.
4775 Yank the most recently killed text back into the buffer at the
4779 Rotate the kill-ring, and yank the new top. You can only do this
4780 if the prior command is <C-y> or <M-y>.
4783 File: bashref.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
4788 You can pass numeric arguments to Readline commands. Sometimes the
4789 argument acts as a repeat count, other times it is the sign of the
4790 argument that is significant. If you pass a negative argument to a
4791 command which normally acts in a forward direction, that command will
4792 act in a backward direction. For example, to kill text back to the
4793 start of the line, you might type `M-- C-k'.
4795 The general way to pass numeric arguments to a command is to type
4796 meta digits before the command. If the first `digit' you type is a
4797 minus sign (<->), then the sign of the argument will be negative. Once
4798 you have typed one meta digit to get the argument started, you can type
4799 the remainder of the digits, and then the command. For example, to give
4800 the <C-d> command an argument of 10, you could type `M-1 0 C-d'.
4803 File: bashref.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
4805 Searching for Commands in the History
4806 -------------------------------------
4808 Readline provides commands for searching through the command history
4809 (*note Bash History Facilities::.) for lines containing a specified
4810 string. There are two search modes: INCREMENTAL and NON-INCREMENTAL.
4812 Incremental searches begin before the user has finished typing the
4813 search string. As each character of the search string is typed,
4814 readline displays the next entry from the history matching the string
4815 typed so far. An incremental search requires only as many characters
4816 as needed to find the desired history entry. The Escape character is
4817 used to terminate an incremental search. Control-J will also terminate
4818 the search. Control-G will abort an incremental search and restore the
4819 original line. When the search is terminated, the history entry
4820 containing the search string becomes the current line. To find other
4821 matching entries in the history list, type Control-S or Control-R as
4822 appropriate. This will search backward or forward in the history for
4823 the next entry matching the search string typed so far. Any other key
4824 sequence bound to a readline command will terminate the search and
4825 execute that command. For instance, a `newline' will terminate the
4826 search and accept the line, thereby executing the command from the
4829 Non-incremental searches read the entire search string before
4830 starting to search for matching history lines. The search string may be
4831 typed by the user or part of the contents of the current line.
4834 File: bashref.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
4839 Although the Readline library comes with a set of `emacs'-like
4840 keybindings installed by default, it is possible that you would like to
4841 use a different set of keybindings. You can customize programs that
4842 use Readline by putting commands in an "inputrc" file in your home
4843 directory. The name of this file is taken from the value of the shell
4844 variable `INPUTRC'. If that variable is unset, the default is
4847 When a program which uses the Readline library starts up, the init
4848 file is read, and the key bindings are set.
4850 In addition, the `C-x C-r' command re-reads this init file, thus
4851 incorporating any changes that you might have made to it.
4855 * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
4857 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
4859 * Sample Init File:: An example inputrc file.
4862 File: bashref.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File
4864 Readline Init File Syntax
4865 -------------------------
4867 There are only a few basic constructs allowed in the Readline init
4868 file. Blank lines are ignored. Lines beginning with a `#' are
4869 comments. Lines beginning with a `$' indicate conditional constructs
4870 (*note Conditional Init Constructs::.). Other lines denote variable
4871 settings and key bindings.
4874 You can change the state of a few variables in Readline by using
4875 the `set' command within the init file. Here is how you would
4876 specify that you wish to use `vi' line editing commands:
4880 Right now, there are only a few variables which can be set; so
4881 few, in fact, that we just list them here:
4884 Controls what happens when Readline wants to ring the
4885 terminal bell. If set to `none', Readline never rings the
4886 bell. If set to `visible', Readline uses a visible bell if
4887 one is available. If set to `audible' (the default),
4888 Readline attempts to ring the terminal's bell.
4891 The string to insert at the beginning of the line when the
4892 `insert-comment' command is executed. The default value is
4895 `completion-query-items'
4896 The number of possible completions that determines when the
4897 user is asked whether he wants to see the list of
4898 possibilities. If the number of possible completions is
4899 greater than this value, Readline will ask the user whether
4900 or not he wishes to view them; otherwise, they are simply
4901 listed. The default limit is `100'.
4904 If set to `on', Readline will convert characters with the
4905 eigth bit set to an ASCII key sequence by stripping the eigth
4906 bit and prepending an <ESC> character, converting them to a
4907 meta-prefixed key sequence. The default value is `on'.
4909 `disable-completion'
4910 If set to `On', readline will inhibit word completion.
4911 Completion characters will be inserted into the line as if
4912 they had been mapped to `self-insert'. The default is `off'.
4915 The `editing-mode' variable controls which editing mode you
4916 are using. By default, Readline starts up in Emacs editing
4917 mode, where the keystrokes are most similar to Emacs. This
4918 variable can be set to either `emacs' or `vi'.
4921 When set to `on', readline will try to enable the application
4922 keypad when it is called. Some systems need this to enable
4923 the arrow keys. The default is `off'.
4926 If set to `on', tilde expansion is performed when Readline
4927 attempts word completion. The default is `off'.
4929 `horizontal-scroll-mode'
4930 This variable can be set to either `on' or `off'. Setting it
4931 to `on' means that the text of the lines that you edit will
4932 scroll horizontally on a single screen line when they are
4933 longer than the width of the screen, instead of wrapping onto
4934 a new screen line. By default, this variable is set to `off'.
4937 Sets Readline's idea of the current keymap for key binding
4938 commands. Acceptable `keymap' names are `emacs',
4939 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
4940 `vi-command', and `vi-insert'. `vi' is equivalent to
4941 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
4942 default value is `emacs'. The value of the `editing-mode'
4943 variable also affects the default keymap.
4946 If set to `on', completed directory names have a slash
4947 appended. The default is `on'.
4949 `mark-modified-lines'
4950 This variable, when set to `on', says to display an asterisk
4951 (`*') at the start of history lines which have been modified.
4952 This variable is `off' by default.
4955 If set to `on', Readline will enable eight-bit input (it will
4956 not strip the eighth bit from the characters it reads),
4957 regardless of what the terminal claims it can support. The
4958 default value is `off'. The name `meta-flag' is a synonym
4962 If set to `on', Readline will display characters with the
4963 eighth bit set directly rather than as a meta-prefixed escape
4964 sequence. The default is `off'.
4966 `show-all-if-ambiguous'
4967 This alters the default behavior of the completion functions.
4968 If set to `on', words which have more than one possible
4969 completion cause the matches to be listed immediately instead
4970 of ringing the bell. The default value is `off'.
4973 If set to `on', a character denoting a file's type is
4974 appended to the filename when listing possible completions.
4975 The default is `off'.
4978 The syntax for controlling key bindings in the init file is
4979 simple. First you have to know the name of the command that you
4980 want to change. The following pages contain tables of the command
4981 name, the default keybinding, and a short description of what the
4984 Once you know the name of the command, simply place the name of
4985 the key you wish to bind the command to, a colon, and then the
4986 name of the command on a line in the init file. The name of the
4987 key can be expressed in different ways, depending on which is most
4988 comfortable for you.
4990 KEYNAME: FUNCTION-NAME or MACRO
4991 KEYNAME is the name of a key spelled out in English. For
4993 Control-u: universal-argument
4994 Meta-Rubout: backward-kill-word
4995 Control-o: "> output"
4997 In the above example, `C-u' is bound to the function
4998 `universal-argument', and `C-o' is bound to run the macro
4999 expressed on the right hand side (that is, to insert the text
5000 `> output' into the line).
5002 "KEYSEQ": FUNCTION-NAME or MACRO
5003 KEYSEQ differs from KEYNAME above in that strings denoting an
5004 entire key sequence can be specified, by placing the key
5005 sequence in double quotes. Some GNU Emacs style key escapes
5006 can be used, as in the following example, but the special
5007 character names are not recognized.
5009 "\C-u": universal-argument
5010 "\C-x\C-r": re-read-init-file
5011 "\e[11~": "Function Key 1"
5013 In the above example, `C-u' is bound to the function
5014 `universal-argument' (just as it was in the first example),
5015 `C-x C-r' is bound to the function `re-read-init-file', and
5016 `ESC [ 1 1 ~' is bound to insert the text `Function Key 1'.
5017 The following escape sequences are available when specifying
5038 When entering the text of a macro, single or double quotes
5039 should be used to indicate a macro definition. Unquoted text
5040 is assumed to be a function name. Backslash will quote any
5041 character in the macro text, including `"' and `''. For
5042 example, the following binding will make `C-x \' insert a
5043 single `\' into the line:
5047 File: bashref.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File
5049 Conditional Init Constructs
5050 ---------------------------
5052 Readline implements a facility similar in spirit to the conditional
5053 compilation features of the C preprocessor which allows key bindings
5054 and variable settings to be performed as the result of tests. There
5055 are three parser directives used.
5058 The `$if' construct allows bindings to be made based on the
5059 editing mode, the terminal being used, or the application using
5060 Readline. The text of the test extends to the end of the line; no
5061 characters are required to isolate it.
5064 The `mode=' form of the `$if' directive is used to test
5065 whether Readline is in `emacs' or `vi' mode. This may be
5066 used in conjunction with the `set keymap' command, for
5067 instance, to set bindings in the `emacs-standard' and
5068 `emacs-ctlx' keymaps only if Readline is starting out in
5072 The `term=' form may be used to include terminal-specific key
5073 bindings, perhaps to bind the key sequences output by the
5074 terminal's function keys. The word on the right side of the
5075 `=' is tested against the full name of the terminal and the
5076 portion of the terminal name before the first `-'. This
5077 allows `sun' to match both `sun' and `sun-cmd', for instance.
5080 The APPLICATION construct is used to include
5081 application-specific settings. Each program using the
5082 Readline library sets the APPLICATION NAME, and you can test
5083 for it. This could be used to bind key sequences to
5084 functions useful for a specific program. For instance, the
5085 following command adds a key sequence that quotes the current
5086 or previous word in Bash:
5088 # Quote the current or previous word
5089 "\C-xq": "\eb\"\ef\""
5093 This command, as you saw in the previous example, terminates an
5097 Commands in this branch of the `$if' directive are executed if the
5101 File: bashref.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File
5106 Here is an example of an inputrc file. This illustrates key
5107 binding, variable assignment, and conditional syntax.
5110 # This file controls the behaviour of line input editing for
5111 # programs that use the Gnu Readline library. Existing programs
5112 # include FTP, Bash, and Gdb.
5114 # You can re-read the inputrc file with C-x C-r.
5115 # Lines beginning with '#' are comments.
5117 # Set various bindings for emacs mode.
5119 set editing-mode emacs
5123 Meta-Control-h: backward-kill-word Text after the function name is ignored
5126 # Arrow keys in keypad mode
5128 #"\M-OD": backward-char
5129 #"\M-OC": forward-char
5130 #"\M-OA": previous-history
5131 #"\M-OB": next-history
5133 # Arrow keys in ANSI mode
5135 "\M-[D": backward-char
5136 "\M-[C": forward-char
5137 "\M-[A": previous-history
5138 "\M-[B": next-history
5140 # Arrow keys in 8 bit keypad mode
5142 #"\M-\C-OD": backward-char
5143 #"\M-\C-OC": forward-char
5144 #"\M-\C-OA": previous-history
5145 #"\M-\C-OB": next-history
5147 # Arrow keys in 8 bit ANSI mode
5149 #"\M-\C-[D": backward-char
5150 #"\M-\C-[C": forward-char
5151 #"\M-\C-[A": previous-history
5152 #"\M-\C-[B": next-history
5158 # An old-style binding. This happens to be the default.
5161 # Macros that are convenient for shell interaction
5164 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
5165 # prepare to type a quoted word -- insert open and close double quotes
5166 # and move to just after the open quote
5167 "\C-x\"": "\"\"\C-b"
5168 # insert a backslash (testing backslash escapes in sequences and macros)
5170 # Quote the current or previous word
5171 "\C-xq": "\eb\"\ef\""
5172 # Add a binding to refresh the line, which is unbound
5173 "\C-xr": redraw-current-line
5174 # Edit variable on current line.
5175 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
5178 # use a visible bell if one is available
5179 set bell-style visible
5181 # don't strip characters to 7 bits when reading
5184 # allow iso-latin1 characters to be inserted rather than converted to
5185 # prefix-meta sequences
5186 set convert-meta off
5188 # display characters with the eighth bit set directly rather than
5189 # as meta-prefixed characters
5192 # if there are more than 150 possible completions for a word, ask the
5193 # user if he wants to see all of them
5194 set completion-query-items 150
5200 "\M-.": yank-last-arg
5204 File: bashref.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
5206 Bindable Readline Commands
5207 ==========================
5211 * Commands For Moving:: Moving about the line.
5212 * Commands For History:: Getting at previous lines.
5213 * Commands For Text:: Commands for changing text.
5214 * Commands For Killing:: Commands for killing and yanking.
5215 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
5216 * Commands For Completion:: Getting Readline to do the typing for you.
5217 * Keyboard Macros:: Saving and re-executing typed characters
5218 * Miscellaneous Commands:: Other miscellaneous commands.
5220 This section describes Readline commands that may be bound to key
5224 File: bashref.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
5229 `beginning-of-line (C-a)'
5230 Move to the start of the current line.
5233 Move to the end of the line.
5235 `forward-char (C-f)'
5236 Move forward a character.
5238 `backward-char (C-b)'
5239 Move back a character.
5241 `forward-word (M-f)'
5242 Move forward to the end of the next word. Words are composed of
5245 `backward-word (M-b)'
5246 Move back to the start of this, or the previous, word. Words are
5247 composed of letters and digits.
5249 `clear-screen (C-l)'
5250 Clear the screen and redraw the current line, leaving the current
5251 line at the top of the screen.
5253 `redraw-current-line ()'
5254 Refresh the current line. By default, this is unbound.
5257 File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
5259 Commands For Manipulating The History
5260 -------------------------------------
5262 `accept-line (Newline, Return)'
5263 Accept the line regardless of where the cursor is. If this line is
5264 non-empty, add it to the history list according to the setting of
5265 the `HISTCONTROL' variable. If this line was a history line, then
5266 restore the history line to its original state.
5268 `previous-history (C-p)'
5269 Move `up' through the history list.
5271 `next-history (C-n)'
5272 Move `down' through the history list.
5274 `beginning-of-history (M-<)'
5275 Move to the first line in the history.
5277 `end-of-history (M->)'
5278 Move to the end of the input history, i.e., the line you are
5281 `reverse-search-history (C-r)'
5282 Search backward starting at the current line and moving `up'
5283 through the history as necessary. This is an incremental search.
5285 `forward-search-history (C-s)'
5286 Search forward starting at the current line and moving `down'
5287 through the the history as necessary. This is an incremental
5290 `non-incremental-reverse-search-history (M-p)'
5291 Search backward starting at the current line and moving `up'
5292 through the history as necessary using a non-incremental search
5293 for a string supplied by the user.
5295 `non-incremental-forward-search-history (M-n)'
5296 Search forward starting at the current line and moving `down'
5297 through the the history as necessary using a non-incremental search
5298 for a string supplied by the user.
5300 `history-search-forward ()'
5301 Search forward through the history for the string of characters
5302 between the start of the current line and the current cursor
5303 position (the `point'). This is a non-incremental search. By
5304 default, this command is unbound.
5306 `history-search-backward ()'
5307 Search backward through the history for the string of characters
5308 between the start of the current line and the point. This is a
5309 non-incremental search. By default, this command is unbound.
5311 `yank-nth-arg (M-C-y)'
5312 Insert the first argument to the previous command (usually the
5313 second word on the previous line). With an argument N, insert the
5314 Nth word from the previous command (the words in the previous
5315 command begin with word 0). A negative argument inserts the Nth
5316 word from the end of the previous command.
5318 `yank-last-arg (M-., M-_)'
5319 Insert last argument to the previous command (the last word of the
5320 previous history entry). With an argument, behave exactly like
5324 File: bashref.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
5326 Commands For Changing Text
5327 --------------------------
5330 Delete the character under the cursor. If the cursor is at the
5331 beginning of the line, there are no characters in the line, and
5332 the last character typed was not `C-d', then return `EOF'.
5334 `backward-delete-char (Rubout)'
5335 Delete the character behind the cursor. A numeric arg says to kill
5336 the characters instead of deleting them.
5338 `quoted-insert (C-q, C-v)'
5339 Add the next character that you type to the line verbatim. This is
5340 how to insert key sequences like <C-q>, for example.
5342 `tab-insert (M-TAB)'
5343 Insert a tab character.
5345 `self-insert (a, b, A, 1, !, ...)'
5348 `transpose-chars (C-t)'
5349 Drag the character before the cursor forward over the character at
5350 the cursor, moving the cursor forward as well. If the insertion
5351 point is at the end of the line, then this transposes the last two
5352 characters of the line. Negative argumentss don't work.
5354 `transpose-words (M-t)'
5355 Drag the word behind the cursor past the word in front of the
5356 cursor moving the cursor over that word as well.
5359 Uppercase the current (or following) word. With a negative
5360 argument, do the previous word, but do not move the cursor.
5362 `downcase-word (M-l)'
5363 Lowercase the current (or following) word. With a negative
5364 argument, do the previous word, but do not move the cursor.
5366 `capitalize-word (M-c)'
5367 Capitalize the current (or following) word. With a negative
5368 argument, do the previous word, but do not move the cursor.
5371 File: bashref.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
5377 Kill the text from the current cursor position to the end of the
5380 `backward-kill-line (C-x Rubout)'
5381 Kill backward to the beginning of the line.
5383 `unix-line-discard (C-u)'
5384 Kill backward from the cursor to the beginning of the current line.
5385 Save the killed text on the kill-ring.
5387 `kill-whole-line ()'
5388 Kill all characters on the current line, no matter where the
5389 cursor is. By default, this is unbound.
5392 Kill from the cursor to the end of the current word, or if between
5393 words, to the end of the next word. Word boundaries are the same
5396 `backward-kill-word (M-DEL)'
5397 Kill the word behind the cursor. Word boundaries are the same as
5400 `unix-word-rubout (C-w)'
5401 Kill the word behind the cursor, using white space as a word
5402 boundary. The killed text is saved on the kill-ring.
5404 `delete-horizontal-space ()'
5405 Delete all spaces and tabs around point. By default, this is
5409 Kill the text between the point and the *mark* (saved cursor
5410 position. This text is referred to as the REGION. By default,
5411 this command is unbound.
5413 `copy-region-as-kill ()'
5414 Copy the text in the region to the kill buffer, so you can yank it
5415 right away. By default, this command is unbound.
5417 `copy-backward-word ()'
5418 Copy the word before point to the kill buffer. By default, this
5421 `copy-forward-word ()'
5422 Copy the word following point to the kill buffer. By default,
5423 this command is unbound.
5426 Yank the top of the kill ring into the buffer at the current
5430 Rotate the kill-ring, and yank the new top. You can only do this
5431 if the prior command is yank or yank-pop.
5434 File: bashref.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
5436 Specifying Numeric Arguments
5437 ----------------------------
5439 `digit-argument (M-0, M-1, ... M--)'
5440 Add this digit to the argument already accumulating, or start a new
5441 argument. <M-> starts a negative argument.
5443 `universal-argument ()'
5444 This is another way to specify an argument. If this command is
5445 followed by one or more digits, optionally with a leading minus
5446 sign, those digits define the argument. If the command is
5447 followed by digits, executing `universal-argument' again ends the
5448 numeric argument, but is otherwise ignored. As a special case, if
5449 this command is immediately followed by a character that is
5450 neither a digit or minus sign, the argument count for the next
5451 command is multiplied by four. The argument count is initially
5452 one, so executing this function the first time makes the argument
5453 count four, a second time makes the argument count sixteen, and so
5454 on. By default, this is not bound to a key.
5457 File: bashref.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
5459 Letting Readline Type For You
5460 -----------------------------
5463 Attempt to do completion on the text before the cursor. This is
5464 application-specific. Generally, if you are typing a filename
5465 argument, you can do filename completion; if you are typing a
5466 command, you can do command completion, if you are typing in a
5467 symbol to GDB, you can do symbol name completion, if you are
5468 typing in a variable to Bash, you can do variable name completion,
5469 and so on. Bash attempts completion treating the text as a
5470 variable (if the text begins with `$'), username (if the text
5471 begins with `~'), hostname (if the text begins with `@'), or
5472 command (including aliases and functions) in turn. If none of
5473 these produces a match, filename completion is attempted.
5475 `possible-completions (M-?)'
5476 List the possible completions of the text before the cursor.
5478 `insert-completions (M-*)'
5479 Insert all completions of the text before point that would have
5480 been generated by `possible-completions'.
5482 `complete-filename (M-/)'
5483 Attempt filename completion on the text before point.
5485 `possible-filename-completions (C-x /)'
5486 List the possible completions of the text before point, treating
5489 `complete-username (M-~)'
5490 Attempt completion on the text before point, treating it as a
5493 `possible-username-completions (C-x ~)'
5494 List the possible completions of the text before point, treating
5497 `complete-variable (M-$)'
5498 Attempt completion on the text before point, treating it as a
5501 `possible-variable-completions (C-x $)'
5502 List the possible completions of the text before point, treating
5503 it as a shell variable.
5505 `complete-hostname (M-@)'
5506 Attempt completion on the text before point, treating it as a
5509 `possible-hostname-completions (C-x @)'
5510 List the possible completions of the text before point, treating
5513 `complete-command (M-!)'
5514 Attempt completion on the text before point, treating it as a
5515 command name. Command completion attempts to match the text
5516 against aliases, reserved words, shell functions, builtins, and
5517 finally executable filenames, in that order.
5519 `possible-command-completions (C-x !)'
5520 List the possible completions of the text before point, treating
5521 it as a command name.
5523 `dynamic-complete-history (M-TAB)'
5524 Attempt completion on the text before point, comparing the text
5525 against lines from the history list for possible completion
5528 `complete-into-braces (M-{)'
5529 Perform filename completion and return the list of possible
5530 completions enclosed within braces so the list is available to the
5531 shell (*note Brace Expansion::.).
5534 File: bashref.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
5539 `start-kbd-macro (C-x ()'
5540 Begin saving the characters typed into the current keyboard macro.
5542 `end-kbd-macro (C-x ))'
5543 Stop saving the characters typed into the current keyboard macro
5544 and save the definition.
5546 `call-last-kbd-macro (C-x e)'
5547 Re-execute the last keyboard macro defined, by making the
5548 characters in the macro appear as if typed at the keyboard.
5551 File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
5553 Some Miscellaneous Commands
5554 ---------------------------
5556 `re-read-init-file (C-x C-r)'
5557 Read in the contents of the inputrc file, and incorporate any
5558 bindings or variable assignments found there.
5561 Abort the current editing command and ring the terminal's bell
5562 (subject to the setting of `bell-style').
5564 `do-uppercase-version (M-a, M-b, M-X, ...)'
5565 If the metafied character X is lowercase, run the command that is
5566 bound to the corresponding uppercase character.
5569 Make the next character that you type be metafied. This is for
5570 people without a meta key. Typing `ESC f' is equivalent to typing
5573 `undo (C-_, C-x C-u)'
5574 Incremental undo, separately remembered for each line.
5577 Undo all changes made to this line. This is like typing the `undo'
5578 command enough times to get back to the beginning.
5580 `tilde-expand (M-~)'
5581 Perform tilde expansion on the current word.
5584 Set the mark to the current point. If a numeric argument is
5585 supplied, the mark is set to that position.
5587 `exchange-point-and-mark (C-x C-x)'
5588 Swap the point with the mark. The current cursor position is set
5589 to the saved position, and the old cursor position is saved as the
5592 `character-search (C-])'
5593 A character is read and point is moved to the next occurrence of
5594 that character. A negative count searches for previous
5597 `character-search-backward (M-C-])'
5598 A character is read and point is moved to the previous occurrence
5599 of that character. A negative count searches for subsequent
5602 `insert-comment (M-#)'
5603 The value of the `comment-begin' variable is inserted at the
5604 beginning of the current line, and the line is accepted as if a
5605 newline had been typed. This makes the current line a shell
5609 Print all of the functions and their key bindings to the readline
5610 output stream. If a numeric argument is supplied, the output is
5611 formatted in such a way that it can be made part of an INPUTRC
5612 file. This command is unbound by default.
5615 Print all of the settable variables and their values to the
5616 readline output stream. If a numeric argument is supplied, the
5617 output is formatted in such a way that it can be made part of an
5618 INPUTRC file. This command is unbound by default.
5621 Print all of the readline key sequences bound to macros and the
5622 strings they ouput. If a numeric argument is supplied, the output
5623 is formatted in such a way that it can be made part of an INPUTRC
5624 file. This command is unbound by default.
5626 `glob-expand-word (C-x *)'
5627 The word before point is treated as a pattern for pathname
5628 expansion, and the list of matching file names is inserted,
5631 `glob-list-expansions (C-x g)'
5632 The list of expansions that would have been generated by
5633 `glob-expand-word' is inserted into the line, replacing the word
5636 `display-shell-version (C-x C-v)'
5637 Display version information about the current instance of Bash.
5639 `shell-expand-line (M-C-e)'
5640 Expand the line the way the shell does when it reads it. This
5641 performs alias and history expansion as well as all of the shell
5644 `history-expand-line (M-^)'
5645 Perform history expansion on the current line.
5648 Perform alias expansion on the current line (*note Aliases::.).
5650 `history-and-alias-expand-line'
5651 Perform history and alias expansion on the current line.
5653 `insert-last-argument (M-., M-_)'
5654 A synonym for `yank-last-arg'.
5656 `operate-and-get-next (C-o)'
5657 Accept the current line for execution and fetch the next line
5658 relative to the current line from the history for editing. Any
5659 argument is ignored.
5661 `emacs-editing-mode (C-e)'
5662 When in `vi' editing mode, this causes a switch back to `emacs'
5663 editing mode, as if the command `set -o emacs' had been executed.
5666 File: bashref.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
5671 While the Readline library does not have a full set of `vi' editing
5672 functions, it does contain enough to allow simple editing of the line.
5673 The Readline `vi' mode behaves as specified in the POSIX 1003.2
5676 In order to switch interactively between `emacs' and `vi' editing
5677 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
5678 Builtin::.). The Readline default is `emacs' mode.
5680 When you enter a line in `vi' mode, you are already placed in
5681 `insertion' mode, as if you had typed an `i'. Pressing <ESC> switches
5682 you into `command' mode, where you can edit the text of the line with
5683 the standard `vi' movement keys, move to previous history lines with
5684 `k' and subsequent lines with `j', and so forth.
5687 File: bashref.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Command Line Editing, Up: Top
5692 This chapter provides basic instructions for installing Bash on the
5693 various supported platforms. The distribution supports nearly every
5694 version of Unix (and, someday, GNU). Other independent ports exist for
5695 OS/2, Windows 95, and Windows NT.
5699 * Basic Installation:: Installation instructions.
5701 * Compilers and Options:: How to set special options for various
5704 * Compiling For Multiple Architectures:: How to compile Bash for more
5705 than one kind of system from
5706 the same source tree.
5708 * Installation Names:: How to set the various paths used by the installation.
5710 * Specifying the System Type:: How to configure Bash for a particular system.
5712 * Sharing Defaults:: How to share default configuration values among GNU
5715 * Operation Controls:: Options recognized by the configuration program.
5717 * Optional Features:: How to enable and disable optional features when
5721 File: bashref.info, Node: Basic Installation, Next: Compilers and Options, Up: Installing Bash
5726 These are installation instructions for Bash.
5728 The `configure' shell script attempts to guess correct values for
5729 various system-dependent variables used during compilation. It uses
5730 those values to create a `Makefile' in each directory of the package
5731 (the top directory, the `builtins' and `doc' directories, and the each
5732 directory under `lib'). It also creates a `config.h' file containing
5733 system-dependent definitions. Finally, it creates a shell script named
5734 `config.status' that you can run in the future to recreate the current
5735 configuration, a file `config.cache' that saves the results of its
5736 tests to speed up reconfiguring, and a file `config.log' containing
5737 compiler output (useful mainly for debugging `configure'). If at some
5738 point `config.cache' contains results you don't want to keep, you may
5741 If you need to do unusual things to compile the package, please try
5742 to figure out how `configure' could check whether or not to do them,
5743 and mail diffs or instructions to `bash-maintainers@prep.ai.mit.edu' so
5744 they can be considered for the next release.
5746 The file `configure.in' is used to create `configure' by a program
5747 called Autoconf. You only need `configure.in' if you want to change it
5748 or regenerate `configure' using a newer version of Autoconf. If you do
5749 this, make sure you are using Autoconf version 2.10 or newer.
5751 If you need to change `configure.in' or regenerate `configure', you
5752 will need to create two files: `_distribution' and `_patchlevel'.
5753 `_distribution' should contain the major and minor version numbers of
5754 the Bash distribution, for example `2.01'. `_patchlevel' should
5755 contain the patch level of the Bash distribution, `0' for example. The
5756 script `support/mkconffiles' has been provided to automate the creation
5759 The simplest way to compile Bash is:
5761 1. `cd' to the directory containing the source code and type
5762 `./configure' to configure Bash for your system. If you're using
5763 `csh' on an old version of System V, you might need to type `sh
5764 ./configure' instead to prevent `csh' from trying to execute
5767 Running `configure' takes awhile. While running, it prints some
5768 messages telling which features it is checking for.
5770 2. Type `make' to compile Bash and build the `bashbug' bug reporting
5773 3. Optionally, type `make tests' to run the Bash test suite.
5775 4. Type `make install' to install `bash' and `bashbug'. This will
5776 also install the manual pages and Info file.
5779 You can remove the program binaries and object files from the source
5780 code directory by typing `make clean'. To also remove the files that
5781 `configure' created (so you can compile Bash for a different kind of
5782 computer), type `make distclean'.
5785 File: bashref.info, Node: Compilers and Options, Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
5787 Compilers and Options
5788 =====================
5790 Some systems require unusual options for compilation or linking that
5791 the `configure' script does not know about. You can give `configure'
5792 initial values for variables by setting them in the environment. Using
5793 a Bourne-compatible shell, you can do that on the command line like
5796 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
5798 On systems that have the `env' program, you can do it like this:
5800 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
5802 The configuration process uses GCC to build Bash if it is available.
5805 File: bashref.info, Node: Compiling For Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
5807 Compiling For Multiple Architectures
5808 ====================================
5810 You can compile Bash for more than one kind of computer at the same
5811 time, by placing the object files for each architecture in their own
5812 directory. To do this, you must use a version of `make' that supports
5813 the `VPATH' variable, such as GNU `make'. `cd' to the directory where
5814 you want the object files and executables to go and run the `configure'
5815 script from the source directory. You may need to supply the
5816 `--srcdir=PATH' argument to tell `configure' where the source files
5817 are. `configure' automatically checks for the source code in the
5818 directory that `configure' is in and in `..'.
5820 If you have to use a `make' that does not supports the `VPATH'
5821 variable, you can compile Bash for one architecture at a time in the
5822 source code directory. After you have installed Bash for one
5823 architecture, use `make distclean' before reconfiguring for another
5826 Alternatively, if your system supports symbolic links, you can use
5827 the `support/mkclone' script to create a build tree which has symbolic
5828 links back to each file in the source directory. Here's an example
5829 that creates a build directory in the current directory from a source
5830 directory `/usr/gnu/src/bash-2.0':
5832 bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
5834 The `mkclone' script requires Bash, so you must have already built Bash
5835 for at least one architecture before you can create build directories
5836 for other architectures.
5839 File: bashref.info, Node: Installation Names, Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
5844 By default, `make install' will install into `/usr/local/bin',
5845 `/usr/local/man', etc. You can specify an installation prefix other
5846 than `/usr/local' by giving `configure' the option `--prefix=PATH'.
5848 You can specify separate installation prefixes for
5849 architecture-specific files and architecture-independent files. If you
5850 give `configure' the option `--exec-prefix=PATH', the package will use
5851 `PATH' as the prefix for installing programs and libraries.
5852 Documentation and other data files will still use the regular prefix.
5855 File: bashref.info, Node: Specifying the System Type, Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
5857 Specifying the System Type
5858 ==========================
5860 There may be some features `configure' can not figure out
5861 automatically, but needs to determine by the type of host the package
5862 will run on. Usually `configure' can figure that out, but if it prints
5863 a message saying it can not guess the host type, give it the
5864 `--host=TYPE' option. `TYPE' can either be a short name for the system
5865 type, such as `sun4', or a canonical name with three fields:
5866 `CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2').
5868 See the file `support/config.sub' for the possible values of each field.
5871 File: bashref.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
5876 If you want to set default values for `configure' scripts to share,
5877 you can create a site shell script called `config.site' that gives
5878 default values for variables like `CC', `cache_file', and `prefix'.
5879 `configure' looks for `PREFIX/share/config.site' if it exists, then
5880 `PREFIX/etc/config.site' if it exists. Or, you can set the
5881 `CONFIG_SITE' environment variable to the location of the site script.
5882 A warning: the Bash `configure' looks for a site script, but not all
5883 `configure' scripts do.
5886 File: bashref.info, Node: Operation Controls, Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
5891 `configure' recognizes the following options to control how it
5895 Use and save the results of the tests in FILE instead of
5896 `./config.cache'. Set FILE to `/dev/null' to disable caching, for
5897 debugging `configure'.
5900 Print a summary of the options to `configure', and exit.
5905 Do not print messages saying which checks are being made.
5908 Look for the Bash source code in directory DIR. Usually
5909 `configure' can determine that directory automatically.
5912 Print the version of Autoconf used to generate the `configure'
5915 `configure' also accepts some other, not widely used, boilerplate
5919 File: bashref.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash
5924 The Bash `configure' has a number of `--enable-FEATURE' options,
5925 where FEATURE indicates an optional part of the package. There are
5926 also several `--with-PACKAGE' options, where PACKAGE is something like
5927 `gnu-malloc' or `purify' (for the Purify memory allocation checker). To
5928 turn off the default use of a package, use `--without-PACKAGE'. To
5929 configure Bash without a feature that is enabled by default, use
5930 `--disable-FEATURE'.
5932 Here is a complete list of the `--enable-' and `--with-' options
5933 that the Bash `configure' recognizes.
5936 Define if you are using the Andrew File System from Transarc.
5939 Use the curses library instead of the termcap library. This should
5940 be supplied if your system has an inadequate or incomplete termcap
5943 `--with-glibc-malloc'
5944 Use the GNU libc version of `malloc' in `lib/malloc/gmalloc.c'.
5945 This is somewhat slower than the default `malloc', but wastes
5946 considerably less space.
5949 Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
5950 not the same `malloc' that appears in GNU libc, but an older
5951 version derived from the 4.2 BSD `malloc'. This `malloc' is very
5952 fast, but wastes a lot of space. This option is enabled by
5953 default. The `NOTES' file contains a list of systems for which
5954 this should be turned off, and `configure' disables this option
5955 automatically for a number of systems.
5958 Define this to use the Purify memory allocation checker from Pure
5961 `--enable-minimal-config'
5962 This produces a shell with minimal features, close to the
5963 historical Bourne shell.
5965 The `minimal-config' option can be used to disable all of the following
5966 options, but it is processed first, so individual options may be
5967 enabled using `enable-FEATURE'.
5969 All of the following options except for `disabled-builtins' and
5970 `usg-echo-default' are enabled by default, unless the operating system
5971 does not provide the necessary support.
5974 Allow alias expansion and include the `alias' and `unalias'
5977 `--enable-array-variables'
5978 Include support for one-dimensional array shell variables.
5980 `--enable-bang-history'
5981 Include support for `csh'-like history substitution.
5983 `--enable-brace-expansion'
5984 Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
5986 `--enable-command-timing'
5987 Include support for recognizing `time' as a reserved word and for
5988 displaying timing statistics for the pipeline following `time'.
5989 This allows pipelines as well as shell builtins and functions to
5992 `--enable-directory-stack'
5993 Include support for a `csh'-like directory stack and the `pushd',
5994 `popd', and `dirs' builtins.
5996 `--enable-disabled-builtins'
5997 Allow builtin commands to be invoked via `builtin xxx' even after
5998 `xxx' has been disabled using `enable -n xxx'. See *Note Bash
5999 Builtins::, for details of the `builtin' and `enable' builtin
6002 `--enable-dparen-arithmetic'
6003 Include support for the `ksh' `((...))' command.
6005 `--enable-help-builtin'
6006 Include the `help' builtin, which displays help on shell builtins
6010 Include command history and the `fc' and `history' builtin
6013 `--enable-job-control'
6014 This enables job control features, if the OS supports them.
6016 `--enable-process-substitution'
6017 This enables process substitution (*note Process Substitution::.)
6018 if the OS provides the necessary support.
6020 `--enable-prompt-string-decoding'
6021 Turn on the interpretation of a number of backslash-escaped
6022 characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
6026 Include support for command-line editing and history with the Bash
6027 version of the Readline library.
6029 `--enable-restricted'
6030 Include support for a "restricted shell". If this is enabled,
6031 Bash, when called as `rbash', enters a restricted mode. See *Note
6032 The Restricted Shell::, for a description of restricted mode.
6035 Include the `ksh' `select' builtin, which allows the generation of
6038 `--enable-usg-echo-default'
6039 Make the `echo' builtin expand backslash-escaped characters by
6040 default, without requiring the `-e' option. This makes the Bash
6041 `echo' behave more like the System V version.
6043 The file `config.h.top' contains C Preprocessor `#define' statements
6044 for options which are not settable from `configure'. Some of these are
6045 not meant to be changed; beware of the consequences if you do. Read
6046 the comments associated with each definition for more information about
6050 File: bashref.info, Node: Reporting Bugs, Next: Builtin Index, Prev: Installing Bash, Up: Top
6055 Please report all bugs you find in Bash. But first, you should make
6056 sure that it really is a bug, and that it appears in the latest version
6057 of Bash that you have.
6059 Once you have determined that a bug actually exists, use the
6060 `bashbug' command to submit a bug report. If you have a fix, you are
6061 encouraged to mail that as well! Suggestions and `philosophical' bug
6062 reports may be mailed to `bug-bash@prep.ai.MIT.Edu' or posted to the
6063 Usenet newsgroup `gnu.bash.bug'.
6065 All bug reports should include:
6066 * The version number of Bash.
6068 * The hardware and operating system.
6070 * The compiler used to compile Bash.
6072 * A description of the bug behaviour.
6074 * A short script or `recipe' which exercises the bug and may be used
6077 `bashbug' inserts the first three items automatically into the template
6078 it provides for filing a bug report.
6080 Please send all reports concerning this manual to
6081 `chet@ins.CWRU.Edu'.
6084 File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Prev: Reporting Bugs, Up: Top
6086 Index of Shell Builtin Commands
6087 *******************************
6091 * .: Bourne Shell Builtins.
6092 * :: Bourne Shell Builtins.
6093 * [: Bourne Shell Builtins.
6094 * alias: Alias Builtins.
6095 * bg: Job Control Builtins.
6096 * bind: Bash Builtins.
6097 * break: Bourne Shell Builtins.
6098 * builtin: Bash Builtins.
6099 * cd: Bourne Shell Builtins.
6100 * command: Bash Builtins.
6101 * continue: Bourne Shell Builtins.
6102 * declare: Bash Builtins.
6103 * dirs: C Shell Builtins.
6104 * disown: Job Control Builtins.
6105 * echo: Bash Builtins.
6106 * enable: Bash Builtins.
6107 * eval: Bourne Shell Builtins.
6108 * exec: Bourne Shell Builtins.
6109 * exit: Bourne Shell Builtins.
6110 * export: Bourne Shell Builtins.
6111 * fc: Korn Shell Builtins.
6112 * fg: Job Control Builtins.
6113 * getopts: Bourne Shell Builtins.
6114 * hash: Bourne Shell Builtins.
6115 * help: Bash Builtins.
6116 * history: C Shell Builtins.
6117 * jobs: Job Control Builtins.
6118 * kill: Job Control Builtins.
6119 * let <1>: Arithmetic Builtins.
6120 * let: Korn Shell Builtins.
6121 * local: Bash Builtins.
6122 * logout <1>: Bash Builtins.
6123 * logout: C Shell Builtins.
6124 * popd: C Shell Builtins.
6125 * pushd: C Shell Builtins.
6126 * pwd: Bourne Shell Builtins.
6127 * read: Bash Builtins.
6128 * readonly: Bourne Shell Builtins.
6129 * return: Bourne Shell Builtins.
6130 * set: The Set Builtin.
6131 * shift: Bourne Shell Builtins.
6132 * shopt: Bash Builtins.
6133 * source: C Shell Builtins.
6134 * suspend: Job Control Builtins.
6135 * test: Bourne Shell Builtins.
6136 * times: Bourne Shell Builtins.
6137 * trap: Bourne Shell Builtins.
6138 * type: Bash Builtins.
6139 * typeset: Korn Shell Builtins.
6140 * ulimit: Bash Builtins.
6141 * umask: Bourne Shell Builtins.
6142 * unalias: Alias Builtins.
6143 * unset: Bourne Shell Builtins.
6144 * wait: Job Control Builtins.
6147 File: bashref.info, Node: Reserved Word Index, Next: Variable Index, Prev: Builtin Index, Up: Top
6149 Shell Reserved Words
6150 ********************
6155 * case: Conditional Constructs.
6156 * do: Looping Constructs.
6157 * done: Looping Constructs.
6158 * elif: Conditional Constructs.
6159 * else: Conditional Constructs.
6160 * esac: Conditional Constructs.
6161 * fi: Conditional Constructs.
6162 * for: Looping Constructs.
6163 * function: Shell Functions.
6164 * if: Conditional Constructs.
6165 * in: Conditional Constructs.
6166 * select: Korn Shell Constructs.
6167 * then: Conditional Constructs.
6169 * until: Looping Constructs.
6170 * while: Looping Constructs.
6171 * {: Command Grouping.
6172 * }: Command Grouping.
6175 File: bashref.info, Node: Variable Index, Next: Function Index, Prev: Reserved Word Index, Up: Top
6177 Parameter and Variable Index
6178 ****************************
6182 * !: Special Parameters.
6183 * #: Special Parameters.
6184 * $: Special Parameters.
6185 * *: Special Parameters.
6186 * -: Special Parameters.
6187 * 0: Special Parameters.
6188 * ?: Special Parameters.
6189 * @: Special Parameters.
6190 * _: Special Parameters.
6191 * auto_resume: Job Control Variables.
6192 * BASH: Bash Variables.
6193 * BASH_ENV: Bash Variables.
6194 * BASH_VERSINFO: Bash Variables.
6195 * BASH_VERSION: Bash Variables.
6196 * bell-style: Readline Init File Syntax.
6197 * CDPATH: Bourne Shell Variables.
6198 * comment-begin: Readline Init File Syntax.
6199 * completion-query-items: Readline Init File Syntax.
6200 * convert-meta: Readline Init File Syntax.
6201 * DIRSTACK: Bash Variables.
6202 * disable-completion: Readline Init File Syntax.
6203 * editing-mode: Readline Init File Syntax.
6204 * enable-keypad: Readline Init File Syntax.
6205 * EUID: Bash Variables.
6206 * expand-tilde: Readline Init File Syntax.
6207 * FCEDIT: Korn Shell Variables.
6208 * FIGNORE: Bash Variables.
6209 * GLOBIGNORE: Bash Variables.
6210 * GROUPS: Bash Variables.
6211 * histchars: Bash Variables.
6212 * HISTCMD: Bash Variables.
6213 * HISTCONTROL: Bash Variables.
6214 * HISTFILE: Bash Variables.
6215 * HISTFILESIZE: Bash Variables.
6216 * HISTIGNORE: Bash Variables.
6217 * HISTSIZE: Bash Variables.
6218 * HOME: Bourne Shell Variables.
6219 * horizontal-scroll-mode: Readline Init File Syntax.
6220 * HOSTFILE: Bash Variables.
6221 * HOSTNAME: Bash Variables.
6222 * HOSTTYPE: Bash Variables.
6223 * IFS: Bourne Shell Variables.
6224 * IGNOREEOF <1>: Bash Variables.
6225 * IGNOREEOF: C Shell Variables.
6226 * input-meta: Readline Init File Syntax.
6227 * INPUTRC: Bash Variables.
6228 * keymap: Readline Init File Syntax.
6229 * LANG: Bash Variables.
6230 * LC_ALL: Bash Variables.
6231 * LC_COLLATE: Bash Variables.
6232 * LC_MESSAGES: Bash Variables.
6233 * LINENO: Korn Shell Variables.
6234 * MACHTYPE: Bash Variables.
6235 * MAIL: Bourne Shell Variables.
6236 * MAILCHECK: Bash Variables.
6237 * MAILPATH: Bourne Shell Variables.
6238 * mark-modified-lines: Readline Init File Syntax.
6239 * meta-flag: Readline Init File Syntax.
6240 * OLDPWD: Korn Shell Variables.
6241 * OPTARG: Bourne Shell Variables.
6242 * OPTERR: Bash Variables.
6243 * OPTIND: Bourne Shell Variables.
6244 * OSTYPE: Bash Variables.
6245 * output-meta: Readline Init File Syntax.
6246 * PATH: Bourne Shell Variables.
6247 * PIPESTATUS: Bash Variables.
6248 * PPID: Bash Variables.
6249 * PROMPT_COMMAND: Bash Variables.
6250 * PS1: Bourne Shell Variables.
6251 * PS2: Bourne Shell Variables.
6252 * PS3: Korn Shell Variables.
6253 * PS4: Korn Shell Variables.
6254 * PWD: Korn Shell Variables.
6255 * RANDOM: Korn Shell Variables.
6256 * REPLY: Korn Shell Variables.
6257 * SECONDS: Korn Shell Variables.
6258 * SHELLOPTS: Bash Variables.
6259 * SHLVL: Bash Variables.
6260 * show-all-if-ambiguous: Readline Init File Syntax.
6261 * TIMEFORMAT: Bash Variables.
6262 * TMOUT: Korn Shell Variables.
6263 * UID: Bash Variables.
6264 * visible-stats: Readline Init File Syntax.
6267 File: bashref.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Top
6274 * abort (C-g): Miscellaneous Commands.
6275 * accept-line (Newline, Return): Commands For History.
6276 * backward-char (C-b): Commands For Moving.
6277 * backward-delete-char (Rubout): Commands For Text.
6278 * backward-kill-line (C-x Rubout): Commands For Killing.
6279 * backward-kill-word (M-DEL): Commands For Killing.
6280 * backward-word (M-b): Commands For Moving.
6281 * beginning-of-history (M-<): Commands For History.
6282 * beginning-of-line (C-a): Commands For Moving.
6283 * call-last-kbd-macro (C-x e): Keyboard Macros.
6284 * capitalize-word (M-c): Commands For Text.
6285 * character-search (C-]): Miscellaneous Commands.
6286 * character-search-backward (M-C-]): Miscellaneous Commands.
6287 * clear-screen (C-l): Commands For Moving.
6288 * complete (TAB): Commands For Completion.
6289 * copy-backward-word (): Commands For Killing.
6290 * copy-forward-word (): Commands For Killing.
6291 * copy-region-as-kill (): Commands For Killing.
6292 * delete-char (C-d): Commands For Text.
6293 * delete-horizontal-space (): Commands For Killing.
6294 * digit-argument (M-0, M-1, ... M--): Numeric Arguments.
6295 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
6296 * downcase-word (M-l): Commands For Text.
6297 * dump-functions (): Miscellaneous Commands.
6298 * dump-macros (): Miscellaneous Commands.
6299 * dump-variables (): Miscellaneous Commands.
6300 * end-kbd-macro (C-x )): Keyboard Macros.
6301 * end-of-history (M->): Commands For History.
6302 * end-of-line (C-e): Commands For Moving.
6303 * exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
6304 * forward-char (C-f): Commands For Moving.
6305 * forward-search-history (C-s): Commands For History.
6306 * forward-word (M-f): Commands For Moving.
6307 * history-search-backward (): Commands For History.
6308 * history-search-forward (): Commands For History.
6309 * insert-comment (M-#): Miscellaneous Commands.
6310 * insert-completions (M-*): Commands For Completion.
6311 * kill-line (C-k): Commands For Killing.
6312 * kill-region (): Commands For Killing.
6313 * kill-whole-line (): Commands For Killing.
6314 * kill-word (M-d): Commands For Killing.
6315 * next-history (C-n): Commands For History.
6316 * non-incremental-forward-search-history (M-n): Commands For History.
6317 * non-incremental-reverse-search-history (M-p): Commands For History.
6318 * possible-completions (M-?): Commands For Completion.
6319 * prefix-meta (ESC): Miscellaneous Commands.
6320 * previous-history (C-p): Commands For History.
6321 * quoted-insert (C-q, C-v): Commands For Text.
6322 * re-read-init-file (C-x C-r): Miscellaneous Commands.
6323 * redraw-current-line (): Commands For Moving.
6324 * reverse-search-history (C-r): Commands For History.
6325 * revert-line (M-r): Miscellaneous Commands.
6326 * self-insert (a, b, A, 1, !, ...): Commands For Text.
6327 * set-mark (C-@): Miscellaneous Commands.
6328 * start-kbd-macro (C-x (): Keyboard Macros.
6329 * tab-insert (M-TAB): Commands For Text.
6330 * tilde-expand (M-~): Miscellaneous Commands.
6331 * transpose-chars (C-t): Commands For Text.
6332 * transpose-words (M-t): Commands For Text.
6333 * undo (C-_, C-x C-u): Miscellaneous Commands.
6334 * universal-argument (): Numeric Arguments.
6335 * unix-line-discard (C-u): Commands For Killing.
6336 * unix-word-rubout (C-w): Commands For Killing.
6337 * upcase-word (M-u): Commands For Text.
6338 * yank (C-y): Commands For Killing.
6339 * yank-last-arg (M-., M-_): Commands For History.
6340 * yank-nth-arg (M-C-y): Commands For History.
6341 * yank-pop (M-y): Commands For Killing.
6344 File: bashref.info, Node: Concept Index, Prev: Function Index, Up: Top
6351 * alias expansion: Aliases.
6352 * arithmetic evaluation: Arithmetic Evaluation.
6353 * arithmetic expansion: Arithmetic Expansion.
6354 * arithmetic, shell: Shell Arithmetic.
6356 * background: Job Control Basics.
6357 * Bash configuration: Basic Installation.
6358 * Bash installation: Basic Installation.
6359 * Bourne shell: Basic Shell Features.
6360 * brace expansion: Brace Expansion.
6361 * builtin: Definitions.
6362 * command editing: Readline Bare Essentials.
6363 * command execution: Command Search and Execution.
6364 * command history: Bash History Facilities.
6365 * command search: Command Search and Execution.
6366 * command substitution: Command Substitution.
6367 * command timing: Pipelines.
6368 * commands, conditional: Conditional Constructs.
6369 * commands, grouping: Command Grouping.
6370 * commands, lists: Lists.
6371 * commands, looping: Looping Constructs.
6372 * commands, pipelines: Pipelines.
6373 * commands, simple: Simple Commands.
6374 * comments, shell: Comments.
6375 * configuration: Basic Installation.
6376 * control operator: Definitions.
6377 * editing command lines: Readline Bare Essentials.
6378 * environment: Environment.
6379 * evaluation, arithmetic: Arithmetic Evaluation.
6380 * event designators: Event Designators.
6381 * exit status <1>: Definitions.
6382 * exit status: Exit Status.
6383 * expansion: Shell Expansions.
6384 * expansion, arithmetic: Arithmetic Expansion.
6385 * expansion, brace: Brace Expansion.
6386 * expansion, filename: Filename Expansion.
6387 * expansion, parameter: Shell Parameter Expansion.
6388 * expansion, pathname: Filename Expansion.
6389 * expansion, tilde: Tilde Expansion.
6390 * expressions, arithmetic: Arithmetic Evaluation.
6391 * expressions, conditional: Bash Conditional Expressions.
6392 * field: Definitions.
6393 * filename: Definitions.
6394 * filename expansion: Filename Expansion.
6395 * foreground: Job Control Basics.
6396 * functions, shell: Shell Functions.
6397 * history events: Event Designators.
6398 * history expansion: History Interaction.
6399 * history list: Bash History Facilities.
6400 * History, how to use: Job Control Variables.
6401 * identifier: Definitions.
6402 * initialization file, readline: Readline Init File.
6403 * installation: Basic Installation.
6404 * interaction, readline: Readline Interaction.
6405 * interactive shell <1>: Is This Shell Interactive?.
6406 * interactive shell: Invoking Bash.
6408 * job control <1>: Definitions.
6409 * job control: Job Control Basics.
6410 * kill ring: Readline Killing Commands.
6411 * killing text: Readline Killing Commands.
6412 * localization: Locale Translation.
6413 * metacharacter: Definitions.
6414 * name: Definitions.
6415 * notation, readline: Readline Bare Essentials.
6416 * operator, shell: Definitions.
6417 * parameter expansion: Shell Parameter Expansion.
6418 * parameters: Shell Parameters.
6419 * parameters, positional: Positional Parameters.
6420 * parameters, special: Special Parameters.
6421 * pathname expansion: Filename Expansion.
6422 * pipeline: Pipelines.
6423 * POSIX: Definitions.
6424 * POSIX Mode: Bash POSIX Mode.
6425 * process group: Definitions.
6426 * process group ID: Definitions.
6427 * process substitution: Process Substitution.
6428 * prompting: Printing a Prompt.
6430 * quoting, ANSI: ANSI-C Quoting.
6431 * Readline, how to use: Modifiers.
6432 * redirection: Redirections.
6433 * reserved word: Definitions.
6434 * restricted shell: The Restricted Shell.
6435 * return status: Definitions.
6436 * shell function: Shell Functions.
6437 * shell script: Shell Scripts.
6438 * shell variable: Shell Parameters.
6439 * signal: Definitions.
6440 * signal handling: Signals.
6441 * special builtin: Definitions.
6442 * startup files: Bash Startup Files.
6443 * suspending jobs: Job Control Basics.
6444 * tilde expansion: Tilde Expansion.
6445 * token: Definitions.
6446 * variable, shell: Shell Parameters.
6447 * word: Definitions.
6448 * word splitting: Word Splitting.
6449 * yanking text: Readline Killing Commands.
6455 Node: Introduction
\7f3283
6456 Node: What is Bash?
\7f3508
6457 Node: What is a shell?
\7f4592
6458 Node: Definitions
\7f6473
6459 Node: Basic Shell Features
\7f9134
6460 Node: Shell Syntax
\7f10655
6461 Node: Shell Operation
\7f10945
6462 Node: Quoting
\7f12179
6463 Node: Escape Character
\7f13214
6464 Node: Single Quotes
\7f13645
6465 Node: Double Quotes
\7f13974
6466 Node: ANSI-C Quoting
\7f14670
6467 Node: Locale Translation
\7f15402
6468 Node: Comments
\7f15823
6469 Node: Simple Commands
\7f16347
6470 Node: Pipelines
\7f16936
6472 Node: Looping Constructs
\7f19282
6473 Node: Conditional Constructs
\7f20459
6474 Node: Command Grouping
\7f22526
6475 Node: Shell Functions
\7f23912
6476 Node: Shell Parameters
\7f25685
6477 Node: Positional Parameters
\7f27008
6478 Node: Special Parameters
\7f27702
6479 Node: Shell Expansions
\7f30268
6480 Node: Shell Parameter Expansion
\7f32272
6481 Node: Command Substitution
\7f38280
6482 Node: Process Substitution
\7f39280
6483 Node: Word Splitting
\7f40186
6484 Node: Filename Expansion
\7f41638
6485 Node: Quote Removal
\7f44004
6486 Node: Redirections
\7f44290
6487 Node: Executing Commands
\7f50031
6488 Node: Command Search and Execution
\7f50486
6489 Node: Environment
\7f52220
6490 Node: Exit Status
\7f53856
6491 Node: Signals
\7f54873
6492 Node: Shell Scripts
\7f56084
6493 Node: Bourne Shell Features
\7f57953
6494 Node: Bourne Shell Builtins
\7f58623
6495 Node: Bourne Shell Variables
\7f66977
6496 Node: Other Bourne Shell Features
\7f68514
6497 Node: Major Differences From The Bourne Shell
\7f69271
6498 Node: Csh Features
\7f79631
6499 Node: Brace Expansion
\7f80549
6500 Node: Tilde Expansion
\7f82104
6501 Node: C Shell Builtins
\7f82736
6502 Node: C Shell Variables
\7f87292
6503 Node: Korn Shell Features
\7f87700
6504 Node: Korn Shell Constructs
\7f88428
6505 Node: Korn Shell Builtins
\7f90143
6506 Node: Korn Shell Variables
\7f92301
6507 Node: Aliases
\7f93860
6508 Node: Alias Builtins
\7f96326
6509 Node: Bash Features
\7f96942
6510 Node: Invoking Bash
\7f97933
6511 Node: Bash Startup Files
\7f101798
6512 Node: Is This Shell Interactive?
\7f105373
6513 Node: Bash Builtins
\7f106356
6514 Node: The Set Builtin
\7f122211
6515 Node: Bash Conditional Expressions
\7f127586
6516 Node: Bash Variables
\7f132237
6517 Node: Shell Arithmetic
\7f142271
6518 Node: Arithmetic Evaluation
\7f142739
6519 Node: Arithmetic Expansion
\7f144769
6520 Node: Arithmetic Builtins
\7f145573
6521 Node: Arrays
\7f146044
6522 Node: Printing a Prompt
\7f149071
6523 Node: The Restricted Shell
\7f150669
6524 Node: Bash POSIX Mode
\7f151899
6525 Node: Job Control
\7f155583
6526 Node: Job Control Basics
\7f156048
6527 Node: Job Control Builtins
\7f160191
6528 Node: Job Control Variables
\7f163114
6529 Node: Using History Interactively
\7f164261
6530 Node: Bash History Facilities
\7f164850
6531 Node: History Interaction
\7f167248
6532 Node: Event Designators
\7f169810
6533 Node: Word Designators
\7f170737
6534 Node: Modifiers
\7f171986
6535 Node: Command Line Editing
\7f173303
6536 Node: Introduction and Notation
\7f173963
6537 Node: Readline Interaction
\7f175001
6538 Node: Readline Bare Essentials
\7f176193
6539 Node: Readline Movement Commands
\7f177736
6540 Node: Readline Killing Commands
\7f178648
6541 Node: Readline Arguments
\7f180368
6542 Node: Searching
\7f181345
6543 Node: Readline Init File
\7f182981
6544 Node: Readline Init File Syntax
\7f184037
6545 Node: Conditional Init Constructs
\7f191820
6546 Node: Sample Init File
\7f194101
6547 Node: Bindable Readline Commands
\7f197134
6548 Node: Commands For Moving
\7f197884
6549 Node: Commands For History
\7f198731
6550 Node: Commands For Text
\7f201404
6551 Node: Commands For Killing
\7f203148
6552 Node: Numeric Arguments
\7f205174
6553 Node: Commands For Completion
\7f206300
6554 Node: Keyboard Macros
\7f209262
6555 Node: Miscellaneous Commands
\7f209820
6556 Node: Readline vi Mode
\7f214036
6557 Node: Installing Bash
\7f214914
6558 Node: Basic Installation
\7f215983
6559 Node: Compilers and Options
\7f218908
6560 Node: Compiling For Multiple Architectures
\7f219642
6561 Node: Installation Names
\7f221299
6562 Node: Specifying the System Type
\7f222021
6563 Node: Sharing Defaults
\7f222732
6564 Node: Operation Controls
\7f223397
6565 Node: Optional Features
\7f224302
6566 Node: Reporting Bugs
\7f229185
6567 Node: Builtin Index
\7f230265
6568 Node: Reserved Word Index
\7f233732
6569 Node: Variable Index
\7f235059
6570 Node: Function Index
\7f240327
6571 Node: Concept Index
\7f244750