1 This is Info file bashref.info, produced by Makeinfo-1.64 from the
2 input file ./bashref.texi.
4 This text is a brief description of the features that are present in
7 This is Edition 2.0, last updated 19 May 1997,
8 of `The GNU Bash Reference Manual',
9 for `Bash', Version 2.01.
11 Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
13 Permission is granted to make and distribute verbatim copies of
14 this manual provided the copyright notice and this permission notice
15 are preserved on all copies.
17 Permission is granted to copy and distribute modified versions of this
18 manual under the conditions for verbatim copying, provided that the entire
19 resulting derived work is distributed under the terms of a permission
20 notice identical to this one.
22 Permission is granted to copy and distribute translations of this manual
23 into another language, under the above conditions for modified versions,
24 except that this permission notice may be stated in a translation approved
28 File: bashref.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
33 This text is a brief description of the features that are present in
36 This is Edition 2.0, last updated 19 May 1997, of `The GNU Bash
37 Reference Manual', for `Bash', Version 2.01.
39 Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
41 Bash contains features that appear in other popular shells, and some
42 features that only appear in Bash. Some of the shells that Bash has
43 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
44 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
45 following menu breaks the features up into categories based upon which
46 one of these other shells inspired the feature.
48 This manual is meant as a brief introduction to features found in
49 Bash. The Bash manual page should be used as the definitive reference
54 * Introduction:: An introduction to the shell.
56 * Definitions:: Some definitions used in the rest of this
59 * Basic Shell Features:: The shell "building blocks".
61 * Bourne Shell Features:: Features similar to those found in the
64 * Csh Features:: Features originally found in the
67 * Korn Shell Features:: Features originally found in the Korn
70 * Bash Features:: Features found only in Bash.
72 * Job Control:: A chapter describing what job control is
73 and how Bash allows you to use it.
75 * Using History Interactively:: Chapter dealing with history expansion
78 * Command Line Editing:: Chapter describing the command line
81 * Installing Bash:: How to build and install Bash on your system.
83 * Reporting Bugs:: How to report bugs in Bash.
85 * Builtin Index:: Index of Bash builtin commands.
87 * Reserved Word Index:: Index of Bash reserved words.
89 * Variable Index:: Quick reference helps you find the
92 * Function Index:: Index of bindable Readline functions.
94 * Concept Index:: General index for concepts described in
98 File: bashref.info, Node: Introduction, Next: Definitions, Prev: Top, Up: Top
105 * What is Bash?:: A short description of Bash.
107 * What is a shell?:: A brief introduction to shells.
110 File: bashref.info, Node: What is Bash?, Next: What is a shell?, Up: Introduction
115 Bash is the shell, or command language interpreter, that will appear
116 in the GNU operating system. The name is an acronym for the
117 `Bourne-Again SHell', a pun on Steve Bourne, the author of the direct
118 ancestor of the current Unix shell `/bin/sh', which appeared in the
119 Seventh Edition Bell Labs Research version of Unix.
121 Bash is an `sh'-compatible shell that incorporates useful features
122 from the Korn shell `ksh' and the C shell `csh'. It is ultimately
123 intended to be a conformant implementation of the IEEE POSIX Shell and
124 Tools specification (IEEE Working Group 1003.2). It offers functional
125 improvements over `sh' for both interactive and programming use.
127 While the GNU operating system will include a version of `csh', Bash
128 will be the default shell. Like other GNU software, Bash is quite
129 portable. It currently runs on nearly every version of Unix and a few
130 other operating systems - independently-supported ports exist for OS/2
134 File: bashref.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction
139 At its base, a shell is simply a macro processor that executes
140 commands. A Unix shell is both a command interpreter, which provides
141 the user interface to the rich set of Unix utilities, and a programming
142 language, allowing these utilitites to be combined. The shell reads
143 commands either from a terminal or a file. Files containing commands
144 can be created, and become commands themselves. These new commands
145 have the same status as system commands in directories like `/bin',
146 allowing users or groups to establish custom environments.
148 A shell allows execution of Unix commands, both synchronously and
149 asynchronously. The "redirection" constructs permit fine-grained
150 control of the input and output of those commands, and the shell allows
151 control over the contents of their environment. Unix shells also
152 provide a small set of built-in commands ("builtins") implementing
153 functionality impossible (e.g., `cd', `break', `continue', and `exec'),
154 or inconvenient (`history', `getopts', `kill', or `pwd', for example)
155 to obtain via separate utilities. Shells may be used interactively or
156 non-interactively: they accept input typed from the keyboard or from a
157 file. All of the shell builtins are described in subsequent sections.
159 While executing commands is essential, most of the power (and
160 complexity) of shells is due to their embedded programming languages.
161 Like any high-level language, the shell provides variables, flow
162 control constructs, quoting, and functions.
164 Shells have begun offering features geared specifically for
165 interactive use rather than to augment the programming language. These
166 interactive features include job control, command line editing, history
167 and aliases. Each of these features is described in this manual.
170 File: bashref.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top
175 These definitions are used throughout the remainder of this manual.
178 A family of open system standards based on Unix. Bash is
179 concerned with POSIX 1003.2, the Shell and Tools Standard.
182 A space or tab character.
185 A command that is implemented internally by the shell itself,
186 rather than by an executable program somewhere in the file system.
189 A `word' that performs a control function. It is a `newline' or
190 one of the following: `||', `&&', `&', `;', `;;', `|', `(', or `)'.
193 The value returned by a command to its caller.
196 A unit of text that is the result of one of the shell expansions.
197 After expansion, when executing a command, the resulting fields
198 are used as the command name and arguments.
201 A string of characters used to identify a file.
204 A set of processes comprising a pipeline, and any processes
205 descended from it, that are all in the same process group.
208 A mechanism by which users can selectively stop (suspend) and
209 restart (resume) execution of processes.
212 A character that, when unquoted, separates words. A metacharacter
213 is a `blank' or one of the following characters: `|', `&', `;',
214 `(', `)', `<', or `>'.
217 A `word' consisting solely of letters, numbers, and underscores,
218 and beginning with a letter or underscore. `Name's are used as
219 shell variable and function names. Also referred to as an
223 A `control operator' or a `redirection operator'. *Note
224 Redirections::, for a list of redirection operators.
227 A collection of related processes each having the same process
231 A unique identifer that represents a `process group' during its
235 A `word' that has a special meaning to the shell. Most reserved
236 words introduce shell flow control constructs, such as `for' and
240 A synonym for `exit status'.
243 A mechanism by which a process may be notified by the kernal of an
244 event occurring in the system.
247 A shell builtin command that has been classified as special by the
251 A sequence of characters considered a single unit by the shell.
252 It is either a `word' or an `operator'.
255 A `token' that is not an `operator'.
258 File: bashref.info, Node: Basic Shell Features, Next: Bourne Shell Features, Prev: Definitions, Up: Top
263 Bash is an acronym for `Bourne-Again SHell'. The Bourne shell is
264 the traditional Unix shell originally written by Stephen Bourne. All
265 of the Bourne shell builtin commands are available in Bash, and the
266 rules for evaluation and quoting are taken from the POSIX 1003.2
267 specification for the `standard' Unix shell.
269 This chapter briefly summarizes the shell's "building blocks":
270 commands, control structures, shell functions, shell parameters, shell
271 expansions, redirections, which are a way to direct input and output
272 from and to named files, and how the shell executes commands.
276 * Shell Syntax:: What your input means to the shell.
277 * Simple Commands:: The most common type of command.
278 * Pipelines:: Connecting the input and output of several
280 * Lists:: How to execute commands sequentially.
281 * Looping Constructs:: Shell commands for iterative action.
282 * Conditional Constructs:: Shell commands for conditional execution.
283 * Command Grouping:: Ways to group commands.
284 * Shell Functions:: Grouping commands by name.
285 * Shell Parameters:: Special shell variables.
286 * Shell Expansions:: How Bash expands variables and the various
287 expansions available.
288 * Redirections:: A way to control where input and output go.
289 * Executing Commands:: What happens when you run a command.
290 * Shell Scripts:: Executing files of shell commands.
293 File: bashref.info, Node: Shell Syntax, Next: Simple Commands, Up: Basic Shell Features
300 * Shell Operation:: The basic operation of the shell.
302 * Quoting:: How to remove the special meaning from characters.
304 * Comments:: How to specify comments.
307 File: bashref.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax
312 The following is a brief description of the shell's operation when it
313 reads and executes a command. Basically, the shell does the following:
315 1. Reads its input from a file (*note Shell Scripts::.), from a string
316 supplied as an argument to the `-c' invocation option (*note
317 Invoking Bash::.), or from the user's terminal.
319 2. Breaks the input into words and operators, obeying the quoting
320 rules described in *Note Quoting::. Tokens are separated by
321 `metacharacters'. Alias expansion is performed by this step
324 3. Parses the tokens into simple and compound commands.
326 4. Performs the various shell expansions (*note Shell Expansions::.),
327 breaking the expanded tokens into lists of filenames (*note
328 Filename Expansion::.) and commands and arguments.
330 5. Performs any necessary redirections (*note Redirections::.) and
331 removes the redirection operators and their operands from the
334 6. Executes the command (*note Executing Commands::.).
336 7. Optionally waits for the command to complete and collects its exit
341 File: bashref.info, Node: Quoting, Next: Comments, Prev: Shell Operation, Up: Shell Syntax
348 * Escape Character:: How to remove the special meaning from a single
350 * Single Quotes:: How to inhibit all interpretation of a sequence
352 * Double Quotes:: How to suppress most of the interpretation of a
353 sequence of characters.
354 * ANSI-C Quoting:: How to expand ANSI-C sequences in quoted strings.
356 * Locale Translation:: How to translate strings into different languages.
358 Quoting is used to remove the special meaning of certain characters
359 or words to the shell. Quoting can be used to disable special
360 treatment for special characters, to prevent reserved words from being
361 recognized as such, and to prevent parameter expansion.
363 Each of the shell `metacharacters' (*note Definitions::.) has
364 special meaning to the shell and must be quoted if they are to
365 represent themselves. There are three quoting mechanisms: the ESCAPE
366 CHARACTER, single quotes, and double quotes.
369 File: bashref.info, Node: Escape Character, Next: Single Quotes, Up: Quoting
374 A non-quoted backslash `\' is the Bash escape character. It
375 preserves the literal value of the next character that follows, with
376 the exception of `newline'. If a `\newline' pair appears, and the
377 backslash is not quoted, the `\newline' is treated as a line
378 continuation (that is, it is effectively ignored).
381 File: bashref.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting
386 Enclosing characters in single quotes preserves the literal value of
387 each character within the quotes. A single quote may not occur between
388 single quotes, even when preceded by a backslash.
391 File: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting
396 Enclosing characters in double quotes preserves the literal value of
397 all characters within the quotes, with the exception of `$', ``', and
398 `\'. The characters `$' and ``' retain their special meaning within
399 double quotes. The backslash retains its special meaning only when
400 followed by one of the following characters: `$', ``', `"', `\', or
401 `newline'. A double quote may be quoted within double quotes by
402 preceding it with a backslash.
404 The special parameters `*' and `@' have special meaning when in
405 double quotes (*note Shell Parameter Expansion::.).
408 File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double Quotes, Up: Quoting
413 Words of the form `$'STRING'' are treated specially. The word
414 expands to STRING, with backslash-escaped characters replaced as
415 specifed by the ANSI C standard. Backslash escape sequences, if
416 present, are decoded as follows:
425 an escape character (not ANSI C)
446 the character whose `ASCII' code is NNN in octal
448 The result is single-quoted, as if the dollar sign had not been present.
451 File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting
453 Locale-Specific Translation
454 ...........................
456 A double-quoted string preceded by a dollar sign (`$') will cause
457 the string to be translated according to the current locale. If the
458 current locale is `C' or `POSIX', the dollar sign is ignored. If the
459 string is translated and replaced, the replacement is double-quoted.
462 File: bashref.info, Node: Comments, Prev: Quoting, Up: Shell Syntax
467 In a non-interactive shell, or an interactive shell in which the
468 `interactive_comments' option to the `shopt' builtin is enabled (*note
469 Bash Builtins::.), a word beginning with `#' causes that word and all
470 remaining characters on that line to be ignored. An interactive shell
471 without the `interactive_comments' option enabled does not allow
472 comments. The `interactive_comments' option is on by default in
476 File: bashref.info, Node: Simple Commands, Next: Pipelines, Prev: Shell Syntax, Up: Basic Shell Features
481 A simple command is the kind of command you'll encounter most often.
482 It's just a sequence of words separated by `blank's, terminated by one
483 of the shell control operators (*note Definitions::.). The first word
484 generally specifies a command to be executed.
486 The return status (*note Exit Status::.) of a simple command is its
487 exit status as provided by the POSIX.1 `waitpid' function, or 128+N if
488 the command was terminated by signal N.
491 File: bashref.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Basic Shell Features
496 A `pipeline' is a sequence of simple commands separated by `|'.
498 The format for a pipeline is
499 [`time' [`-p']] [`!'] COMMAND1 [`|' COMMAND2 ...]
501 The output of each command in the pipeline is connected to the input of
502 the next command. That is, each command reads the previous command's
505 The reserved word `time' causes timing statistics to be printed for
506 the pipeline once it finishes. The `-p' option changes the output
507 format to that specified by POSIX. The `TIMEFORMAT' variable may be
508 set to a format string that specifies how the timing information should
509 be displayed. *Note Bash Variables::, for a description of the
512 Each command in a pipeline is executed in its own subshell. The exit
513 status of a pipeline is the exit status of the last command in the
514 pipeline. If the reserved word `!' precedes the pipeline, the exit
515 status is the logical NOT of the exit status of the last command.
518 File: bashref.info, Node: Lists, Next: Looping Constructs, Prev: Pipelines, Up: Basic Shell Features
523 A `list' is a sequence of one or more pipelines separated by one of
524 the operators `;', `&', `&&', or `||', and optionally terminated by one
525 of `;', `&', or a `newline'.
527 Of these list operators, `&&' and `||' have equal precedence,
528 followed by `;' and `&', which have equal precedence.
530 If a command is terminated by the control operator `&', the shell
531 executes the command in the BACKGROUND in a subshell. The shell does
532 not wait for the command to finish, and the return status is 0 (true).
533 Commands separated by a `;' are executed sequentially; the shell waits
534 for each command to terminate in turn. The return status is the exit
535 status of the last command executed.
537 The control operators `&&' and `||' denote AND lists and OR lists,
538 respectively. An AND list has the form
541 COMMAND2 is executed if, and only if, COMMAND returns an exit status of
544 An OR list has the form
547 COMMAND2 is executed if and only if COMMAND returns a non-zero exit
550 The return status of AND and OR lists is the exit status of the last
551 command executed in the list.
554 File: bashref.info, Node: Looping Constructs, Next: Conditional Constructs, Prev: Lists, Up: Basic Shell Features
559 Note that wherever you see a `;' in the description of a command's
560 syntax, it may be replaced indiscriminately with one or more newlines.
562 Bash supports the following looping constructs.
565 The syntax of the `until' command is:
566 until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
567 Execute CONSEQUENT-COMMANDS as long as the final command in
568 TEST-COMMANDS has an exit status which is not zero.
571 The syntax of the `while' command is:
572 while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
574 Execute CONSEQUENT-COMMANDS as long as the final command in
575 TEST-COMMANDS has an exit status of zero.
578 The syntax of the `for' command is:
580 for NAME [in WORDS ...]; do COMMANDS; done
581 Execute COMMANDS for each member in WORDS, with NAME bound to the
582 current member. If `in WORDS' is not present, `in "$@"' is
585 The `break' and `continue' builtins (*note Bourne Shell Builtins::.)
586 may be used to control loop execution.
589 File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Basic Shell Features
591 Conditional Constructs
592 ======================
595 The syntax of the `if' command is:
597 if TEST-COMMANDS; then
599 [elif MORE-TEST-COMMANDS; then
601 [else ALTERNATE-CONSEQUENTS;]
604 Execute CONSEQUENT-COMMANDS only if the final command in
605 TEST-COMMANDS has an exit status of zero. Otherwise, each `elif'
606 list is executed in turn, and if its exit status is zero, the
607 corresponding MORE-CONSEQUENTS is executed and the command
608 completes. If `else ALTERNATE-CONSEQUENTS' is present, and the
609 final command in the final `if' or `elif' clause has a non-zero
610 exit status, then execute ALTERNATE-CONSEQUENTS.
613 The syntax of the `case' command is:
615 `case WORD in [ ( PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
617 Selectively execute COMMANDS based upon WORD matching PATTERN.
618 The `|' is used to separate multiple patterns.
620 Here is an example using `case' in a script that could be used to
621 describe one interesting feature of an animal:
623 echo -n "Enter the name of an animal: "
625 echo -n "The $ANIMAL has "
627 horse | dog | cat) echo -n "four";;
628 man | kangaroo ) echo -n "two";;
629 *) echo -n "an unknown number of";;
636 The EXPRESSION is evaluated according to the rules described below
637 (*note Arithmetic Evaluation::.). If the value of the expression
638 is non-zero, the return status is 0; otherwise the return status
639 is 1. This is exactly equivalent to
642 The `select' construct, which allows users to choose from a list of
643 items presented as a menu, is also available. *Note Korn Shell
644 Constructs::, for a full description of `select'.
647 File: bashref.info, Node: Command Grouping, Next: Shell Functions, Prev: Conditional Constructs, Up: Basic Shell Features
652 Bash provides two ways to group a list of commands to be executed as
653 a unit. When commands are grouped, redirections may be applied to the
654 entire command list. For example, the output of all the commands in
655 the list may be redirected to a single stream.
660 Placing a list of commands between parentheses causes a subshell
661 to be created, and each of the commands to be executed in that
662 subshell. Since the LIST is executed in a subshell, variable
663 assignments do not remain in effect after the subshell completes.
668 Placing a list of commands between curly braces causes the list to
669 be executed in the current shell context. No subshell is created.
670 The semicolon following LIST is required.
672 In addition to the creation of a subshell, there is a subtle
673 difference between these two constructs due to historical reasons. The
674 braces are `reserved words', so they must be separated from the LIST by
675 `blank's. The parentheses are `operators', and are recognized as
676 separate tokens by the shell even if they are not separated from the
679 The exit status of both of these constructs is the exit status of
683 File: bashref.info, Node: Shell Functions, Next: Shell Parameters, Prev: Command Grouping, Up: Basic Shell Features
688 Shell functions are a way to group commands for later execution
689 using a single name for the group. They are executed just like a
690 "regular" command. Shell functions are executed in the current shell
691 context; no new process is created to interpret them.
693 Functions are declared using this syntax:
694 [ `function' ] NAME () { COMMAND-LIST; }
696 This defines a shell function named NAME. The reserved word
697 `function' is optional. The BODY of the function is the COMMAND-LIST
698 between { and }. This list is executed whenever NAME is specified as
699 the name of a command. The exit status of a function is the exit
700 status of the last command executed in the body.
702 When a function is executed, the arguments to the function become
703 the positional parameters during its execution (*note Positional
704 Parameters::.). The special parameter `#' that expands to the number of
705 positional parameters is updated to reflect the change. Positional
706 parameter `0' is unchanged.
708 If the builtin command `return' is executed in a function, the
709 function completes and execution resumes with the next command after
710 the function call. When a function completes, the values of the
711 positional parameters and the special parameter `#' are restored to the
712 values they had prior to function execution. If a numeric argument is
713 given to `return', that is the function return status.
715 Variables local to the function may be declared with the `local'
716 builtin. These variables are visible only to the function and the
719 Functions may be recursive. No limit is placed on the number of
723 File: bashref.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell Functions, Up: Basic Shell Features
730 * Positional Parameters:: The shell's command-line arguments.
731 * Special Parameters:: Parameters with special meanings.
733 A PARAMETER is an entity that stores values. It can be a `name', a
734 number, or one of the special characters listed below. For the shell's
735 purposes, a VARIABLE is a parameter denoted by a `name'.
737 A parameter is set if it has been assigned a value. The null string
738 is a valid value. Once a variable is set, it may be unset only by using
739 the `unset' builtin command.
741 A variable may be assigned to by a statement of the form
744 If VALUE is not given, the variable is assigned the null string. All
745 VALUEs undergo tilde expansion, parameter and variable expansion,
746 command substitution, arithmetic expansion, and quote removal (detailed
747 below). If the variable has its `-i' attribute set (see the
748 description of the `declare' builtin in *Note Bash Builtins::), then
749 VALUE is subject to arithmetic expansion even if the `$((...))' syntax
750 does not appear (*note Arithmetic Expansion::.). Word splitting is not
751 performed, with the exception of `"$@"' as explained below. Filename
752 expansion is not performed.
755 File: bashref.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters
757 Positional Parameters
758 ---------------------
760 A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
761 other than the single digit `0'. Positional parameters are assigned
762 from the shell's arguments when it is invoked, and may be reassigned
763 using the `set' builtin command. Positional parameters may not be
764 assigned to with assignment statements. The positional parameters are
765 temporarily replaced when a shell function is executed (*note Shell
768 When a positional parameter consisting of more than a single digit
769 is expanded, it must be enclosed in braces.
772 File: bashref.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters
777 The shell treats several parameters specially. These parameters may
778 only be referenced; assignment to them is not allowed.
781 Expands to the positional parameters, starting from one. When the
782 expansion occurs within double quotes, it expands to a single word
783 with the value of each parameter separated by the first character
784 of the `IFS' special variable. That is, `"$*"' is equivalent to
785 `"$1C$2C..."', where C is the first character of the value of the
786 `IFS' variable. If `IFS' is unset, the parameters are separated
787 by spaces. If `IFS' is null, the parameters are joined without
788 intervening separators.
791 Expands to the positional parameters, starting from one. When the
792 expansion occurs within double quotes, each parameter expands as a
793 separate word. That is, `"$@"' is equivalent to `"$1" "$2" ...'.
794 When there are no positional parameters, `"$@"' and `$@' expand to
795 nothing (i.e., they are removed).
798 Expands to the number of positional parameters in decimal.
801 Expands to the exit status of the most recently executed foreground
805 Expands to the current option flags as specified upon invocation,
806 by the `set' builtin command, or those set by the shell itself
807 (such as the `-i' option).
810 Expands to the process ID of the shell. In a `()' subshell, it
811 expands to the process ID of the current shell, not the subshell.
814 Expands to the process ID of the most recently executed background
815 (asynchronous) command.
818 Expands to the name of the shell or shell script. This is set at
819 shell initialization. If Bash is invoked with a file of commands,
820 `$0' is set to the name of that file. If Bash is started with the
821 `-c' option, then `$0' is set to the first argument after the
822 string to be executed, if one is present. Otherwise, it is set to
823 the filename used to invoke Bash, as given by argument zero.
826 At shell startup, set to the absolute filename of the shell or
827 shell script being executed as passed in the argument list.
828 Subsequently, expands to the last argument to the previous command,
829 after expansion. Also set to the full filename of each command
830 executed and placed in the environment exported to that command.
831 When checking mail, this parameter holds the name of the mail file.
834 File: bashref.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features
839 Expansion is performed on the command line after it has been split
840 into `token's. There are seven kinds of expansion performed:
845 * parameter and variable expansion
847 * command substitution
849 * arithmetic expansion
857 * Shell Parameter Expansion:: How Bash expands variables to their values.
858 * Command Substitution:: Using the output of a command as an argument.
859 * Process Substitution:: A way to write and read to and from a
861 * Word Splitting:: How the results of expansion are split into separate
863 * Filename Expansion:: A shorthand for specifying filenames matching patterns.
864 * Quote Removal:: How and when quote characters are removed from
867 Brace expansion, tilde expansion, and arithmetic expansion are
868 described in other sections. For brace expansion, see *Note Brace
869 Expansion::; for tilde expansion, see *Note Tilde Expansion::; and for
870 arithmetic expansion, see *Note Arithmetic Expansion::.
872 The order of expansions is: brace expansion, tilde expansion,
873 parameter, variable, and arithmetic expansion and command substitution
874 (done in a left-to-right fashion), word splitting, and filename
877 On systems that can support it, there is an additional expansion
878 available: PROCESS SUBSTITUTION. This is performed at the same time as
879 parameter, variable, and arithemtic expansion and command substitution.
881 Only brace expansion, word splitting, and filename expansion can
882 change the number of words of the expansion; other expansions expand a
883 single word to a single word. The only exceptions to this are the
884 expansions of `"$@"' (*note Special Parameters::.) and `"${NAME[@]}"'
887 After all expansions, `quote removal' (*note Quote Removal::.) is
891 File: bashref.info, Node: Shell Parameter Expansion, Next: Command Substitution, Up: Shell Expansions
893 Shell Parameter Expansion
894 -------------------------
896 The `$' character introduces parameter expansion, command
897 substitution, or arithmetic expansion. The parameter name or symbol to
898 be expanded may be enclosed in braces, which are optional but serve to
899 protect the variable to be expanded from characters immediately
900 following it which could be interpreted as part of the name.
902 The basic form of parameter expansion is ${PARAMETER}. The value of
903 PARAMETER is substituted. The braces are required when PARAMETER is a
904 positional parameter with more than one digit, or when PARAMETER is
905 followed by a character that is not to be interpreted as part of its
908 If the first character of PARAMETER is an exclamation point, a level
909 of variable indirection is introduced. Bash uses the value of the
910 variable formed from the rest of PARAMETER as the name of the variable;
911 this variable is then expanded and that value is used in the rest of
912 the substitution, rather than the value of PARAMETER itself. This is
913 known as `indirect expansion'.
915 In each of the cases below, WORD is subject to tilde expansion,
916 parameter expansion, command substitution, and arithmetic expansion.
917 When not performing substring expansion, Bash tests for a parameter
918 that is unset or null; omitting the colon results in a test only for a
919 parameter that is unset.
922 If PARAMETER is unset or null, the expansion of WORD is
923 substituted. Otherwise, the value of PARAMETER is substituted.
926 If PARAMETER is unset or null, the expansion of WORD is assigned
927 to PARAMETER. The value of PARAMETER is then substituted.
928 Positional parameters and special parameters may not be assigned
932 If PARAMETER is null or unset, the expansion of WORD (or a message
933 to that effect if WORD is not present) is written to the standard
934 error and the shell, if it is not interactive, exits. Otherwise,
935 the value of PARAMETER is substituted.
938 If PARAMETER is null or unset, nothing is substituted, otherwise
939 the expansion of WORD is substituted.
941 `${PARAMETER:OFFSET}'
942 `${PARAMETER:OFFSET:LENGTH}'
943 Expands to up to LENGTH characters of PARAMETER, starting at
944 OFFSET. If LENGTH is omitted, expands to the substring of
945 PARAMETER, starting at the character specified by OFFSET. LENGTH
946 and OFFSET are arithmetic expressions (*note Arithmetic
947 Evaluation::.). This is referred to as Substring Expansion.
949 LENGTH must evaluate to a number greater than or equal to zero.
950 If OFFSET evaluates to a number less than zero, the value is used
951 as an offset from the end of the value of PARAMETER. If PARAMETER
952 is `@', the result is LENGTH positional parameters beginning at
953 OFFSET. If PARAMETER is an array name indexed by `@' or `*', the
954 result is the LENGTH members of the array beginning with
955 ${PARAMETER[OFFSET]}. Substring indexing is zero-based unless the
956 positional parameters are used, in which case the indexing starts
960 The length in characters of the value of PARAMETER is substituted.
961 If PARAMETER is `*' or `@', the length substituted is the number
962 of positional parameters. If PARAMETER is an array name
963 subscripted by `*' or `@', the length substituted is the number of
964 elements in the array.
968 The WORD is expanded to produce a pattern just as in filename
969 expansion (*note Filename Expansion::.). If the pattern matches
970 the beginning of the value of PARAMETER, then the expansion is the
971 value of PARAMETER with the shortest matching pattern (the `#'
972 case) or the longest matching pattern (the `##' case) deleted. If
973 PARAMETER is `@' or `*', the pattern removal operation is applied
974 to each positional parameter in turn, and the expansion is the
975 resultant list. If PARAMETER is an array variable subscripted with
976 `@' or `*', the pattern removal operation is applied to each
977 member of the array in turn, and the expansion is the resultant
982 The WORD is expanded to produce a pattern just as in filename
983 expansion. If the pattern matches a trailing portion of the value
984 of PARAMETER, then the expansion is the value of PARAMETER with
985 the shortest matching pattern (the `%' case) or the longest
986 matching pattern (the `%%' case) deleted. If PARAMETER is `@' or
987 `*', the pattern removal operation is applied to each positional
988 parameter in turn, and the expansion is the resultant list. If
989 PARAMETER is an array variable subscripted with `@' or `*', the
990 pattern removal operation is applied to each member of the array
991 in turn, and the expansion is the resultant list.
993 `${PARAMETER/PATTERN/STRING}'
994 `${PARAMETER//PATTERN/STRING}'
995 The PATTERN is expanded to produce a pattern just as in filename
996 expansion. PARAMETER is expanded and the longest match of PATTERN
997 against its value is replaced with STRING. In the first form,
998 only the first match is replaced. The second form causes all
999 matches of PATTERN to be replaced with STRING. If PATTERN begins
1000 with `#', it must match at the beginning of STRING. If PATTERN
1001 begins with `%', it must match at the end of STRING. If STRING is
1002 null, matches of PATTERN are deleted and the `/' following PATTERN
1003 may be omitted. If PARAMETER is `@' or `*', the substitution
1004 operation is applied to each positional parameter in turn, and the
1005 expansion is the resultant list. If PARAMETER is an array
1006 variable subscripted with `@' or `*', the substitution operation
1007 is applied to each member of the array in turn, and the expansion
1008 is the resultant list.
1011 File: bashref.info, Node: Command Substitution, Next: Process Substitution, Prev: Shell Parameter Expansion, Up: Shell Expansions
1013 Command Substitution
1014 --------------------
1016 Command substitution allows the output of a command to replace the
1017 command name. There are two forms:
1023 Bash performs the expansion by executing COMMAND and replacing the
1024 command substitution with the standard output of the command, with any
1025 trailing newlines deleted.
1027 When the old-style backquote form of substitution is used, backslash
1028 retains its literal meaning except when followed by `$', ``', or `\'.
1029 When using the `$(COMMAND)' form, all characters between the
1030 parentheses make up the command; none are treated specially.
1032 Command substitutions may be nested. To nest when using the old
1033 form, escape the inner backquotes with backslashes.
1035 If the substitution appears within double quotes, word splitting and
1036 filename expansion are not performed on the results.
1039 File: bashref.info, Node: Process Substitution, Next: Word Splitting, Prev: Command Substitution, Up: Shell Expansions
1041 Process Substitution
1042 --------------------
1044 Process substitution is supported on systems that support named
1045 pipes (FIFOs) or the `/dev/fd' method of naming open files. It takes
1052 The process LIST is run with its input or output connected to a FIFO or
1053 some file in `/dev/fd'. The name of this file is passed as an argument
1054 to the current command as the result of the expansion. If the
1055 `>(LIST)' form is used, writing to the file will provide input for
1056 LIST. If the `<(LIST)' form is used, the file passed as an argument
1057 should be read to obtain the output of LIST.
1059 On systems that support it, process substitution is performed
1060 simultaneously with parameter and variable expansion, command
1061 substitution, and arithmetic expansion.
1064 File: bashref.info, Node: Word Splitting, Next: Filename Expansion, Prev: Process Substitution, Up: Shell Expansions
1069 The shell scans the results of parameter expansion, command
1070 substitution, and arithmetic expansion that did not occur within double
1071 quotes for word splitting.
1073 The shell treats each character of `$IFS' as a delimiter, and splits
1074 the results of the other expansions into words on these characters. If
1075 `IFS' is unset, or its value is exactly `<space><tab><newline>', the
1076 default, then any sequence of `IFS' characters serves to delimit words.
1077 If `IFS' has a value other than the default, then sequences of the
1078 whitespace characters `space' and `tab' are ignored at the beginning
1079 and end of the word, as long as the whitespace character is in the
1080 value of `IFS' (an `IFS' whitespace character). Any character in `IFS'
1081 that is not `IFS' whitespace, along with any adjacent `IFS' whitespace
1082 characters, delimits a field. A sequence of `IFS' whitespace
1083 characters is also treated as a delimiter. If the value of `IFS' is
1084 null, no word splitting occurs.
1086 Explicit null arguments (`""' or `''') are retained. Unquoted
1087 implicit null arguments, resulting from the expansion of PARAMETERs
1088 that have no values, are removed. If a parameter with no value is
1089 expanded within double quotes, a null argument results and is retained.
1091 Note that if no expansion occurs, no splitting is performed.
1094 File: bashref.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions
1099 After word splitting, unless the `-f' option has been set (*note The
1100 Set Builtin::.), Bash scans each word for the characters `*', `?', and
1101 `['. If one of these characters appears, then the word is regarded as
1102 a PATTERN, and replaced with an alphabetically sorted list of file
1103 names matching the pattern. If no matching file names are found, and
1104 the shell option `nullglob' is disabled, the word is left unchanged. If
1105 the option is set, and no matches are found, the word is removed. When
1106 a pattern is used for filename generation, the character `.' at the
1107 start of a filename or immediately following a slash must be matched
1108 explicitly, unless the shell option `dotglob' is set. The slash
1109 character must always be matched explicitly. In other cases, the `.'
1110 character is not treated specially. See the description of `shopt' in
1111 *Note Bash Builtins::, for a description of the `nullglob' and
1114 The `GLOBIGNORE' shell variable may be used to restrict the set of
1115 filenames matching a PATTERN. If `GLOBIGNORE' is set, each matching
1116 filename that also matches one of the patterns in `GLOBIGNORE' is
1117 removed from the list of matches. The filenames `.' and `..' are
1118 always ignored, even when `GLOBIGNORE'. is set. However, setting
1119 `GLOBIGNORE' has the effect of enabling the `dotglob' shell option, so
1120 all other filenames beginning with a `.' will match. To get the old
1121 behavior of ignoring filenames beginning with a `.', make `.*' one of
1122 the patterns in `GLOBIGNORE'. The `dotglob' option is disabled when
1123 `GLOBIGNORE' is unset.
1125 The special pattern characters have the following meanings:
1127 Matches any string, including the null string.
1130 Matches any single character.
1133 Matches any one of the enclosed characters. A pair of characters
1134 separated by a minus sign denotes a RANGE; any character lexically
1135 between those two characters, inclusive, is matched. If the first
1136 character following the `[' is a `!' or a `^' then any character
1137 not enclosed is matched. A `-' may be matched by including it as
1138 the first or last character in the set. A `]' may be matched by
1139 including it as the first character in the set.
1142 File: bashref.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Expansions
1147 After the preceding expansions, all unquoted occurrences of the
1148 characters `\', `'', and `"' that did not result from one of the above
1149 expansions are removed.
1152 File: bashref.info, Node: Redirections, Next: Executing Commands, Prev: Shell Expansions, Up: Basic Shell Features
1157 Before a command is executed, its input and output may be REDIRECTED
1158 using a special notation interpreted by the shell. Redirection may
1159 also be used to open and close files for the current shell execution
1160 environment. The following redirection operators may precede or appear
1161 anywhere within a simple command or may follow a command. Redirections
1162 are processed in the order they appear, from left to right.
1164 In the following descriptions, if the file descriptor number is
1165 omitted, and the first character of the redirection operator is `<',
1166 the redirection refers to the standard input (file descriptor 0). If
1167 the first character of the redirection operator is `>', the redirection
1168 refers to the standard output (file descriptor 1).
1170 The word that follows the redirection operator in the following
1171 descriptions is subjected to brace expansion, tilde expansion,
1172 parameter expansion, command substitution, arithmetic expansion, quote
1173 removal, and filename expansion. If it expands to more than one word,
1174 Bash reports an error.
1176 Note that the order of redirections is significant. For example,
1180 directs both standard output and standard error to the file DIRLIST,
1184 directs only the standard output to file DIRLIST, because the standard
1185 error was duplicated as standard output before the standard output was
1186 redirected to DIRLIST.
1191 Redirection of input causes the file whose name results from the
1192 expansion of WORD to be opened for reading on file descriptor `n', or
1193 the standard input (file descriptor 0) if `n' is not specified.
1195 The general format for redirecting input is:
1201 Redirection of output causes the file whose name results from the
1202 expansion of WORD to be opened for writing on file descriptor `n', or
1203 the standard output (file descriptor 1) if `n' is not specified. If
1204 the file does not exist it is created; if it does exist it is truncated
1207 The general format for redirecting output is:
1210 If the redirection operator is `>', and the `-C' option to the `set'
1211 builtin has been enabled, the redirection will fail if the filename
1212 whose name results from the expansion of WORD exists. If the
1213 redirection operator is `>|', then the value of the `-C' option to the
1214 `set' builtin command is not tested, and the redirection is attempted
1215 even if the file named by WORD exists.
1217 Appending Redirected Output
1218 ---------------------------
1220 Redirection of output in this fashion causes the file whose name
1221 results from the expansion of WORD to be opened for appending on file
1222 descriptor `n', or the standard output (file descriptor 1) if `n' is
1223 not specified. If the file does not exist it is created.
1225 The general format for appending output is:
1228 Redirecting Standard Output and Standard Error
1229 ----------------------------------------------
1231 Bash allows both the standard output (file descriptor 1) and the
1232 standard error output (file descriptor 2) to be redirected to the file
1233 whose name is the expansion of WORD with this construct.
1235 There are two formats for redirecting standard output and standard
1242 Of the two forms, the first is preferred. This is semantically
1249 This type of redirection instructs the shell to read input from the
1250 current source until a line containing only WORD (with no trailing
1251 blanks) is seen. All of the lines read up to that point are then used
1252 as the standard input for a command.
1254 The format of here-documents is as follows:
1259 No parameter expansion, command substitution, filename expansion, or
1260 arithmetic expansion is performed on WORD. If any characters in WORD
1261 are quoted, the DELIMITER is the result of quote removal on WORD, and
1262 the lines in the here-document are not expanded. Otherwise, all lines
1263 of the here-document are subjected to parameter expansion, command
1264 substitution, and arithmetic expansion. In the latter case, the pair
1265 `\newline' is ignored, and `\' must be used to quote the characters
1268 If the redirection operator is `<<-', then all leading tab
1269 characters are stripped from input lines and the line containing
1270 DELIMITER. This allows here-documents within shell scripts to be
1271 indented in a natural fashion.
1273 Duplicating File Descriptors
1274 ----------------------------
1276 The redirection operator
1279 is used to duplicate input file descriptors. If WORD expands to one or
1280 more digits, the file descriptor denoted by `n' is made to be a copy of
1281 that file descriptor. If WORD evaluates to `-', file descriptor `n' is
1282 closed. If `n' is not specified, the standard input (file descriptor
1288 is used similarly to duplicate output file descriptors. If `n' is not
1289 specified, the standard output (file descriptor 1) is used. As a
1290 special case, if `n' is omitted, and WORD does not expand to one or
1291 more digits, the standard output and standard error are redirected as
1292 described previously.
1294 Opening File Descriptors for Reading and Writing
1295 ------------------------------------------------
1297 The redirection operator
1300 causes the file whose name is the expansion of WORD to be opened for
1301 both reading and writing on file descriptor `n', or on file descriptor
1302 0 if `n' is not specified. If the file does not exist, it is created.
1305 File: bashref.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features
1312 * Command Search and Execution:: How Bash finds commands and runs them.
1314 * Environment:: The environment given to a command.
1316 * Exit Status:: The status returned by commands and how Bash
1319 * Signals:: What happens when Bash or a command it runs
1323 File: bashref.info, Node: Command Search and Execution, Next: Environment, Up: Executing Commands
1325 Command Search and Execution
1326 ----------------------------
1328 After a command has been split into words, if it results in a simple
1329 command and an optional list of arguments, the following actions are
1332 1. If the command name contains no slashes, the shell attempts to
1333 locate it. If there exists a shell function by that name, that
1334 function is invoked as described above in *Note Shell Functions::.
1336 2. If the name does not match a function, the shell searches for it
1337 in the list of shell builtins. If a match is found, that builtin
1340 3. If the name is neither a shell function nor a builtin, and
1341 contains no slashes, Bash searches each element of `$PATH' for a
1342 directory containing an executable file by that name. Bash uses a
1343 hash table to remember the full filenames of executable files (see
1344 the description of `hash' in *Note Bourne Shell Builtins::) to
1345 avoid multiple `PATH' searches. A full search of the directories
1346 in `$PATH' is performed only if the command is not found in the
1347 hash table. If the search is unsuccessful, the shell prints an
1348 error message and returns a nonzero exit status.
1350 4. If the search is successful, or if the command name contains one
1351 or more slashes, the shell executes the named program. Argument 0
1352 is set to the name given, and the remaining arguments to the
1353 command are set to the arguments supplied, if any.
1355 5. If this execution fails because the file is not in executable
1356 format, and the file is not a directory, it is assumed to be SHELL
1357 SCRIPT (*note Shell Scripts::.).
1360 File: bashref.info, Node: Environment, Next: Exit Status, Prev: Command Search and Execution, Up: Executing Commands
1365 When a program is invoked it is given an array of strings called the
1366 ENVIRONMENT. This is a list of name-value pairs, of the form
1369 Bash allows you to manipulate the environment in several ways. On
1370 invocation, the shell scans its own environment and creates a parameter
1371 for each name found, automatically marking it for EXPORT to child
1372 processes. Executed commands inherit the environment. The `export'
1373 and `declare -x' commands allow parameters and functions to be added to
1374 and deleted from the environment. If the value of a parameter in the
1375 environment is modified, the new value becomes part of the environment,
1376 replacing the old. The environment inherited by any executed command
1377 consists of the shell's initial environment, whose values may be
1378 modified in the shell, less any pairs removed by the `unset' command,
1379 plus any additions via the `export' and `declare -x' commands.
1381 The environment for any simple command or function may be augmented
1382 temporarily by prefixing it with parameter assignments, as described in
1383 *Note Shell Parameters::. These assignment statements affect only the
1384 environment seen by that command.
1386 If the `-k' flag is set (*note The Set Builtin::., then all
1387 parameter assignments are placed in the environment for a command, not
1388 just those that precede the command name.
1390 When Bash invokes an external command, the variable `$_' is set to
1391 the full path name of the command and passed to that command in its
1395 File: bashref.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Executing Commands
1400 For the purposes of the shell, a command which exits with a zero
1401 exit status has succeeded. A non-zero exit status indicates failure.
1402 This seemingly counter-intuitive scheme is used so there is one
1403 well-defined way to indicate success and a variety of ways to indicate
1404 various failure modes. When a command terminates on a fatal signal
1405 whose number is N, Bash uses the value 128+N as the exit status.
1407 If a command is not found, the child process created to execute it
1408 returns a status of 127. If a command is found but is not executable,
1409 the return status is 126.
1411 The exit status is used by the Bash conditional commands (*note
1412 Conditional Constructs::.) and some of the list constructs (*note
1415 All of the Bash builtins return an exit status of zero if they
1416 succeed and a non-zero status on failure, so they may be used by the
1417 conditional and list constructs.
1420 File: bashref.info, Node: Signals, Prev: Exit Status, Up: Executing Commands
1425 When Bash is interactive, it ignores `SIGTERM' (so that `kill 0'
1426 does not kill an interactive shell), and `SIGINT' is caught and handled
1427 (so that the `wait' builtin is interruptible). When Bash receives a
1428 `SIGINT', it breaks out of any executing loops. In all cases, Bash
1429 ignores `SIGQUIT'. If job control is in effect (*note Job Control::.),
1430 Bash ignores `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
1432 Synchronous jobs started by Bash have signals set to the values
1433 inherited by the shell from its parent. When job control is not in
1434 effect, background jobs (commands terminated with `&') ignore `SIGINT'
1435 and `SIGQUIT'. Commands run as a result of command substitution ignore
1436 the keyboard-generated job control signals `SIGTTIN', `SIGTTOU', and
1439 The shell exits by default upon receipt of a `SIGHUP'. Before
1440 exiting, it resends the `SIGHUP' to all jobs, running or stopped. To
1441 prevent the shell from sending the `SIGHUP' signal to a particular job,
1442 remove it from the jobs table with the `disown' builtin (*note Job
1443 Control Builtins::.) or use `disown -h' to mark it to not receive
1447 File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
1452 A shell script is a text file containing shell commands. When such
1453 a file is used as the first non-option argument when invoking Bash, and
1454 neither the `-c' nor `-s' option is supplied (*note Invoking Bash::.),
1455 Bash reads and executes commands from the file, then exits. This mode
1456 of operation creates a non-interactive shell. When Bash runs a shell
1457 script, it sets the special parameter `0' to the name of the file,
1458 rather than the name of the shell, and the positional parameters are
1459 set to the remaining arguments, if any are given. If no additional
1460 arguments are supplied, the positional parameters are unset.
1462 A shell script may be made executable by using the `chmod' command
1463 to turn on the execute bit. When Bash finds such a file while
1464 searching the `$PATH' for a command, it spawns a subshell to execute
1465 it. In other words, executing
1468 is equivalent to executing
1469 bash filename ARGUMENTS
1471 if `filename' is an executable shell script. This subshell
1472 reinitializes itself, so that the effect is as if a new shell had been
1473 invoked to interpret the script.
1475 Most versions of Unix make this a part of the kernel's command
1476 execution mechanism. If the first line of a script begins with the two
1477 characters `#!', the remainder of the line specifies an interpreter for
1478 the program. The arguments to the interpreter consist of a single
1479 optional argument following the interpreter name on the first line of
1480 the script file, followed by the name of the script file, followed by
1481 the rest of the arguments. Bash will perform this action on operating
1482 systems that do not handle it themselves. Note that some older
1483 versions of Unix limit the interpreter name and argument to a maximum
1487 File: bashref.info, Node: Bourne Shell Features, Next: Csh Features, Prev: Basic Shell Features, Up: Top
1489 Bourne Shell Style Features
1490 ***************************
1494 * Bourne Shell Builtins:: Builtin commands inherited from the Bourne
1496 * Bourne Shell Variables:: Variables which Bash uses in the same way
1497 as the Bourne Shell.
1498 * Other Bourne Shell Features:: Addtional aspects of Bash which behave in
1499 the same way as the Bourne Shell.
1501 This section briefly summarizes things which Bash inherits from the
1502 Bourne Shell: builtins, variables, and other features. It also lists
1503 the significant differences between Bash and the Bourne Shell.
1506 File: bashref.info, Node: Bourne Shell Builtins, Next: Bourne Shell Variables, Up: Bourne Shell Features
1508 Bourne Shell Builtins
1509 =====================
1511 The following shell builtin commands are inherited from the Bourne
1512 Shell. These commands are implemented as specified by the POSIX 1003.2
1517 Do nothing beyond expanding ARGUMENTS and performing redirections.
1521 Read and execute commands from the FILENAME argument in the
1522 current shell context.
1526 Exit from a `for', `while', `until', or `select' loop. If N is
1527 supplied, the Nth enclosing loop is exited.
1530 cd [-LP] [DIRECTORY]
1531 Change the current working directory to DIRECTORY. If DIRECTORY
1532 is not given, the value of the `HOME' shell variable is used. If
1533 the shell variable `CDPATH' exists, it is used as a search path.
1534 If DIRECTORY begins with a slash, `CDPATH' is not used. The `-P'
1535 option means to not follow symbolic links; symlinks are followed
1536 by default or with the `-L' option.
1540 Resume the next iteration of an enclosing `for', `while', `until',
1541 or `select' loop. If N is supplied, the execution of the Nth
1542 enclosing loop is resumed.
1546 The arguments are concatenated together into a single command,
1547 which is then read and executed.
1550 exec [-cl] [-a NAME] [COMMAND] [ARGUMENTS]
1551 If COMMAND is supplied, it replaces the shell. If the `-l' option
1552 is supplied, the shell places a dash in the zeroth arg passed to
1553 COMMAND. This is what the `login' program does. The `-c' option
1554 causes COMMAND to be executed with an empty environment. If `-a'
1555 is supplied, the shell passes NAME as the zeroth argument to
1556 COMMAND. If no COMMAND is specified, redirections may be used to
1557 affect the current shell environment.
1561 Exit the shell, returning a status of N to the shell's parent.
1564 export [-fn] [-p] [NAME[=VALUE]]
1565 Mark each NAME to be passed to child processes in the environment.
1566 If the `-f' option is supplied, the NAMEs refer to shell
1567 functions. The `-n' option means to no longer mark each NAME for
1568 export. If no NAMES are supplied, or if the `-p' option is given,
1569 a list of exported names is displayed.
1572 getopts OPTSTRING NAME [ARGS]
1573 `getopts' is used by shell scripts to parse positional parameters.
1574 OPTSTRING contains the option letters to be recognized; if a letter
1575 is followed by a colon, the option is expected to have an
1576 argument, which should be separated from it by white space. Each
1577 time it is invoked, `getopts' places the next option in the shell
1578 variable NAME, initializing NAME if it does not exist, and the
1579 index of the next argument to be processed into the variable
1580 `OPTIND'. `OPTIND' is initialized to 1 each time the shell or a
1581 shell script is invoked. When an option requires an argument,
1582 `getopts' places that argument into the variable `OPTARG'. The
1583 shell does not reset `OPTIND' automatically; it must be manually
1584 reset between multiple calls to `getopts' within the same shell
1585 invocation if a new set of parameters is to be used.
1587 `getopts' can report errors in two ways. If the first character of
1588 OPTSTRING is a colon, SILENT error reporting is used. In normal
1589 operation diagnostic messages are printed when illegal options or
1590 missing option arguments are encountered. If the variable `OPTERR'
1591 is set to 0, no error message will be displayed, even if the first
1592 character of `optstring' is not a colon.
1594 If an illegal option is seen, `getopts' places `?' into NAME and,
1595 if not silent, prints an error message and unsets `OPTARG'. If
1596 `getopts' is silent, the option character found is placed in
1597 `OPTARG' and no diagnostic message is printed.
1599 If a required argument is not found, and `getopts' is not silent,
1600 a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
1601 diagnostic message is printed. If `getopts' is silent, then a
1602 colon (`:') is placed in NAME and `OPTARG' is set to the option
1605 `getopts' normally parses the positional parameters, but if more
1606 arguments are given in ARGS, `getopts' parses those instead.
1609 hash [-r] [-p FILENAME] [NAME]
1610 Remember the full filenames of commands specified as arguments, so
1611 they need not be searched for on subsequent invocations. The
1612 commands are found by searching through the directories listed in
1613 `$PATH'. The `-p' option inhibits the path search, and FILENAME
1614 is used as the location of NAME. The `-r' option causes the shell
1615 to forget all remembered locations. If no arguments are given,
1616 information about remembered commands is printed.
1620 Print the current working directory. If the `-P' option is
1621 supplied, the path printed will not contain symbolic links. If
1622 the `-L' option is supplied, the path printed may contain symbolic
1626 readonly [-apf] [NAME] ...
1627 Mark each NAME as unchangable. The values of these names may not
1628 be changed by subsequent assignment. If the `-f' option is
1629 supplied, each NAME refers to a shell function. The `-a' option
1630 means each NAME refers to an array variable. If no NAME arguments
1631 are given, or if the `-p' option is supplied, a list of all
1632 readonly names is printed.
1636 Cause a shell function to exit with value N. This may also be used
1637 to terminate execution of a script being executed with the `.'
1642 Shift positional parameters to the left by N. The positional
1643 parameters from N+1 ... are renamed to `$1' ... . Parameters
1644 represented by the numbers `$#' to N+1 are unset. N must be a
1645 non-negative number less than or equal to `$#'.
1649 Evaluate a conditional expression (*note Bash Conditional
1654 Print out the user and system times used by the shell and its
1658 trap [-lp] [ARG] [SIGSPEC ...]
1659 The commands in ARG are to be read and executed when the shell
1660 receives signal SIGSPEC. If ARG is absent or equal to `-', all
1661 specified signals are reset to the values they had when the shell
1662 was started. If ARG is the null string, then the signal specified
1663 by each SIGSPEC is ignored by the shell and commands it invokes.
1664 If ARG is `-p', the shell displays the trap commands associated
1665 with each SIGSPEC. If no arguments are supplied, or only `-p' is
1666 given, `trap' prints the list of commands associated with each
1667 signal number. Each SIGSPEC is either a signal name such as
1668 `SIGINT' (with or without the `SIG' prefix) or a signal number.
1669 If a SIGSPEC is `0' or `EXIT', ARG is executed when the shell
1670 exits. If a SIGSPEC is `DEBUG', the command ARG is executed after
1671 every simple command. The `-l' option causes the shell to print a
1672 list of signal names and their corresponding numbers.
1674 Signals ignored upon entry to the shell cannot be trapped or reset.
1675 Trapped signals are reset to their original values in a child
1676 process when it is created.
1680 Set the shell process's file creation mask to MODE. If MODE
1681 begins with a digit, it is interpreted as an octal number; if not,
1682 it is interpreted as a symbolic mode mask similar to that accepted
1683 by the `chmod' command. If MODE is omitted, the current value of
1684 the mask is printed. If the `-S' option is supplied without a
1685 MODE argument, the mask is printed in a symbolic format.
1689 Each variable or function NAME is removed. If no options are
1690 supplied, or the `-v' option is given, each NAME refers to a shell
1691 variable. If the `-f' option is given, the NAMEs refer to shell
1692 functions, and the function definition is removed. Read-only
1693 variables and functions may not be unset.
1696 File: bashref.info, Node: Bourne Shell Variables, Next: Other Bourne Shell Features, Prev: Bourne Shell Builtins, Up: Bourne Shell Features
1698 Bourne Shell Variables
1699 ======================
1701 Bash uses certain shell variables in the same way as the Bourne
1702 shell. In some cases, Bash assigns a default value to the variable.
1705 A list of characters that separate fields; used when the shell
1706 splits words as part of expansion.
1709 A colon-separated list of directories in which the shell looks for
1713 The current user's home directory; the default for the `cd' builtin
1717 A colon-separated list of directories used as a search path for
1721 A colon-separated list of files which the shell periodically checks
1722 for new mail. You can also specify what message is printed by
1723 separating the file name from the message with a `?'. When used
1724 in the text of the message, `$_' stands for the name of the
1728 If this parameter is set to a filename and the `MAILPATH' variable
1729 is not set, Bash informs the user of the arrival of mail in the
1733 The primary prompt string. The default value is `\s-\v\$ '.
1736 The secondary prompt string. The default value is `> '.
1739 The index of the last option processed by the `getopts' builtin.
1742 The value of the last option argument processed by the `getopts'
1746 File: bashref.info, Node: Other Bourne Shell Features, Prev: Bourne Shell Variables, Up: Bourne Shell Features
1748 Other Bourne Shell Features
1749 ===========================
1753 * Major Differences From The Bourne Shell:: Major differences between
1754 Bash and the Bourne shell.
1756 Bash implements essentially the same grammar, parameter and variable
1757 expansion, redirection, and quoting as the Bourne Shell. Bash uses the
1758 POSIX 1003.2 standard as the specification of how these features are to
1759 be implemented. There are some differences between the traditional
1760 Bourne shell and the POSIX standard; this section quickly details the
1761 differences of significance. A number of these differences are
1762 explained in greater depth in subsequent sections.
1765 File: bashref.info, Node: Major Differences From The Bourne Shell, Up: Other Bourne Shell Features
1767 Major Differences From The SVR4.2 Bourne Shell
1768 ----------------------------------------------
1770 Bash is POSIX-conformant, even where the POSIX specification differs
1771 from traditional `sh' behavior.
1773 Bash has multi-character invocation options (*note Invoking Bash::.).
1775 Bash has command-line editing (*note Command Line Editing::.) and
1778 Bash has command history (*note Bash History Facilities::.) and the
1779 `history' and `fc' builtins to manipulate it.
1781 Bash implements `csh'-like history expansion (*note History
1784 Bash has one-dimensional array variables (*note Arrays::.), and the
1785 appropriate variable expansions and assignment syntax to use them.
1786 Some of the Bash builtins take options to act on arrays. Bash provides
1787 some built-in array variables.
1789 Bash implements the `!' keyword to negate the return value of a
1790 pipeline (*note Pipelines::.). Very useful when an `if' statement
1791 needs to act only if a test fails.
1793 Bash includes the `select' compound command, which allows the
1794 generation of simple menus (*note Korn Shell Constructs::.).
1796 Bash includes brace expansion (*note Brace Expansion::.) and tilde
1797 expansion (*note Tilde Expansion::.).
1799 Bash implements command aliases and the `alias' and `unalias'
1800 builtins (*note Aliases::.).
1802 Bash provides shell arithmetic and arithmetic expansion (*note Shell
1805 The POSIX and `ksh'-style `$()' form of command substitution is
1806 implemented (*note Command Substitution::.), and preferred to the
1807 Bourne shell's ```' (which is also implemented for backwards
1810 Variables present in the shell's initial environment are
1811 automatically exported to child processes. The Bourne shell does not
1812 normally do this unless the variables are explicitly marked using the
1815 Bash includes the POSIX and `ksh'-style pattern removal `%', `#',
1816 `%%' and `##' constructs to remove leading or trailing substrings from
1817 variable values (*note Shell Parameter Expansion::.).
1819 The expansion `${#xx}', which returns the length of `$xx', is
1820 supported (*note Shell Parameter Expansion::.).
1822 The `$'...'' quoting syntax, which expands ANSI-C backslash-escaped
1823 characters in the text between the single quotes, is supported (*note
1826 Bash supports the `$"..."' quoting syntax to do locale-specific
1827 translation of the characters between the double quotes. The `-D' and
1828 `--dump-strings' invocation options list the translatable strings found
1829 in a script (*note Locale Translation::.).
1831 The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
1832 substring of `var''s value of length LENGTH, optionally beginning at
1833 OFFSET, is present (*note Shell Parameter Expansion::.).
1835 The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
1836 PATTERN and replaces it with REPLACEMENT in the value of `var', is
1837 available (*note Shell Parameter Expansion::.).
1839 Bash has INDIRECT variable expansion using `${!word}' (*note Shell
1840 Parameter Expansion::.).
1842 Bash can expand positional parameters beyond `$9' using `${NUM}'.
1844 Bash has process substitution (*note Process Substitution::.).
1846 Bash automatically assigns variables that provide information about
1847 the current user (`UID', `EUID', and `GROUPS'), the current host
1848 (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the instance of
1849 Bash that is running (`BASH', `BASH_VERSION', and `BASH_VERSINFO'.
1850 *Note Bash Variables::, for details.
1852 The `IFS' variable is used to split only the results of expansion,
1853 not all words (*note Word Splitting::.). This closes a longstanding
1854 shell security hole.
1856 It is possible to have a variable and a function with the same name;
1857 `sh' does not separate the two name spaces.
1859 Bash functions are permitted to have local variables using the
1860 `local' builtin, and thus useful recursive functions may be written.
1862 Variable assignments preceding commands affect only that command,
1863 even builtins and functions (*note Environment::.). In `sh', all
1864 variable assignments preceding commands are global unless the command
1865 is executed from the file system.
1867 Bash performs filename expansion on filenames specified as operands
1868 to output redirection operators.
1870 Bash contains the `<>' redirection operator, allowing a file to be
1871 opened for both reading and writing, and the `&>' redirection operator,
1872 for directing standard output and standard error to the same file
1873 (*note Redirections::.).
1875 The `noclobber' option is available to avoid overwriting existing
1876 files with output redirection (*note The Set Builtin::.). The `>|'
1877 redirection operator may be used to override `noclobber'.
1879 Bash interprets special backslash-escaped characters in the prompt
1880 strings when interactive (*note Printing a Prompt::.).
1882 Bash allows you to write a function to override a builtin, and
1883 provides access to that builtin's functionality within the function via
1884 the `builtin' and `command' builtins (*note Bash Builtins::.).
1886 The `command' builtin allows selective disabling of functions when
1887 command lookup is performed (*note Bash Builtins::.).
1889 Individual builtins may be enabled or disabled using the `enable'
1890 builtin (*note Bash Builtins::.).
1892 The Bash `hash' builtin allows a name to be associated with an
1893 arbitrary filename, even when that filename cannot be found by
1894 searching the `$PATH', using `hash -p'.
1896 Shell functions may be exported to children via the environment
1897 (*note Shell Functions::.).
1899 Bash includes a `help' builtin for quick reference to shell
1900 facilities (*note Bash Builtins::.).
1902 The Bash `read' builtin (*note Bash Builtins::.) will read a line
1903 ending in `\' with the `-r' option, and will use the `REPLY' variable
1904 as a default if no arguments are supplied. The Bash `read' builtin
1905 also accepts a prompt string with the `-p' option and will use Readline
1906 to obtain the line when given the `-e' option.
1908 Bash includes the `shopt' builtin, for finer control of shell
1909 optional capabilities (*note Bash Builtins::.).
1911 Bash has much more optional behavior controllable with the `set'
1912 builtin (*note The Set Builtin::.).
1914 The `disown' builtin can remove a job from the internal shell job
1915 table (*note Job Control Builtins::.).
1917 The `return' builtin may be used to abort execution of scripts
1918 executed with the `.' or `source' builtins (*note Bourne Shell
1921 The `test' builtin (*note Bourne Shell Builtins::.) is slightly
1922 different, as it implements the POSIX 1003.2 algorithm, which specifies
1923 the behavior based on the number of arguments.
1925 The `trap' builtin (*note Bourne Shell Builtins::.) allows a `DEBUG'
1926 pseudo-signal specification, similar to `EXIT'. Commands specified
1927 with a `DEBUG' trap are executed after every simple command. The
1928 `DEBUG' trap is not inherited by shell functions.
1930 The Bash `export', `readonly', and `declare' builtins can take a
1931 `-f' option to act on shell functions, a `-p' option to display
1932 variables with various attributes set in a format that can be used as
1933 shell input, a `-n' option to remove various variable attributes, and
1934 `name=value' arguments to set variable attributes and values
1937 The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::.)
1938 each take `-L' and `-P' builtins to switch between logical and physical
1941 The Bash `type' builtin is more extensive and gives more information
1942 about the names it finds (*note Bash Builtins::.).
1944 Bash implements a `csh'-like directory stack, and provides the
1945 `pushd', `popd', and `dirs' builtins to manipulate it (*note C Shell
1946 Builtins::.). Bash also makes the directory stack visible as the value
1947 of the `DIRSTACK' shell variable.
1949 The Bash restricted mode is more useful (*note The Restricted
1950 Shell::.); the SVR4.2 shell restricted mode is too limited.
1952 Bash has the `time' reserved word and command timing (*note
1953 Pipelines::.). The display of the timing statistics may be controlled
1954 with the `TIMEFORMAT' variable.
1956 The SVR4.2 shell has two privilege-related builtins (`mldmode' and
1957 `priv') not present in Bash.
1959 Bash does not have the `stop' or `newgrp' builtins.
1961 Bash does not use the `SHACCT' variable or perform shell accounting.
1963 The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
1965 More features unique to Bash may be found in *Note Bash Features::.
1967 Implementation Differences From The SVR4.2 Shell
1968 ------------------------------------------------
1970 Since Bash is a completely new implementation, it does not suffer
1971 from many of the limitations of the SVR4.2 shell. For instance:
1973 * Bash does not fork a subshell when redirecting into or out of a
1974 shell control structure such as an `if' or `while' statement.
1976 * Bash does not allow unbalanced quotes. The SVR4.2 shell will
1977 silently insert a needed closing quote at `EOF' under certain
1978 circumstances. This can be the cause of some hard-to-find errors.
1980 * The SVR4.2 shell uses a baroque memory management scheme based on
1981 trapping `SIGSEGV'. If the shell is started from a process with
1982 `SIGSEGV' blocked (e.g., by using the `system()' C library
1983 function call), the shell misbehaves badly.
1985 * In a questionable attempt at security, the SVR4.2 shell, when
1986 invoked without the `-p' option, will alter its real and effective
1987 UID and GID if they are less than some magic threshold value,
1988 commonly 100. This can lead to unexpected results.
1990 * The SVR4.2 shell does not allow users to trap `SIGALRM' or
1993 * For some reason, the SVR4.2 shell does not allow the `MAILCHECK'
1994 variable to be unset.
1996 * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
1998 * Bash allows multiple option arguments when it is invoked (`-x -v');
1999 the SVR4.2 shell allows only one option argument (`-xv'). In
2000 fact, some versions of the shell dump core if the second argument
2003 * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
2004 script only if one of the POSIX.2 special builtins fails, and only
2005 for certain failures, as enumerated in the POSIX.2 standard.
2007 * The SVR4.2 shell behaves differently when invoked as `jsh' (it
2008 turns on job control).
2011 File: bashref.info, Node: Csh Features, Next: Korn Shell Features, Prev: Bourne Shell Features, Up: Top
2013 C-Shell Style Features
2014 **********************
2016 The C-Shell ("`csh'") was created by Bill Joy at The University of
2017 California at Berkeley. It is generally considered to have better
2018 features for interactive use than the original Bourne shell. Some of
2019 the `csh' features present in Bash include job control, history
2020 expansion, `protected' redirection, and several variables to control
2021 the interactive behaviour of the shell (e.g., `IGNOREEOF').
2023 *Note Using History Interactively::, for details on history
2028 * Brace Expansion:: Expansion of expressions within braces.
2029 * Tilde Expansion:: Expansion of the ~ character.
2030 * C Shell Builtins:: Builtin commands adopted from the C Shell.
2031 * C Shell Variables:: Variables which Bash uses in essentially
2032 the same way as the C Shell.
2035 File: bashref.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Csh Features
2040 Brace expansion is a mechanism by which arbitrary strings may be
2041 generated. This mechanism is similar to FILENAME EXPANSION (*note
2042 Filename Expansion::.), but the file names generated need not exist.
2043 Patterns to be brace expanded take the form of an optional PREAMBLE,
2044 followed by a series of comma-separated strings between a pair of
2045 braces, followed by an optional POSTAMBLE. The preamble is prepended
2046 to each string contained within the braces, and the postamble is then
2047 appended to each resulting string, expanding left to right.
2049 Brace expansions may be nested. The results of each expanded string
2050 are not sorted; left to right order is preserved. For example,
2051 bash$ echo a{d,c,b}e
2054 Brace expansion is performed before any other expansions, and any
2055 characters special to other expansions are preserved in the result. It
2056 is strictly textual. Bash does not apply any syntactic interpretation
2057 to the context of the expansion or the text between the braces.
2059 A correctly-formed brace expansion must contain unquoted opening and
2060 closing braces, and at least one unquoted comma. Any incorrectly
2061 formed brace expansion is left unchanged.
2063 This construct is typically used as shorthand when the common prefix
2064 of the strings to be generated is longer than in the above example:
2065 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2067 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2070 File: bashref.info, Node: Tilde Expansion, Next: C Shell Builtins, Prev: Brace Expansion, Up: Csh Features
2075 Bash has tilde (~) expansion, similar, but not identical, to that of
2076 `csh'. The following table shows what unquoted words beginning with a
2080 The current value of `$HOME'.
2086 The subdirectory `foo' of the home directory of the user `fred'.
2094 Bash will also tilde expand words following redirection operators
2095 and words following `=' in assignment statements.
2098 File: bashref.info, Node: C Shell Builtins, Next: C Shell Variables, Prev: Tilde Expansion, Up: Csh Features
2103 Bash has several builtin commands whose definition is very similar
2107 pushd [DIR | +N | -N] [-n]
2109 Save the current directory on a list and then `cd' to DIR. With no
2110 arguments, exchanges the top two directories.
2113 Brings the Nth directory (counting from the left of the list
2114 printed by `dirs', starting with zero) to the top of the list
2115 by rotating the stack.
2118 Brings the Nth directory (counting from the right of the list
2119 printed by `dirs', starting with zero) to the top of the list
2120 by rotating the stack.
2123 Suppresses the normal change of directory when adding
2124 directories to the stack, so that only the stack is
2128 Makes the current working directory be the top of the stack,
2129 and then `cd's to DIR. You can see the saved directory list
2130 with the `dirs' command.
2135 Pop the directory stack, and `cd' to the new top directory. When
2136 no arguments are given, `popd' removes the top directory from the
2137 stack and performs a `cd' to the new top directory. The elements
2138 are numbered from 0 starting at the first directory listed with
2139 `dirs'; i.e., `popd' is equivalent to `popd +0'.
2141 Removes the Nth directory (counting from the left of the list
2142 printed by `dirs'), starting with zero.
2145 Removes the Nth directory (counting from the right of the
2146 list printed by `dirs'), starting with zero.
2149 Suppresses the normal change of directory when removing
2150 directories from the stack, so that only the stack is
2154 dirs [+N | -N] [-clvp]
2155 Display the list of currently remembered directories. Directories
2156 find their way onto the list with the `pushd' command; you can get
2157 back up through the list with the `popd' command.
2159 Displays the Nth directory (counting from the left of the
2160 list printed by `dirs' when invoked without options), starting
2164 Displays the Nth directory (counting from the right of the
2165 list printed by `dirs' when invoked without options), starting
2169 Clears the directory stack by deleting all of the elements.
2172 Produces a longer listing; the default listing format uses a
2173 tilde to denote the home directory.
2176 Causes `dirs' to print the directory stack with one entry per
2180 Causes `dirs' to print the directory stack with one entry per
2181 line, prepending each entry with its index in the stack.
2185 history [-anrw] [FILENAME]
2188 Display the history list with line numbers. Lines prefixed with
2189 with a `*' have been modified. An argument of N says to list only
2190 the last N lines. Options, if supplied, have the following
2194 Write out the current history to the history file.
2197 Read the current history file and append its contents to the
2201 Append the new history lines (history lines entered since the
2202 beginning of the current Bash session) to the history file.
2205 Append the history lines not already read from the history
2206 file to the current history list. These are lines appended
2207 to the history file since the beginning of the current Bash
2211 Clear the history list. This may be combined with the other
2212 options to replace the history list completely.
2215 The ARGs are added to the end of the history list as a single
2219 Perform history substitution on the ARGs and display the
2220 result on the standard output, without storing the results in
2223 When the `-w', `-r', `-a', or `-n' option is used, if FILENAME is
2224 given, then it is used as the history file. If not, then the
2225 value of the `HISTFILE' variable is used.
2231 A synonym for `.' (*note Bourne Shell Builtins::.).
2234 File: bashref.info, Node: C Shell Variables, Prev: C Shell Builtins, Up: Csh Features
2240 If this variable is set, its value is used the number of
2241 consecutive `EOF's Bash will read before exiting. By default,
2242 Bash will exit upon reading a single `EOF'. If `IGNOREEOF' is not
2243 set to a numeric value, Bash acts as if its value were 10.
2246 File: bashref.info, Node: Korn Shell Features, Next: Bash Features, Prev: Csh Features, Up: Top
2248 Korn Shell Style Features
2249 *************************
2251 This section describes features primarily inspired by the Korn Shell
2252 (`ksh'). In some cases, the POSIX 1003.2 standard has adopted these
2253 commands and variables from the Korn Shell; Bash implements those
2254 features using the POSIX standard as a guide.
2258 * Korn Shell Constructs:: Shell grammar constructs adopted from the
2260 * Korn Shell Builtins:: Builtin commands adopted from the Korn Shell.
2261 * Korn Shell Variables:: Variables which Bash uses in essentially
2262 the same way as the Korn Shell.
2263 * Aliases:: Substituting one command for another.
2266 File: bashref.info, Node: Korn Shell Constructs, Next: Korn Shell Builtins, Up: Korn Shell Features
2268 Korn Shell Constructs
2269 =====================
2271 Bash includes the Korn Shell `select' construct. This construct
2272 allows the easy generation of menus. It has almost the same syntax as
2275 The syntax of the `select' command is:
2276 select NAME [in WORDS ...]; do COMMANDS; done
2278 The list of words following `in' is expanded, generating a list of
2279 items. The set of expanded words is printed on the standard error,
2280 each preceded by a number. If the `in WORDS' is omitted, the
2281 positional parameters are printed. The `PS3' prompt is then displayed
2282 and a line is read from the standard input. If the line consists of a
2283 number corresponding to one of the displayed words, then the value of
2284 NAME is set to that word. If the line is empty, the words and prompt
2285 are displayed again. If `EOF' is read, the `select' command completes.
2286 Any other value read causes NAME to be set to null. The line read is
2287 saved in the variable `REPLY'.
2289 The COMMANDS are executed after each selection until a `break' or
2290 `return' command is executed, at which point the `select' command
2293 Bash also has adopted command timing from the Korn shell. If the
2294 `time' reserved word precedes a pipeline, which may consist of a single
2295 command, timing statistics for the pipeline are displayed when it
2296 completes. The statistics currently consist of elapsed (wall-clock)
2297 time and user and system time consumed by the command's execution.
2299 The use of `time' as a reserved word permits the timing of shell
2300 builtins, shell functions, and pipelines. An external `time' command
2301 cannot time these easily.
2304 File: bashref.info, Node: Korn Shell Builtins, Next: Korn Shell Variables, Prev: Korn Shell Constructs, Up: Korn Shell Features
2309 This section describes Bash builtin commands taken from `ksh'.
2312 `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
2313 `fc -s [PAT=REP] [COMMAND]'
2315 Fix Command. In the first form, a range of commands from FIRST to
2316 LAST is selected from the history list. Both FIRST and LAST may
2317 be specified as a string (to locate the most recent command
2318 beginning with that string) or as a number (an index into the
2319 history list, where a negative number is used as an offset from the
2320 current command number). If LAST is not specified it is set to
2321 FIRST. If FIRST is not specified it is set to the previous
2322 command for editing and -16 for listing. If the `-l' flag is
2323 given, the commands are listed on standard output. The `-n' flag
2324 suppresses the command numbers when listing. The `-r' flag
2325 reverses the order of the listing. Otherwise, the editor given by
2326 ENAME is invoked on a file containing those commands. If ENAME is
2327 not given, the value of the following variable expansion is used:
2328 `${FCEDIT:-${EDITOR:-vi}}'. This says to use the value of the
2329 `FCEDIT' variable if set, or the value of the `EDITOR' variable if
2330 that is set, or `vi' if neither is set. When editing is complete,
2331 the edited commands are echoed and executed.
2333 In the second form, COMMAND is re-executed after each instance of
2334 PAT in the selected command is replaced by REP.
2336 A useful alias to use with the `fc' command is `r='fc -s'', so
2337 that typing `r cc' runs the last command beginning with `cc' and
2338 typing `r' re-executes the last command (*note Aliases::.).
2341 The `let' builtin allows arithmetic to be performed on shell
2342 variables. For details, refer to *Note Arithmetic Builtins::.
2345 The `typeset' command is supplied for compatibility with the Korn
2346 shell; however, it has been deprecated in favor of the `declare'
2347 command (*note Bash Builtins::.).
2350 File: bashref.info, Node: Korn Shell Variables, Next: Aliases, Prev: Korn Shell Builtins, Up: Korn Shell Features
2352 Korn Shell Variables
2353 ====================
2356 The default variable for the `read' builtin.
2359 Each time this parameter is referenced, a random integer between 0
2360 and 32767 is generated. Assigning a value to this variable seeds
2361 the random number generator.
2364 This variable expands to the number of seconds since the shell was
2365 started. Assignment to this variable resets the count to the
2366 value assigned, and the expanded value becomes the value assigned
2367 plus the number of seconds since the assignment.
2370 The value of this variable is used as the prompt for the `select'
2371 command. If this variable is not set, the `select' command
2375 This is the prompt printed before the command line is echoed when
2376 the `-x' option is set (*note The Set Builtin::.). The default is
2380 The current working directory as set by the `cd' builtin.
2383 The previous working directory as set by the `cd' builtin.
2386 If set to a value greater than zero, the value is interpreted as
2387 the number of seconds to wait for input after issuing the primary
2388 prompt. Bash terminates after that number of seconds if input does
2392 The line number in the script or shell function currently
2396 The editor used as a default by the `fc' builtin command.
2399 File: bashref.info, Node: Aliases, Prev: Korn Shell Variables, Up: Korn Shell Features
2406 * Alias Builtins:: Builtins commands to maniuplate aliases.
2408 The shell maintains a list of ALIASES that may be set and unset with
2409 the `alias' and `unalias' builtin commands.
2411 The first word of each command, if unquoted, is checked to see if it
2412 has an alias. If so, that word is replaced by the text of the alias.
2413 The alias name and the replacement text may contain any valid shell
2414 input, including shell metacharacters, with the exception that the
2415 alias name may not contain =. The first word of the replacement text
2416 is tested for aliases, but a word that is identical to an alias being
2417 expanded is not expanded a second time. This means that one may alias
2418 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
2419 expand the replacement text. If the last character of the alias value
2420 is a space or tab character, then the next command word following the
2421 alias is also checked for alias expansion.
2423 Aliases are created and listed with the `alias' command, and removed
2424 with the `unalias' command.
2426 There is no mechanism for using arguments in the replacement text,
2427 as in `csh'. If arguments are needed, a shell function should be used
2428 (*note Shell Functions::.).
2430 Aliases are not expanded when the shell is not interactive, unless
2431 the `expand_aliases' shell option is set using `shopt' (*note Bash
2434 The rules concerning the definition and use of aliases are somewhat
2435 confusing. Bash always reads at least one complete line of input
2436 before executing any of the commands on that line. Aliases are
2437 expanded when a command is read, not when it is executed. Therefore, an
2438 alias definition appearing on the same line as another command does not
2439 take effect until the next line of input is read. The commands
2440 following the alias definition on that line are not affected by the new
2441 alias. This behavior is also an issue when functions are executed.
2442 Aliases are expanded when the function definition is read, not when the
2443 function is executed, because a function definition is itself a
2444 compound command. As a consequence, aliases defined in a function are
2445 not available until after that function is executed. To be safe,
2446 always put alias definitions on a separate line, and do not use `alias'
2447 in compound commands.
2449 Note that for almost every purpose, aliases are superseded by shell
2453 File: bashref.info, Node: Alias Builtins, Up: Aliases
2459 alias [`-p'] [NAME[=VALUE] ...]
2461 Without arguments or with the `-p' option, `alias' prints the list
2462 of aliases on the standard output in a form that allows them to be
2463 reused as input. If arguments are supplied, an alias is defined
2464 for each NAME whose VALUE is given. If no VALUE is given, the name
2465 and value of the alias is printed.
2468 unalias [-a] [NAME ... ]
2470 Remove each NAME from the list of aliases. If `-a' is supplied,
2471 all aliases are removed.
2474 File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Korn Shell Features, Up: Top
2479 This section describes features unique to Bash.
2483 * Invoking Bash:: Command line options that you can give
2485 * Bash Startup Files:: When and how Bash executes scripts.
2486 * Is This Shell Interactive?:: Determining the state of a running Bash.
2487 * Bash Builtins:: Table of builtins specific to Bash.
2488 * The Set Builtin:: This builtin is so overloaded it
2489 deserves its own section.
2490 * Bash Conditional Expressions:: Primitives used in composing expressions for
2492 * Bash Variables:: List of variables that exist in Bash.
2493 * Shell Arithmetic:: Arithmetic on shell variables.
2494 * Arrays:: Array Variables
2495 * Printing a Prompt:: Controlling the PS1 string.
2496 * The Restricted Shell:: A more controlled mode of shell execution.
2497 * Bash POSIX Mode:: Making Bash behave more closely to what
2498 the POSIX standard specifies.
2501 File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
2506 bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2507 bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] -c STRING [ARGUMENT ...]
2508 bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2510 In addition to the single-character shell command-line options
2511 (*note The Set Builtin::.), there are several multi-character options
2512 that you can use. These options must appear on the command line before
2513 the single-character options in order for them to be recognized.
2519 Display a usage message on standard output and exit sucessfully.
2522 Make this shell act as if it were directly invoked by login. This
2523 is equivalent to `exec -l bash' but can be issued from another
2524 shell, such as `csh'. If you wanted to replace your current login
2525 shell with a Bash login shell, you would say `exec bash --login'.
2528 Do not use the GNU Readline library (*note Command Line Editing::.)
2529 to read interactive command lines.
2532 Don't load the system-wide startup file `/etc/profile' or any of
2533 the personal initialization files `~/.bash_profile',
2534 `~/.bash_login', or `~/.profile' when Bash is invoked as a login
2538 Don't read the `~/.bashrc' initialization file in an interactive
2539 shell. This is on by default if the shell is invoked as `sh'.
2542 Change the behavior of Bash where the default operation differs
2543 from the POSIX 1003.2 standard to match the standard. This is
2544 intended to make Bash behave as a strict superset of that
2545 standard. *Note Bash POSIX Mode::, for a description of the Bash
2549 Execute commands from FILENAME (instead of `~/.bashrc') in an
2553 Make the shell a restricted shell (*note The Restricted Shell::.).
2559 Show version information for this instance of Bash on the standard
2560 output and exit successfully.
2562 There are several single-character options you can give which are
2563 not available with the `set' builtin.
2566 Read and execute commands from STRING after processing the
2567 options, then exit. Any remaining arguments are assigned to the
2568 positional parameters, starting with `$0'.
2571 Force the shell to run interactively.
2574 Make the shell restricted.
2577 If this flag is present, or if no arguments remain after option
2578 processing, then commands are read from the standard input. This
2579 option allows the positional parameters to be set when invoking an
2583 A list of all double-quoted strings preceded by `$' is printed on
2584 the standard ouput. These are the strings that are subject to
2585 language translation when the current locale is not `C' or `POSIX'
2586 (*note Locale Translation::.). This implies the `-n' option; no
2587 commands will be executed.
2589 An *interactive* shell is one whose input and output are both
2590 connected to terminals (as determined by `isatty()'), or one started
2591 with the `-i' option.
2593 If arguments remain after option processing, and neither the `-c'
2594 nor the `-s' option has been supplied, the first argument is assumed to
2595 be the name of a file containing shell commands (*note Shell
2596 Scripts::.). When Bash is invoked in this fashion, `$0' is set to the
2597 name of the file, and the positional parameters are set to the
2598 remaining arguments. Bash reads and executes commands from this file,
2599 then exits. Bash's exit status is the exit status of the last command
2600 executed in the script. If no commands are executed, the exit status
2604 File: bashref.info, Node: Bash Startup Files, Next: Is This Shell Interactive?, Prev: Invoking Bash, Up: Bash Features
2609 This section describs how Bash executes its startup files. If any
2610 of the files exist but cannot be read, Bash reports an error. Tildes
2611 are expanded in file names as described above under Tilde Expansion
2612 (*note Tilde Expansion::.).
2614 When Bash is invoked as an interactive login shell, it first reads
2615 and executes commands from the file `/etc/profile', if that file exists.
2616 After reading that file, it looks for `~/.bash_profile',
2617 `~/.bash_login', and `~/.profile', in that order, and reads and
2618 executes commands from the first one that exists and is readable. The
2619 `--noprofile' option may be used when the shell is started to inhibit
2622 When a login shell exits, Bash reads and executes commands from the
2623 file `~/.bash_logout', if it exists.
2625 When an interactive shell that is not a login shell is started, Bash
2626 reads and executes commands from `~/.bashrc', if that file exists.
2627 This may be inhibited by using the `--norc' option. The `--rcfile
2628 FILE' option will force Bash to read and execute commands from FILE
2629 instead of `~/.bashrc'.
2631 So, typically, your `~/.bash_profile' contains the line
2632 `if [ -f `~/.bashrc' ]; then . `~/.bashrc'; fi'
2634 after (or before) any login-specific initializations.
2636 When Bash is started non-interactively, to run a shell script, for
2637 example, it looks for the variable `BASH_ENV' in the environment,
2638 expands its value if it appears there, and uses the expanded value as
2639 the name of a file to read and execute. Bash behaves as if the
2640 following command were executed:
2641 `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
2643 but the value of the `PATH' variable is not used to search for the file
2646 If Bash is invoked with the name `sh', it tries to mimic the startup
2647 behavior of historical versions of `sh' as closely as possible, while
2648 conforming to the POSIX standard as well.
2650 When invoked as a login shell, it first attempts to read and execute
2651 commands from `/etc/profile' and `~/.profile', in that order. The
2652 `--noprofile' option may be used to inhibit this behavior. When
2653 invoked as an interactive shell with the name `sh', `bash' looks for
2654 the variable `ENV', expands its value if it is defined, and uses the
2655 expanded value as the name of a file to read and execute. Since a
2656 shell invoked as `sh' does not attempt to read and execute commands
2657 from any other startup files, the `--rcfile' option has no effect. A
2658 non-interactive shell invoked with the name `sh' does not attempt to
2659 read any startup files.
2661 When invoked as `sh', Bash enters POSIX mode after the startup files
2664 When Bash is started in POSIX mode, as with the `--posix' command
2665 line option, it follows the POSIX standard for startup files. In this
2666 mode, the `ENV' variable is expanded and commands are read and executed
2667 from the file whose name is the expanded value. No other startup files
2668 are read. This is done by interactive shells only.
2670 Bash attempts to determine when it is being run by the remote shell
2671 daemon, usually `rshd'. If Bash determines it is being run by rshd, it
2672 reads and executes commands from `~/.bashrc', if that file exists and
2673 is readable. It will not do this if invoked as `sh'. The `--norc'
2674 option may be used to inhibit this behavior, and the `--rcfile' option
2675 may be used to force another file to be read, but rshd does not
2676 generally invoke the shell with those options or allow them to be
2680 File: bashref.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Features
2682 Is This Shell Interactive?
2683 ==========================
2685 As defined in *Note Invoking Bash::, an interactive shell is one
2686 whose input and output are both connected to terminals (as determined
2687 by `isatty(3)'), or one started with the `-i' option.
2689 You may wish to determine within a startup script whether Bash is
2690 running interactively or not. To do this, examine the variable `$PS1';
2691 it is unset in non-interactive shells, and set in interactive shells.
2694 if [ -z "$PS1" ]; then
2695 echo This shell is not interactive
2697 echo This shell is interactive
2700 Alternatively, you may test the value of the `-' special parameter.
2701 It contains `i' when the shell is interactive. For example:
2704 *i*) echo This shell is interactive ;;
2705 *) echo This shell is not interactive ;;
2709 File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Is This Shell Interactive?, Up: Bash Features
2711 Bash Builtin Commands
2712 =====================
2714 This section describes builtin commands which are unique to or have
2715 been extended in Bash.
2718 bind [-m KEYMAP] [-lpsvPSV] [-q NAME] [-r KEYSEQ]
2719 bind [-m KEYMAP] -f FILENAME
2720 bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
2722 Display current Readline (*note Command Line Editing::.) key and
2723 function bindings, or bind a key sequence to a Readline function
2724 or macro. The binding syntax accepted is identical to that of
2725 `.inputrc' (*note Readline Init File::.), but each binding must be
2726 passed as a separate argument: e.g.,
2727 `"\C-x\C-r":re-read-init-file'. Options, if supplied, have the
2731 Use KEYMAP as the keymap to be affected by the subsequent
2732 bindings. Acceptable KEYMAP names are `emacs',
2733 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
2734 `vi-command', and `vi-insert'. `vi' is equivalent to
2735 `vi-command'; `emacs' is equivalent to `emacs-standard'.
2738 List the names of all Readline functions
2741 Display Readline function names and bindings in such a way
2742 that they can be re-read
2745 List current Readline function names and bindings
2748 Display Readline variable names and values in such a way that
2752 List current Readline variable names and values
2755 Display Readline key sequences bound to macros and the
2756 strings they output in such a way that they can be re-read
2759 Display Readline key sequences bound to macros and the
2763 Read key bindings from FILENAME
2766 Query about which keys invoke the named FUNCTION
2769 Remove any current binding for KEYSEQ
2772 builtin [SHELL-BUILTIN [ARGS]]
2773 Run a shell builtin. This is useful when you wish to define a
2774 shell function with the same name as a shell builtin, but need the
2775 functionality of the builtin within the function itself.
2778 command [-pVv] COMMAND [ARGS ...]
2779 Runs COMMAND with ARG ignoring shell functions. If you have a
2780 shell function called `ls', and you wish to call the command `ls',
2781 you can say `command ls'. The `-p' option means to use a default
2782 value for `$PATH' that is guaranteed to find all of the standard
2785 If either the `-V' or `-v' option is supplied, a description of
2786 COMMAND is printed. The `-v' option causes a single word
2787 indicating the command or file name used to invoke COMMAND to be
2788 printed; the `-V' option produces a more verbose description.
2791 declare [-afFrxi] [-p] [NAME[=VALUE]]
2793 Declare variables and give them attributes. If no NAMEs are
2794 given, then display the values of variables instead.
2796 The `-p' option will display the attributes and values of each
2797 NAME. When `-p' is used, additional options are ignored. The
2798 `-F' option inhibits the display of function definitions; only the
2799 function name and attributes are printed. `-F' implies `-f'. The
2800 following options can be used to restrict output to variables with
2801 the specified attributes or to give variables attributes:
2804 Each NAME is an array variable (*note Arrays::.).
2807 Use function names only.
2810 The variable is to be treated as an integer; arithmetic
2811 evaluation (*note Shell Arithmetic::.) is performed when the
2812 variable is assigned a value.
2815 Make NAMEs readonly. These names cannot then be assigned
2816 values by subsequent assignment statements.
2819 Mark each NAME for export to subsequent commands via the
2822 Using `+' instead of `-' turns off the attribute instead. When
2823 used in a function, `declare' makes each NAME local, as with the
2827 echo [-neE] [arg ...]
2828 Output the `arg's, separated by spaces, terminated with a newline.
2829 The return status is always 0. If `-n' is specified, the
2830 trailing newline is suppressed. If the `-e' option is given,
2831 interpretation of the following backslash-escaped characters is
2832 enabled. The `-E' option disables the interpretation of these
2833 escape characters, even on systems where they are interpreted by
2834 default. `echo' interprets the following escape sequences:
2842 suppress trailing newline
2866 the character whose ASCII code is `nnn' (octal)
2869 enable [-n] [-p] [-f FILENAME] [-ads] [NAME ...]
2870 Enable and disable builtin shell commands. This allows you to use
2871 a disk command which has the same name as a shell builtin. If
2872 `-n' is used, the NAMEs become disabled. Otherwise NAMEs are
2873 enabled. For example, to use the `test' binary found via `$PATH'
2874 instead of the shell builtin version, type `enable -n test'.
2876 If the `-p' option is supplied, or no NAME arguments appear, a
2877 list of shell builtins is printed. With no other arguments, the
2878 list consists of all enabled shell builtins. The `-a' option
2879 means to list each builtin with an indication of whether or not it
2882 The `-f' option means to load the new builtin command NAME from
2883 shared object FILENAME, on systems that support dynamic loading.
2884 The `-d' option will delete a builtin loaded with `-f'. If there
2885 are no options, a list of the shell builtins is displayed. The
2886 `-s' option restricts `enable' to the POSIX.2 special builtins.
2887 If `-s' is used with `-f', the new builtin becomes a special
2892 Display helpful information about builtin commands. If PATTERN is
2893 specified, `help' gives detailed help on all commands matching
2894 PATTERN, otherwise a list of the builtins is printed.
2898 For each argument, create a local variable called NAME, and give
2899 it VALUE. `local' can only be used within a function; it makes
2900 the variable NAME have a visible scope restricted to that function
2905 Exit a login shell, returning a status of N to the shell's parent.
2908 read [-a ANAME] [-p PROMPT] [-er] [NAME ...]
2909 One line is read from the standard input, and the first word is
2910 assigned to the first NAME, the second word to the second NAME,
2911 and so on, with leftover words assigned to the last NAME. Only
2912 the characters in the value of the `IFS' variable are recognized
2913 as word delimiters. If no names are supplied, the line read is
2914 assigned to the variable `REPLY'. The return code is zero, unless
2915 end-of-file is encountered. Options, if supplied, have the
2919 If this option is given, a backslash-newline pair is not
2920 ignored, and the backslash is considered to be part of the
2924 Display `prompt', without a trailing newline, before
2925 attempting to read any input. The prompt is displayed only
2926 if input is coming from a terminal.
2929 The words are assigned to sequential indices of the array
2930 variable ANAME, starting at 0.
2933 Readline (*note Command Line Editing::.) is used to obtain
2937 shopt [-pqsu] [-o] [OPTNAME ...]
2938 Toggle the values of variables controlling optional shell behavior.
2939 With no options, or with the `-p' option, a list of all settable
2940 options is displayed, with an indication of whether or not each is
2941 set. Other options have the following meanings:
2944 Enable (set) each OPTNAME
2947 Disable (unset) each OPTNAME.
2950 Suppresses normal output; the return status indicates whether
2951 the OPTNAME is set or unset. If multiple OPTNAME arguments
2952 are given with `-q', the return status is zero if all
2953 OPTNAMES are enabled; non-zero otherwise.
2956 Restricts the values of OPTNAME to be those defined for the
2957 `-o' option to the `set' builtin (*note The Set Builtin::.).
2959 If either of `-s' or `-u' is used with no OPTNAME arguments, the
2960 display is limited to those options which are set or unset,
2963 Unless otherwise noted, the `shopt' options are disabled (off) by
2966 The return status when listing options is zero if all OPTNAMES are
2967 enabled, non-zero otherwise. When setting or unsetting options,
2968 the return status is zero unless an OPTNAME is not a legal shell
2971 The list of `shopt' options is:
2973 If this is set, an argument to the `cd' builtin command that
2974 is not a directory is assumed to be the name of a variable
2975 whose value is the directory to change to.
2978 If set, minor errors in the spelling of a directory component
2979 in a `cd' command will be corrected. The errors checked for
2980 are transposed characters, a missing character, and a
2981 character too many. If a correction is found, the corrected
2982 path is printed, and the command proceeds. This option is
2983 only used by interactive shells.
2986 If this is set, Bash checks that a command found in the hash
2987 table exists before trying to execute it. If a hashed
2988 command no longer exists, a normal path search is performed.
2991 If set, Bash checks the window size after each command and,
2992 if necessary, updates the values of `LINES' and `COLUMNS'.
2995 If set, Bash attempts to save all lines of a multiple-line
2996 command in the same history entry. This allows easy
2997 re-editing of multi-line commands.
3000 If set, Bash includes filenames beginning with a `.' in the
3001 results of filename expansion.
3004 If this is set, a non-interactive shell will not exit if it
3005 cannot execute the file specified as an argument to the `exec'
3006 builtin command. An interactive shell does not exit if `exec'
3010 If set, the history list is appended to the file named by the
3011 value of the `HISTFILE' variable when the shell exits, rather
3012 than overwriting the file.
3015 If set, and Readline is being used, a user is given the
3016 opportunity to re-edit a failed history substitution.
3019 If set, and Readline is being used, the results of history
3020 substitution are not immediately passed to the shell parser.
3021 Instead, the resulting line is loaded into the Readline
3022 editing buffer, allowing further modification.
3025 If set, and Readline is being used, Bash will attempt to
3026 perform hostname completion when a word beginning with `@' is
3027 being completed (*note Commands For Completion::.). This
3028 option is enabled by default.
3030 `interactive_comments'
3031 Allow a word beginning with `#' to cause that word and all
3032 remaining characters on that line to be ignored in an
3033 interactive shell. This option is enabled by default.
3036 If enabled, and the `cmdhist' option is enabled, multi-line
3037 commands are saved to the history with embedded newlines
3038 rather than using semicolon separators where possible.
3041 If set, and a file that Bash is checking for mail has been
3042 accessed since the last time it was checked, the message
3043 `"The mail in MAILFILE has been read"' is displayed.
3046 If set, Bash allows filename patterns which match no files to
3047 expand to a null string, rather than themselves.
3050 If set, prompt strings undergo variable and parameter
3051 expansion after being expanded (*note Printing a Prompt::.).
3052 This option is enabled by default.
3055 If this is set, the `shift' builtin prints an error message
3056 when the shift count exceeds the number of positional
3060 If set, the `source' builtin uses the value of `PATH' to find
3061 the directory containing the file supplied as an argument.
3062 This is enabled by default.
3065 type [-all] [-type | -path] [NAME ...]
3066 For each NAME, indicate how it would be interpreted if used as a
3069 If the `-type' flag is used, `type' returns a single word which is
3070 one of `alias', `function', `builtin', `file' or `keyword', if
3071 NAME is an alias, shell function, shell builtin, disk file, or
3072 shell reserved word, respectively. If the NAME is not found, then
3073 nothing is printed, and `type' returns a failure status.
3075 If the `-path' flag is used, `type' either returns the name of the
3076 disk file that would be executed, or nothing if `-type' would not
3079 If the `-all' flag is used, returns all of the places that contain
3080 an executable named FILE. This includes aliases and functions, if
3081 and only if the `-path' flag is not also used.
3083 `type' accepts `-a', `-t', and `-p' as equivalent to `-all',
3084 `-type', and `-path', respectively.
3087 ulimit [-acdflmnpstuvSH] [LIMIT]
3088 `ulimit' provides control over the resources available to processes
3089 started by the shell, on systems that allow such control. If an
3090 option is given, it is interpreted as follows:
3092 change and report the soft limit associated with a resource.
3095 change and report the hard limit associated with a resource.
3098 all current limits are reported.
3101 the maximum size of core files created.
3104 the maximum size of a process's data segment.
3107 the maximum size of files created by the shell.
3110 The maximum size that may be locked into memory.
3113 the maximum resident set size.
3116 the maximum number of open file descriptors.
3119 the pipe buffer size.
3122 the maximum stack size.
3125 the maximum amount of cpu time in seconds.
3128 the maximum number of processes available to a single user.
3131 the maximum amount of virtual memory available to the process.
3133 If LIMIT is given, it is the new value of the specified resource.
3134 Otherwise, the current value of the soft limit for the specified
3135 resource is printed, unless the `-H' option is supplied. When
3136 setting new limits, if neither `-H' nor `-S' is supplied, both the
3137 hard and soft limits are set. If no option is given, then `-f' is
3138 assumed. Values are in 1024-byte increments, except for `-t',
3139 which is in seconds, `-p', which is in units of 512-byte blocks,
3140 and `-n' and `-u', which are unscaled values.
3143 File: bashref.info, Node: The Set Builtin, Next: Bash Conditional Expressions, Prev: Bash Builtins, Up: Bash Features
3148 This builtin is so overloaded that it deserves its own section.
3151 set [-abefhkmnptuvxdBCHP] [-o OPTION] [ARGUMENT ...]
3154 Mark variables which are modified or created for export.
3157 Cause the status of terminated background jobs to be reported
3158 immediately, rather than before printing the next primary
3162 Exit immediately if a simple command exits with a non-zero
3166 Disable file name generation (globbing).
3169 Locate and remember (hash) commands as they are looked up for
3173 All arguments in the form of assignment statements are placed
3174 in the environment for a command, not just those that precede
3178 Job control is enabled (*note Job Control::.).
3181 Read commands but do not execute them.
3184 Set the flag corresponding to OPTION-NAME:
3193 use an `emacs'-style line editing interface (*note
3194 Command Line Editing::.).
3206 Enable command history, as described in *Note Bash
3207 History Facilities::. This option is on by default in
3211 the shell will not exit upon reading EOF.
3241 change the behavior of Bash where the default operation
3242 differs from the POSIX 1003.2 standard to match the
3243 standard. This is intended to make Bash behave as a
3244 strict superset of that standard.
3253 use a `vi'-style line editing interface.
3259 Turn on privileged mode. In this mode, the `$BASH_ENV' file
3260 is not processed, and shell functions are not inherited from
3261 the environment. This is enabled automatically on startup if
3262 the effective user (group) id is not equal to the real user
3263 (group) id. Turning this option off causes the effective user
3264 and group ids to be set to the real user and group ids.
3267 Exit after reading and executing one command.
3270 Treat unset variables as an error when substituting.
3273 Print shell input lines as they are read.
3276 Print commands and their arguments as they are executed.
3279 The shell will perform brace expansion (*note Brace
3280 Expansion::.). This option is on by default.
3283 Disallow output redirection to existing files.
3286 Enable `!' style history substitution (*note History
3287 Interaction::.). This flag is on by default for interactive
3291 If set, do not follow symbolic links when performing commands
3292 such as `cd' which change the current directory. The
3293 physical directory is used instead. By default, Bash follows
3294 the logical chain of directories when performing commands
3295 which change the current directory.
3297 For example, if `/usr/sys' is a link to `/usr/local/sys' then:
3298 $ cd /usr/sys; echo $PWD
3303 If `set -P' is on, then:
3304 $ cd /usr/sys; echo $PWD
3310 If no arguments follow this flag, then the positional
3311 parameters are unset. Otherwise, the positional parameters
3312 are set to the ARGUMENTS, even if some of them begin with a
3316 Signal the end of options, cause all remaining ARGUMENTS to
3317 be assigned to the positional parameters. The `-x' and `-v'
3318 options are turned off. If there are no arguments, the
3319 positional parameters remain unchanged.
3321 Using `+' rather than `-' causes these flags to be turned off.
3322 The flags can also be used upon invocation of the shell. The
3323 current set of flags may be found in `$-'.
3325 The remaining N ARGUMENTS are positional parameters and are
3326 assigned, in order, to `$1', `$2', ... `$N'. If no arguments are
3327 given, all shell variables are printed.
3330 File: bashref.info, Node: Bash Conditional Expressions, Next: Bash Variables, Prev: The Set Builtin, Up: Bash Features
3332 Bash Conditional Expressions
3333 ============================
3335 Conditional expressions are used by the `test' and `[' builtins.
3337 Expressions may be unary or binary. Unary expressions are often
3338 used to examine the status of a file. There are string operators and
3339 numeric comparison operators as well. Each operator and operand must
3340 be a separate argument. If FILE is of the form `/dev/fd/N', then file
3341 descriptor N is checked. Expressions are composed of the following
3345 True if FILE exists and is a block special file.
3348 True if FILE exists and is a character special file.
3351 True if FILE exists and is a directory.
3354 True if FILE exists.
3357 True if FILE exists and is a regular file.
3360 True if FILE exists and is set-group-id.
3363 True if FILE has its "sticky" bit set.
3366 True if FILE exists and is a symbolic link.
3369 True if FILE exists and is a named pipe.
3372 True if FILE exists and is readable.
3375 True if FILE exists and has a size greater than zero.
3378 True if FILE exists and is a socket.
3381 True if FD is opened on a terminal.
3384 True if FILE exists and its set-user-id bit is set.
3387 True if FILE exists and is writable.
3390 True if FILE exists and is executable.
3393 True if FILE exists and is owned by the effective user id.
3396 True if FILE exists and is owned by the effective group id.
3399 True if FILE1 is newer (according to modification date) than FILE2.
3402 True if FILE1 is older than FILE2.
3405 True if FILE1 and FILE2 have the same device and inode numbers.
3408 True if shell option OPTNAME is enabled. The list of options
3409 appears in the description of the `-o' option to the `set' builtin
3410 (*note The Set Builtin::.).
3413 True if the length of STRING is zero.
3417 True if the length of STRING is non-zero.
3420 True if the strings are equal. `==' may be used in place of `='.
3422 `STRING1 != STRING2'
3423 True if the strings are not equal.
3426 True if STRING1 sorts before STRING2 lexicographically.
3429 True if STRING1 sorts after STRING2 lexicographically.
3432 True if EXPR is false.
3435 True if both EXPR1 and EXPR2 are true.
3438 True if either EXPR1 and EXPR2 is true.
3441 `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'. These
3442 arithmetic binary operators return true if ARG1 is equal to, not
3443 equal to, less than, less than or equal to, greater than, or
3444 greater than or equal to ARG2, respectively. ARG1 and ARG2 may be
3445 positive or negative integers.
3447 The Bash `test' and `[' builtins evaluate conditional expressions
3448 using a set of rules based on the number of arguments. These are the
3452 The expression is false.
3455 The expression is true if and only if the argument is not null.
3458 If the first argument is `!', the expression is true if and only
3459 if the second argument is null. If the first argument is one of
3460 the listed unary operators, the expression is true if the unary
3461 test is true. If the first argument is not a legal unary
3462 operator, the expression is false.
3465 If the first argument is `!', the value is the negation of the
3466 two-argument test using the second and third arguments. If the
3467 second argument is one of the binary operators, the result of the
3468 expression is the result of the binary test using the first and
3469 third arguments as operands. If the first argument is exactly `('
3470 and the third argument is exactly `)', the result is the
3471 one-argument test of the second argument. Otherwise, the
3472 expression is false. The `-a' and `-o' operators are considered
3473 binary operators in this case.
3476 If the first argument is `!', the result is the negation of the
3477 three-argument expression composed of the remaining arguments.
3478 Otherwise, the expression is parsed and evaluated according to
3479 precedence. `-a' has a higher precedence than `-o'.
3482 The expression is parsed and evaluated according to precedence,
3483 with `-a' having a higher precedence than `-o'.
3486 File: bashref.info, Node: Bash Variables, Next: Shell Arithmetic, Prev: Bash Conditional Expressions, Up: Bash Features
3491 These variables are set or used by Bash, but other shells do not
3492 normally treat them specially.
3495 If this variable is set when Bash is invoked to execute a shell
3496 script, its value is expanded and used as the name of a startup
3497 file to read before executing the script. *Note Bash Startup
3501 The value of this parameter is used as a format string specifying
3502 how the timing information for pipelines prefixed with the `time'
3503 reserved word should be displayed. The `%' character introduces an
3504 escape sequence that is expanded to a time value or other
3505 information. The escape sequences and their meanings are as
3506 follows; the braces denote optional portions.
3512 The elapsed time in seconds.
3515 The number of CPU seconds spent in user mode.
3518 The number of CPU seconds spent in system mode.
3521 The CPU percentage, computed as (%U + %S) / %R.
3523 The optional P is a digit specifying the precision, the number of
3524 fractional digits after a decimal point. A value of 0 causes no
3525 decimal point or fraction to be output. At most three places
3526 after the decimal point may be specified; values of P greater than
3527 3 are changed to 3. If P is not specified, the value 3 is used.
3529 The optional `l' specifies a longer format, including minutes, of
3530 the form MMmSS.FFs. The value of P determines whether or not the
3531 fraction is included.
3533 If this variable is not set, bash acts as if it had the value
3534 `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''.
3535 If the value is null, no timing information is displayed. A
3536 trailing newline is added when the format string is displayed.
3539 Set to a value of `ignorespace', it means don't enter lines which
3540 begin with a space or tab into the history list. Set to a value
3541 of `ignoredups', it means don't enter lines which match the last
3542 entered line. A value of `ignoreboth' combines the two options.
3543 Unset, or set to any other value than those above, means to save
3544 all lines on the history list.
3547 A colon-separated list of patterns used to decide which command
3548 lines should be saved on the history list. Each pattern is
3549 anchored at the beginning of the line and must fully specify the
3550 line (no implicit `*' is appended). Each pattern is tested
3551 against the line after the checks specified by `HISTCONTROL' are
3552 applied. In addition to the normal shell pattern matching
3553 characters, `&' matches the previous history line. `&' may be
3554 escaped using a backslash. The backslash is removed before
3557 `HISTIGNORE' subsumes the function of `HISTCONTROL'. A pattern of
3558 `&' is identical to `ignoredups', and a pattern of `[ ]*' is
3559 identical to `ignorespace'. Combining these two patterns,
3560 separating them with a colon, provides the functionality of
3564 The name of the file to which the command history is saved. The
3565 default is `~/.bash_history'.
3568 If set, this is the maximum number of commands to remember in the
3572 The maximum number of lines contained in the history file. When
3573 this variable is assigned a value, the history file is truncated,
3574 if necessary, to contain no more than that number of lines. The
3575 default value is 500. The history file is also truncated to this
3576 size after writing it when an interactive shell exits.
3579 Up to three characters which control history expansion, quick
3580 substitution, and tokenization (*note History Interaction::.).
3581 The first character is the "history-expansion-char", that is, the
3582 character which signifies the start of a history expansion,
3583 normally `!'. The second character is the character which
3584 signifies `quick substitution' when seen as the first character on
3585 a line, normally `^'. The optional third character is the
3586 character which signifies the remainder of the line is a comment,
3587 when found as the first character of a word, usually `#'. The
3588 history comment character causes history substitution to be
3589 skipped for the remaining words on the line. It does not
3590 necessarily cause the shell parser to treat the rest of the line
3594 The history number, or index in the history list, of the current
3595 command. If `HISTCMD' is unset, it loses its special properties,
3596 even if it is subsequently reset.
3599 Contains the name of a file in the same format as `/etc/hosts' that
3600 should be read when the shell needs to complete a hostname. You
3601 can change the file interactively; the next time you attempt to
3602 complete a hostname, Bash will add the contents of the new file to
3603 the already existing database.
3606 How often (in seconds) that the shell should check for mail in the
3607 files specified in `MAILPATH'.
3610 If present, this contains a string which is a command to execute
3611 before the printing of each primary prompt (`$PS1').
3614 The numeric real user id of the current user.
3617 The numeric effective user id of the current user.
3620 An array variable containing the list of groups of which the
3621 current user is a member.
3624 The process id of the shell's parent process.
3627 The name of the current host.
3630 A string describing the machine Bash is running on.
3633 A string describing the operating system Bash is running on.
3636 A string that fully describes the system type on which Bash is
3637 executing, in the standard GNU CPU-COMPANY-SYSTEM format.
3640 A colon-separated list of enabled shell options. Each word in the
3641 list is a valid argument for the `-o' option to the `set' builtin
3642 command (*note The Set Builtin::.). The options appearing in
3643 `SHELLOPTS' are those reported as `on' by `set -o'. If this
3644 variable is in the environment when Bash starts up, each shell
3645 option in the list will be enabled before reading any startup
3646 files. This variable is readonly.
3649 A colon-separated list of suffixes to ignore when performing
3650 filename completion. A file name whose suffix matches one of the
3651 entries in `FIGNORE' is excluded from the list of matched file
3652 names. A sample value is `.o:~'
3655 A colon-separated list of patterns defining the set of filenames to
3656 be ignored by filename expansion. If a filename matched by a
3657 filename expansion pattern also matches one of the patterns in
3658 `GLOBIGNORE', it is removed from the list of matches.
3661 An array variable (*note Arrays::.) containing the current
3662 contents of the directory stack. Directories appear in the stack
3663 in the order they are displayed by the `dirs' builtin. Assigning
3664 to members of this array variable may be used to modify
3665 directories already in the stack, but the `pushd' and `popd'
3666 builtins must be used to add and remove directories. Assignment
3667 to this variable will not change the current directory. If
3668 `DIRSTACK' is unset, it loses its special properties, even if it
3669 is subsequently reset.
3672 An array variable (*note Arrays::.) containing a list of exit
3673 status values from the processes in the most-recently-executed
3674 foreground pipeline (which may contain only a single command).
3677 The name of the Readline startup file, overriding the default of
3681 The full filename used to execute the current instance of Bash.
3684 The version number of the current instance of Bash.
3687 An array variable whose members hold version information for this
3688 instance of Bash. The values assigned to the array members are as
3692 The major version number (the RELEASE).
3695 The minor version number (the VERSION).
3704 The release status (e.g., BETA1).
3707 The value of `MACHTYPE'.
3710 Incremented by one each time a new instance of Bash is started.
3711 This is intended to be a count of how deeply your Bash shells are
3715 If set to the value 1, Bash displays error messages generated by
3716 the `getopts' builtin command.
3719 Used to determine the locale category for any category not
3720 specifically selected with a variable starting with `LC_'.
3723 This variable overrides the value of `LANG' and any other `LC_'
3724 variable specifying a locale category.
3727 This variable determines the collation order used when sorting the
3728 results of filename expansion (*note Filename Expansion::.).
3731 This variable determines the locale used to translate double-quoted
3732 strings preceded by a `$' (*note Locale Translation::.).
3735 Controls the action of the shell on receipt of an `EOF' character
3736 as the sole input. If set, then the value of it is the number of
3737 consecutive `EOF' characters that can be read as the first
3738 character on an input line before the shell will exit. If the
3739 variable exists but does not have a numeric value (or has no
3740 value) then the default is 10. If the variable does not exist,
3741 then `EOF' signifies the end of input to the shell. This is only
3742 in effect for interactive shells.
3745 File: bashref.info, Node: Shell Arithmetic, Next: Arrays, Prev: Bash Variables, Up: Bash Features
3752 * Arithmetic Evaluation:: How shell arithmetic works.
3753 * Arithmetic Expansion:: How to use arithmetic in shell expansions.
3754 * Arithmetic Builtins:: Builtin commands that use shell arithmetic.
3756 Bash includes several mechanisms to evaluate arithmetic expressions
3757 and display the result or use it as part of a command.
3760 File: bashref.info, Node: Arithmetic Evaluation, Next: Arithmetic Expansion, Up: Shell Arithmetic
3762 Arithmetic Evaluation
3763 ---------------------
3765 The shell allows arithmetic expressions to be evaluated, as one of
3766 the shell expansions or by the `let' builtin.
3768 Evaluation is done in long integers with no check for overflow,
3769 though division by 0 is trapped and flagged as an error. The following
3770 list of operators is grouped into levels of equal-precedence operators.
3771 The levels are listed in order of decreasing precedence.
3774 unary minus and plus
3777 logical and bitwise negation
3780 multiplication, division, remainder
3783 addition, subtraction
3786 left and right bitwise shifts
3792 equality and inequality
3798 bitwise exclusive OR
3809 `expr ? expr : expr'
3810 conditional evaluation
3812 `= *= /= %= += -= <<= >>= &= ^= |='
3815 Shell variables are allowed as operands; parameter expansion is
3816 performed before the expression is evaluated. The value of a parameter
3817 is coerced to a long integer within an expression. A shell variable
3818 need not have its integer attribute turned on to be used in an
3821 Constants with a leading 0 are interpreted as octal numbers. A
3822 leading `0x' or `0X' denotes hexadecimal. Otherwise, numbers take the
3823 form [BASE`#']N, where BASE is a decimal number between 2 and 64
3824 representing the arithmetic base, and N is a number in that base. If
3825 BASE is omitted, then base 10 is used. The digits greater than 9 are
3826 represented by the lowercase letters, the uppercase letters, `_', and
3827 `@', in that order. If BASE is less than or equal to 36, lowercase and
3828 uppercase letters may be used interchangably to represent numbers
3831 Operators are evaluated in order of precedence. Sub-expressions in
3832 parentheses are evaluated first and may override the precedence rules
3836 File: bashref.info, Node: Arithmetic Expansion, Next: Arithmetic Builtins, Prev: Arithmetic Evaluation, Up: Shell Arithmetic
3838 Arithmetic Expansion
3839 --------------------
3841 Arithmetic expansion allows the evaluation of an arithmetic
3842 expression and the substitution of the result. The format for
3843 arithmetic expansion is:
3847 The expression is treated as if it were within double quotes, but a
3848 double quote inside the braces or parentheses is not treated specially.
3849 All tokens in the expression undergo parameter expansion, command
3850 substitution, and quote removal. Arithmetic substitutions may be
3853 The evaluation is performed according to the rules listed above. If
3854 the expression is invalid, Bash prints a message indicating failure and
3855 no substitution occurs.
3858 File: bashref.info, Node: Arithmetic Builtins, Prev: Arithmetic Expansion, Up: Shell Arithmetic
3864 let EXPRESSION [EXPRESSION]
3865 The `let' builtin allows arithmetic to be performed on shell
3866 variables. Each EXPRESSION is evaluated according to the rules
3867 given previously (*note Arithmetic Evaluation::.). If the last
3868 EXPRESSION evaluates to 0, `let' returns 1; otherwise 0 is
3872 File: bashref.info, Node: Arrays, Next: Printing a Prompt, Prev: Shell Arithmetic, Up: Bash Features
3877 Bash provides one-dimensional array variables. Any variable may be
3878 used as an array; the `declare' builtin will explicitly declare an
3879 array. There is no maximum limit on the size of an array, nor any
3880 requirement that members be indexed or assigned contiguously. Arrays
3883 An array is created automatically if any variable is assigned to
3885 name[SUBSCRIPT]=VALUE
3887 The SUBSCRIPT is treated as an arithmetic expression that must evaluate
3888 to a number greater than or equal to zero. To explicitly declare an
3893 declare -a NAME[SUBSCRIPT]
3895 is also accepted; the SUBSCRIPT is ignored. Attributes may be
3896 specified for an array variable using the `declare' and `readonly'
3897 builtins. Each attribute applies to all members of an array.
3899 Arrays are assigned to using compound assignments of the form
3900 name=(value1 ... valueN)
3902 where each VALUE is of the form `[[SUBSCRIPT]=]'STRING. If the
3903 optional subscript is supplied, that index is assigned to; otherwise
3904 the index of the element assigned is the last index assigned to by the
3905 statement plus one. Indexing starts at zero. This syntax is also
3906 accepted by the `declare' builtin. Individual array elements may be
3907 assigned to using the `name['SUBSCRIPT`]='VALUE syntax introduced above.
3909 Any element of an array may be referenced using
3910 `${name['SUBSCRIPT`]}'. The braces are required to avoid conflicts
3911 with the shell's filename expansion operators. If the SUBSCRIPT is `@'
3912 or `*', the word expands to all members of the array NAME. These
3913 subscripts differ only when the word appears within double quotes. If
3914 the word is double-quoted, `${name[*]}' expands to a single word with
3915 the value of each array member separated by the first character of the
3916 `IFS' variable, and `${name[@]}' expands each element of NAME to a
3917 separate word. When there are no array members, `${name[@]}' expands
3918 to nothing. This is analogous to the expansion of the special
3919 parameters `@' and `*'. `${#name['SUBSCRIPT`]}' expands to the length
3920 of `${name['SUBSCRIPT`]}'. If SUBSCRIPT is `@' or `*', the expansion
3921 is the number of elements in the array. Referencing an array variable
3922 without a subscript is equivalent to referencing element zero.
3924 The `unset' builtin is used to destroy arrays. `unset'
3925 NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT. `unset'
3926 NAME, where NAME is an array, removes the entire array. A subscript of
3927 `*' or `@' also removes the entire array.
3929 The `declare', `local', and `readonly' builtins each accept a `-a'
3930 option to specify an array. The `read' builtin accepts a `-a' option
3931 to assign a list of words read from the standard input to an array, and
3932 can read values from the standard input into individual array elements.
3933 The `set' and `declare' builtins display array values in a way that
3934 allows them to be reused as input.
3937 File: bashref.info, Node: Printing a Prompt, Next: The Restricted Shell, Prev: Arrays, Up: Bash Features
3939 Controlling the Prompt
3940 ======================
3942 The value of the variable `PROMPT_COMMAND' is examined just before
3943 Bash prints each primary prompt. If it is set and non-null, then the
3944 value is executed just as if you had typed it on the command line.
3946 In addition, the following table describes the special characters
3947 which can appear in the prompt variables:
3953 the date, in "Weekday Month Date" format (e.g., "Tue May 26").
3956 an escape character.
3959 the hostname, up to the first `.'.
3968 the name of the shell, the basename of `$0' (the portion following
3972 the time, in 24-hour HH:MM:SS format.
3975 the time, in 12-hour HH:MM:SS format.
3978 the time, in 12-hour am/pm format.
3981 the version of Bash (e.g., 2.00)
3984 the release of Bash, version + patchlevel (e.g., 2.00.0)
3987 the current working directory.
3990 the basename of `$PWD'.
3996 the history number of this command.
3999 the command number of this command.
4002 if the effective uid is 0, `#', otherwise `$'.
4005 the character corresponding to the octal number `nnn'.
4011 begin a sequence of non-printing characters. This could be used to
4012 embed a terminal control sequence into the prompt.
4015 end a sequence of non-printing characters.
4018 File: bashref.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Printing a Prompt, Up: Bash Features
4020 The Restricted Shell
4021 ====================
4023 If Bash is started with the name `rbash', or the `--restricted'
4024 option is supplied at invocation, the shell becomes restricted. A
4025 restricted shell is used to set up an environment more controlled than
4026 the standard shell. A restricted shell behaves identically to `bash'
4027 with the exception that the following are disallowed:
4028 * Changing directories with the `cd' builtin.
4030 * Setting or unsetting the values of the `SHELL' or `PATH' variables.
4032 * Specifying command names containing slashes.
4034 * Specifying a filename containing a slash as an argument to the `.'
4037 * Importing function definitions from the shell environment at
4040 * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
4041 redirection operators.
4043 * Using the `exec' builtin to replace the shell with another command.
4045 * Adding or deleting builtin commands with the `-f' and `-d' options
4046 to the `enable' builtin.
4048 * Specifying the `-p' option to the `command' builtin.
4050 * Turning off restricted mode with `set +r'.
4053 File: bashref.info, Node: Bash POSIX Mode, Prev: The Restricted Shell, Up: Bash Features
4058 Starting Bash with the `--posix' command-line option or executing
4059 `set -o posix' while Bash is running will cause Bash to conform more
4060 closely to the POSIX.2 standard by changing the behavior to match that
4061 specified by POSIX.2 in areas where the Bash default differs.
4063 The following list is what's changed when `POSIX mode' is in effect:
4065 1. When a command in the hash table no longer exists, Bash will
4066 re-search `$PATH' to find the new location. This is also
4067 available with `shopt -s checkhash'.
4069 2. The `>&' redirection does not redirect stdout and stderr.
4071 3. The message printed by the job control code and builtins when a job
4072 exits with a non-zero status is `Done(status)'.
4074 4. Reserved words may not be aliased.
4076 5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
4077 number and `!!' to `!' are enabled, and parameter expansion is
4078 performed on the value regardless of the setting of the
4079 `promptvars' option.
4081 6. Interactive comments are enabled by default. (Note that Bash has
4082 them on by default anyway.)
4084 7. The POSIX.2 startup files are executed (`$ENV') rather than the
4087 8. Tilde expansion is only performed on assignments preceding a
4088 command name, rather than on all assignment statements on the line.
4090 9. The default history file is `~/.sh_history' (this is the default
4091 value of `$HISTFILE').
4093 10. The output of `kill -l' prints all the signal names on a single
4094 line, separated by spaces.
4096 11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
4099 12. Redirection operators do not perform filename expansion on the word
4100 in the redirection unless the shell is interactive.
4102 13. Function names must be valid shell `name's. That is, they may not
4103 contain characters other than letters, digits, and underscores, and
4104 may not start with a digit. Declaring a function with an illegal
4105 name causes a fatal syntax error in non-interactive shells.
4107 14. POSIX.2 `special' builtins are found before shell functions during
4110 15. If a POSIX.2 special builtin returns an error status, a
4111 non-interactive shell exits. The fatal errors are those listed in
4112 the POSIX.2 standard, and include things like passing incorrect
4113 options, redirection errors, variable assignment errors for
4114 assignments preceding the command name, and so on.
4116 16. If the `cd' builtin finds a directory to change to using
4117 `$CDPATH', the value it assigns to the `PWD' variable does not
4118 contain any symbolic links, as if `cd -P' had been executed.
4120 17. A non-interactive shell exits with an error status if a variable
4121 assignment error occurs when no command name follows the assignment
4122 statements. A variable assignment error occurs, for example, when
4123 trying to assign a value to a read-only variable.
4125 18. A non-interactive shell exits with an error status if the iteration
4126 variable in a `for' statement or the selection variable in a
4127 `select' statement is a read-only variable.
4129 19. Process substitution is not available.
4131 20. Assignment statements preceding POSIX.2 `special' builtins persist
4132 in the shell environment after the builtin completes.
4134 21. The `export' and `readonly' builtin commands display their output
4135 in the format required by POSIX.2.
4138 There is other POSIX.2 behavior that Bash does not implement.
4141 1. Assignment statements affect the execution environment of all
4142 builtins, not just special ones.
4145 File: bashref.info, Node: Job Control, Next: Using History Interactively, Prev: Bash Features, Up: Top
4150 This chapter disusses what job control is, how it works, and how
4151 Bash allows you to access its facilities.
4155 * Job Control Basics:: How job control works.
4156 * Job Control Builtins:: Bash builtin commands used to interact
4158 * Job Control Variables:: Variables Bash uses to customize job
4162 File: bashref.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control
4167 Job control refers to the ability to selectively stop (suspend) the
4168 execution of processes and continue (resume) their execution at a later
4169 point. A user typically employs this facility via an interactive
4170 interface supplied jointly by the system's terminal driver and Bash.
4172 The shell associates a JOB with each pipeline. It keeps a table of
4173 currently executing jobs, which may be listed with the `jobs' command.
4174 When Bash starts a job asynchronously (in the background), it prints a
4175 line that looks like:
4178 indicating that this job is job number 1 and that the process ID of the
4179 last process in the pipeline associated with this job is 25647. All of
4180 the processes in a single pipeline are members of the same job. Bash
4181 uses the JOB abstraction as the basis for job control.
4183 To facilitate the implementation of the user interface to job
4184 control, the system maintains the notion of a current terminal process
4185 group ID. Members of this process group (processes whose process group
4186 ID is equal to the current terminal process group ID) receive
4187 keyboard-generated signals such as `SIGINT'. These processes are said
4188 to be in the foreground. Background processes are those whose process
4189 group ID differs from the terminal's; such processes are immune to
4190 keyboard-generated signals. Only foreground processes are allowed to
4191 read from or write to the terminal. Background processes which attempt
4192 to read from (write to) the terminal are sent a `SIGTTIN' (`SIGTTOU')
4193 signal by the terminal driver, which, unless caught, suspends the
4196 If the operating system on which Bash is running supports job
4197 control, Bash allows you to use it. Typing the SUSPEND character
4198 (typically `^Z', Control-Z) while a process is running causes that
4199 process to be stopped and returns you to Bash. Typing the DELAYED
4200 SUSPEND character (typically `^Y', Control-Y) causes the process to be
4201 stopped when it attempts to read input from the terminal, and control to
4202 be returned to Bash. You may then manipulate the state of this job,
4203 using the `bg' command to continue it in the background, the `fg'
4204 command to continue it in the foreground, or the `kill' command to kill
4205 it. A `^Z' takes effect immediately, and has the additional side
4206 effect of causing pending output and typeahead to be discarded.
4208 There are a number of ways to refer to a job in the shell. The
4209 character `%' introduces a job name. Job number `n' may be referred to
4210 as `%n'. A job may also be referred to using a prefix of the name used
4211 to start it, or using a substring that appears in its command line.
4212 For example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the
4213 other hand, refers to any job containing the string `ce' in its command
4214 line. If the prefix or substring matches more than one job, Bash
4215 reports an error. The symbols `%%' and `%+' refer to the shell's
4216 notion of the current job, which is the last job stopped while it was
4217 in the foreground. The previous job may be referenced using `%-'. In
4218 output pertaining to jobs (e.g., the output of the `jobs' command), the
4219 current job is always flagged with a `+', and the previous job with a
4222 Simply naming a job can be used to bring it into the foreground:
4223 `%1' is a synonym for `fg %1', bringing job 1 from the background into
4224 the foreground. Similarly, `%1 &' resumes job 1 in the background,
4225 equivalent to `bg %1'
4227 The shell learns immediately whenever a job changes state.
4228 Normally, Bash waits until it is about to print a prompt before
4229 reporting changes in a job's status so as to not interrupt any other
4230 output. If the the `-b' option to the `set' builtin is set, Bash
4231 reports such changes immediately (*note The Set Builtin::.).
4233 If you attempt to exit Bash while jobs are stopped, the shell prints
4234 a message warning you that you have stopped jobs. You may then use the
4235 `jobs' command to inspect their status. If you do this, or try to exit
4236 again immediately, you are not warned again, and the stopped jobs are
4240 File: bashref.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control
4242 Job Control Builtins
4243 ====================
4247 Place JOBSPEC into the background, as if it had been started with
4248 `&'. If JOBSPEC is not supplied, the current job is used.
4252 Bring JOBSPEC into the foreground and make it the current job. If
4253 JOBSPEC is not supplied, the current job is used.
4256 jobs [-lpnrs] [JOBSPEC]
4257 jobs -x COMMAND [JOBSPEC]
4259 The first form lists the active jobs. The options have the
4263 List process IDs in addition to the normal information
4266 Display information only about jobs that have changed status
4267 since you were last notified of their status.
4270 List only the process ID of the job's process group leader.
4273 Restrict output to running jobs.
4276 Restrict output to stopped jobs.
4278 If JOBSPEC is given, output is restricted to information about
4279 that job. If JOBSPEC is not supplied, the status of all jobs is
4282 If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
4283 in COMMAND or ARGUMENTS with the corresponding process group ID,
4284 and executes COMMAND, passing it ARGUMENTs, returning its exit
4288 kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC
4290 Send a signal specified by SIGSPEC or SIGNUM to the process named
4291 by JOBSPEC. SIGSPEC is either a signal name such as `SIGINT'
4292 (with or without the `SIG' prefix) or a signal number; SIGNUM is a
4293 signal number. If SIGSPEC and SIGNUM are not present, `SIGTERM'
4294 is used. The `-l' option lists the signal names, or the signal
4295 name corresponding to SIGSPEC.
4299 Wait until the child process specified by process ID PID or job
4300 specification JOBSPEC exits and report its exit status. If a job
4301 spec is given, all processes in the job are waited for. If no
4302 arguments are given, all currently active child processes are
4306 disown [-h] [JOBSPEC ...]
4307 Without options, each JOBSPEC is removed from the table of active
4308 jobs. If the `-h' option is given, the job is not removed from
4309 the table, but is marked so that `SIGHUP' is not sent to the job
4310 if the shell receives a `SIGHUP'. If JOBSPEC is not present, the
4311 current job is used.
4315 Suspend the execution of this shell until it receives a `SIGCONT'
4316 signal. The `-f' option means to suspend even if the shell is a
4319 When job control is not active, the `kill' and `wait' builtins do
4320 not accept JOBSPEC arguments. They must be supplied process IDs.
4323 File: bashref.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control
4325 Job Control Variables
4326 =====================
4329 This variable controls how the shell interacts with the user and
4330 job control. If this variable exists then single word simple
4331 commands without redirects are treated as candidates for resumption
4332 of an existing job. There is no ambiguity allowed; if there is
4333 more than one job beginning with the string typed, then the most
4334 recently accessed job will be selected. The name of a stopped
4335 job, in this context, is the command line used to start it. If
4336 this variable is set to the value `exact', the string supplied
4337 must match the name of a stopped job exactly; if set to
4338 `substring', the string supplied needs to match a substring of the
4339 name of a stopped job. The `substring' value provides
4340 functionality analogous to the `%?' job ID (*note Job Control
4341 Basics::.). If set to any other value, the supplied string must
4342 be a prefix of a stopped job's name; this provides functionality
4343 analogous to the `%' job ID.
4346 File: bashref.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
4348 Using History Interactively
4349 ***************************
4351 This chapter describes how to use the GNU History Library
4352 interactively, from a user's standpoint. It should be considered a
4353 user's guide. For information on using the GNU History Library in your
4354 own programs, see the GNU Readline Library Manual.
4358 * Bash History Facilities:: How Bash lets you manipulate your command
4360 * History Interaction:: What it feels like using History as a user.
4363 File: bashref.info, Node: Bash History Facilities, Next: History Interaction, Up: Using History Interactively
4365 Bash History Facilities
4366 =======================
4368 When the `-o history' option to the `set' builtin is enabled (*note
4369 The Set Builtin::.), the shell provides access to the COMMAND HISTORY,
4370 the list of commands previously typed. The text of the last `HISTSIZE'
4371 commands (default 500) is saved in a history list. The shell stores
4372 each command in the history list prior to parameter and variable
4373 expansion but after history expansion is performed, subject to the
4374 values of the shell variables `HISTIGNORE' and `HISTCONTROL'. When the
4375 shell starts up, the history is initialized from the file named by the
4376 `HISTFILE' variable (default `~/.bash_history'). `HISTFILE' is
4377 truncated, if necessary, to contain no more than the number of lines
4378 specified by the value of the `HISTFILESIZE' variable. When an
4379 interactive shell exits, the last `HISTSIZE' lines are copied from the
4380 history list to `HISTFILE'. If the `histappend' shell option is set
4381 (*note Bash Builtins::.), the lines are appended to the history file,
4382 otherwise the history file is overwritten. If `HISTFILE' is unset, or
4383 if the history file is unwritable, the history is not saved. After
4384 saving the history, the history file is truncated to contain no more
4385 than `$HISTFILESIZE' lines. If `HISTFILESIZE' is not set, no
4386 truncation is performed.
4388 The builtin command `fc' (*note Korn Shell Builtins::.) may be used
4389 to list or edit and re-execute a portion of the history list. The
4390 `history' builtin (*note C Shell Builtins::.) can be used to display or
4391 modify the history list and manipulate the history file. When using
4392 the command-line editing, search commands are available in each editing
4393 mode that provide access to the history list.
4395 The shell allows control over which commands are saved on the history
4396 list. The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
4397 the shell to save only a subset of the commands entered. The `cmdhist'
4398 shell option, if enabled, causes the shell to attempt to save each line
4399 of a multi-line command in the same history entry, adding semicolons
4400 where necessary to preserve syntactic correctness. The `lithist' shell
4401 option causes the shell to save the command with embedded newlines
4402 instead of semicolons. *Note Bash Builtins:: for a description of
4406 File: bashref.info, Node: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
4408 Interactive History Expansion
4409 =============================
4411 The History library provides a history expansion feature that is
4412 similar to the history expansion provided by `csh'. This section
4413 describes the syntax used to manipulate the history information.
4415 History expansions introduce words from the history list into the
4416 input stream, making it easy to repeat commands, insert the arguments
4417 to a previous command into the current input line, or fix errors in
4418 previous commands quickly.
4420 History expansion takes place in two parts. The first is to
4421 determine which line from the previous history should be used during
4422 substitution. The second is to select portions of that line for
4423 inclusion into the current one. The line selected from the previous
4424 history is called the "event", and the portions of that line that are
4425 acted upon are called "words". Various "modifiers" are available to
4426 manipulate the selected words. The line is broken into words in the
4427 same fashion that Bash does, so that several English (or Unix) words
4428 surrounded by quotes are considered as one word. History expansions
4429 are introduced by the appearance of the history expansion character,
4430 which is `!' by default. Only `\' and `'' may be used to escape the
4431 history expansion character.
4433 Several shell options settable with the `shopt' builtin (*note Bash
4434 Builtins::.) may be used to tailor the behavior of history expansion.
4435 If the `histverify' shell option is enabled, and Readline is being
4436 used, history substitutions are not immediately passed to the shell
4437 parser. Instead, the expanded line is reloaded into the Readline
4438 editing buffer for further modification. If Readline is being used,
4439 and the `histreedit' shell option is enabled, a failed history
4440 expansion will be reloaded into the Readline editing buffer for
4441 correction. The `-p' option to the `history' builtin command may be
4442 used to see what a history expansion will do before using it. The `-s'
4443 option to the `history' builtin may be used to add commands to the end
4444 of the history list without actually executing them, so that they are
4445 available for subsequent recall.
4447 The shell allows control of the various characters used by the
4448 history expansion mechanism with the `histchars' variable.
4452 * Event Designators:: How to specify which history line to use.
4453 * Word Designators:: Specifying which words are of interest.
4454 * Modifiers:: Modifying the results of substitution.
4457 File: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
4462 An event designator is a reference to a command line entry in the
4466 Start a history substitution, except when followed by a space, tab,
4467 the end of the line, = or (.
4470 Refer to command line N.
4473 Refer to the command N lines back.
4476 Refer to the previous command. This is a synonym for `!-1'.
4479 Refer to the most recent command starting with STRING.
4482 Refer to the most recent command containing STRING. The trailing
4483 `?' may be omitted if the STRING is followed immediately by a
4487 Quick Substitution. Repeat the last command, replacing STRING1
4488 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'.
4491 The entire command line typed so far.
4494 File: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
4499 Word designators are used to select desired words from the event. A
4500 `:' separates the event specification from the word designator. It can
4501 be omitted if the word designator begins with a `^', `$', `*', `-', or
4502 `%'. Words are numbered from the beginning of the line, with the first
4503 word being denoted by 0 (zero). Words are inserted into the current
4504 line separated by single spaces.
4507 The `0'th word. For many applications, this is the command word.
4513 The first argument; that is, word 1.
4519 The word matched by the most recent `?STRING?' search.
4522 A range of words; `-Y' abbreviates `0-Y'.
4525 All of the words, except the `0'th. This is a synonym for `1-$'.
4526 It is not an error to use `*' if there is just one word in the
4527 event; the empty string is returned in that case.
4533 Abbreviates `X-$' like `X*', but omits the last word.
4535 If a word designator is supplied without an event specification, the
4536 previous command is used as the event.
4539 File: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
4544 After the optional word designator, you can add a sequence of one or
4545 more of the following modifiers, each preceded by a `:'.
4548 Remove a trailing pathname component, leaving only the head.
4551 Remove all leading pathname components, leaving the tail.
4554 Remove a trailing suffix of the form `.SUFFIX', leaving the
4558 Remove all but the trailing suffix.
4561 Print the new command but do not execute it.
4564 Quote the substituted words, escaping further substitutions.
4567 Quote the substituted words as with `q', but break into words at
4568 spaces, tabs, and newlines.
4571 Substitute NEW for the first occurrence of OLD in the event line.
4572 Any delimiter may be used in place of `/'. The delimiter may be
4573 quoted in OLD and NEW with a single backslash. If `&' appears in
4574 NEW, it is replaced by OLD. A single backslash will quote the
4575 `&'. The final delimiter is optional if it is the last character
4579 Repeat the previous substitution.
4582 Cause changes to be applied over the entire event line. Used in
4583 conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
4586 File: bashref.info, Node: Command Line Editing, Next: Installing Bash, Prev: Using History Interactively, Up: Top
4588 Command Line Editing
4589 ********************
4591 This chapter describes the basic features of the GNU command line
4596 * Introduction and Notation:: Notation used in this text.
4597 * Readline Interaction:: The minimum set of commands for editing a line.
4598 * Readline Init File:: Customizing Readline from a user's view.
4599 * Bindable Readline Commands:: A description of most of the Readline commands
4600 available for binding
4601 * Readline vi Mode:: A short description of how to make Readline
4602 behave like the vi editor.
4605 File: bashref.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
4607 Introduction to Line Editing
4608 ============================
4610 The following paragraphs describe the notation used to represent
4613 The text C-k is read as `Control-K' and describes the character
4614 produced when the k key is pressed while the Control key is depressed.
4616 The text M-k is read as `Meta-K' and describes the character
4617 produced when the meta key (if you have one) is depressed, and the k
4618 key is pressed. If you do not have a meta key, the identical keystroke
4619 can be generated by typing ESC first, and then typing k. Either
4620 process is known as "metafying" the k key.
4622 The text M-C-k is read as `Meta-Control-k' and describes the
4623 character produced by "metafying" C-k.
4625 In addition, several keys have their own names. Specifically, DEL,
4626 ESC, LFD, SPC, RET, and TAB all stand for themselves when seen in this
4627 text, or in an init file (*note Readline Init File::.).
4630 File: bashref.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
4632 Readline Interaction
4633 ====================
4635 Often during an interactive session you type in a long line of text,
4636 only to notice that the first word on the line is misspelled. The
4637 Readline library gives you a set of commands for manipulating the text
4638 as you type it in, allowing you to just fix your typo, and not forcing
4639 you to retype the majority of the line. Using these editing commands,
4640 you move the cursor to the place that needs correction, and delete or
4641 insert the text of the corrections. Then, when you are satisfied with
4642 the line, you simply press RETURN. You do not have to be at the end of
4643 the line to press RETURN; the entire line is accepted regardless of the
4644 location of the cursor within the line.
4648 * Readline Bare Essentials:: The least you need to know about Readline.
4649 * Readline Movement Commands:: Moving about the input line.
4650 * Readline Killing Commands:: How to delete text, and how to get it back!
4651 * Readline Arguments:: Giving numeric arguments to commands.
4652 * Searching:: Searching through previous lines.
4655 File: bashref.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
4657 Readline Bare Essentials
4658 ------------------------
4660 In order to enter characters into the line, simply type them. The
4661 typed character appears where the cursor was, and then the cursor moves
4662 one space to the right. If you mistype a character, you can use your
4663 erase character to back up and delete the mistyped character.
4665 Sometimes you may miss typing a character that you wanted to type,
4666 and not notice your error until you have typed several other
4667 characters. In that case, you can type C-b to move the cursor to the
4668 left, and then correct your mistake. Afterwards, you can move the
4669 cursor to the right with C-f.
4671 When you add text in the middle of a line, you will notice that
4672 characters to the right of the cursor are `pushed over' to make room
4673 for the text that you have inserted. Likewise, when you delete text
4674 behind the cursor, characters to the right of the cursor are `pulled
4675 back' to fill in the blank space created by the removal of the text. A
4676 list of the basic bare essentials for editing the text of an input line
4680 Move back one character.
4683 Move forward one character.
4686 Delete the character to the left of the cursor.
4689 Delete the character underneath the cursor.
4692 Insert the character into the line at the cursor.
4695 Undo the last thing that you did. You can undo all the way back
4699 File: bashref.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
4701 Readline Movement Commands
4702 --------------------------
4704 The above table describes the most basic possible keystrokes that
4705 you need in order to do editing of the input line. For your
4706 convenience, many other commands have been added in addition to C-b,
4707 C-f, C-d, and DEL. Here are some commands for moving more rapidly
4711 Move to the start of the line.
4714 Move to the end of the line.
4717 Move forward a word.
4720 Move backward a word.
4723 Clear the screen, reprinting the current line at the top.
4725 Notice how C-f moves forward a character, while M-f moves forward a
4726 word. It is a loose convention that control keystrokes operate on
4727 characters while meta keystrokes operate on words.
4730 File: bashref.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
4732 Readline Killing Commands
4733 -------------------------
4735 "Killing" text means to delete the text from the line, but to save
4736 it away for later use, usually by "yanking" (re-inserting) it back into
4737 the line. If the description for a command says that it `kills' text,
4738 then you can be sure that you can get the text back in a different (or
4739 the same) place later.
4741 When you use a kill command, the text is saved in a "kill-ring".
4742 Any number of consecutive kills save all of the killed text together, so
4743 that when you yank it back, you get it all. The kill ring is not line
4744 specific; the text that you killed on a previously typed line is
4745 available to be yanked back later, when you are typing another line.
4747 Here is the list of commands for killing text.
4750 Kill the text from the current cursor position to the end of the
4754 Kill from the cursor to the end of the current word, or if between
4755 words, to the end of the next word.
4758 Kill from the cursor the start of the previous word, or if between
4759 words, to the start of the previous word.
4762 Kill from the cursor to the previous whitespace. This is
4763 different than M-DEL because the word boundaries differ.
4765 And, here is how to "yank" the text back into the line. Yanking
4766 means to copy the most-recently-killed text from the kill buffer.
4769 Yank the most recently killed text back into the buffer at the
4773 Rotate the kill-ring, and yank the new top. You can only do this
4774 if the prior command is C-y or M-y.
4777 File: bashref.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
4782 You can pass numeric arguments to Readline commands. Sometimes the
4783 argument acts as a repeat count, other times it is the sign of the
4784 argument that is significant. If you pass a negative argument to a
4785 command which normally acts in a forward direction, that command will
4786 act in a backward direction. For example, to kill text back to the
4787 start of the line, you might type `M-- C-k'.
4789 The general way to pass numeric arguments to a command is to type
4790 meta digits before the command. If the first `digit' you type is a
4791 minus sign (-), then the sign of the argument will be negative. Once
4792 you have typed one meta digit to get the argument started, you can type
4793 the remainder of the digits, and then the command. For example, to give
4794 the C-d command an argument of 10, you could type `M-1 0 C-d'.
4797 File: bashref.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
4799 Searching for Commands in the History
4800 -------------------------------------
4802 Readline provides commands for searching through the command history
4803 (*note Bash History Facilities::.) for lines containing a specified
4804 string. There are two search modes: INCREMENTAL and NON-INCREMENTAL.
4806 Incremental searches begin before the user has finished typing the
4807 search string. As each character of the search string is typed,
4808 readline displays the next entry from the history matching the string
4809 typed so far. An incremental search requires only as many characters
4810 as needed to find the desired history entry. The Escape character is
4811 used to terminate an incremental search. Control-J will also terminate
4812 the search. Control-G will abort an incremental search and restore the
4813 original line. When the search is terminated, the history entry
4814 containing the search string becomes the current line. To find other
4815 matching entries in the history list, type Control-S or Control-R as
4816 appropriate. This will search backward or forward in the history for
4817 the next entry matching the search string typed so far. Any other key
4818 sequence bound to a readline command will terminate the search and
4819 execute that command. For instance, a `newline' will terminate the
4820 search and accept the line, thereby executing the command from the
4823 Non-incremental searches read the entire search string before
4824 starting to search for matching history lines. The search string may be
4825 typed by the user or part of the contents of the current line.
4828 File: bashref.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
4833 Although the Readline library comes with a set of `emacs'-like
4834 keybindings installed by default, it is possible that you would like to
4835 use a different set of keybindings. You can customize programs that
4836 use Readline by putting commands in an "inputrc" file in your home
4837 directory. The name of this file is taken from the value of the shell
4838 variable `INPUTRC'. If that variable is unset, the default is
4841 When a program which uses the Readline library starts up, the init
4842 file is read, and the key bindings are set.
4844 In addition, the `C-x C-r' command re-reads this init file, thus
4845 incorporating any changes that you might have made to it.
4849 * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
4851 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
4853 * Sample Init File:: An example inputrc file.
4856 File: bashref.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File
4858 Readline Init File Syntax
4859 -------------------------
4861 There are only a few basic constructs allowed in the Readline init
4862 file. Blank lines are ignored. Lines beginning with a `#' are
4863 comments. Lines beginning with a `$' indicate conditional constructs
4864 (*note Conditional Init Constructs::.). Other lines denote variable
4865 settings and key bindings.
4868 You can change the state of a few variables in Readline by using
4869 the `set' command within the init file. Here is how you would
4870 specify that you wish to use `vi' line editing commands:
4874 Right now, there are only a few variables which can be set; so
4875 few, in fact, that we just list them here:
4878 Controls what happens when Readline wants to ring the
4879 terminal bell. If set to `none', Readline never rings the
4880 bell. If set to `visible', Readline uses a visible bell if
4881 one is available. If set to `audible' (the default),
4882 Readline attempts to ring the terminal's bell.
4885 The string to insert at the beginning of the line when the
4886 `insert-comment' command is executed. The default value is
4889 `completion-query-items'
4890 The number of possible completions that determines when the
4891 user is asked whether he wants to see the list of
4892 possibilities. If the number of possible completions is
4893 greater than this value, Readline will ask the user whether
4894 or not he wishes to view them; otherwise, they are simply
4895 listed. The default limit is `100'.
4898 If set to `on', Readline will convert characters with the
4899 eigth bit set to an ASCII key sequence by stripping the eigth
4900 bit and prepending an ESC character, converting them to a
4901 meta-prefixed key sequence. The default value is `on'.
4903 `disable-completion'
4904 If set to `On', readline will inhibit word completion.
4905 Completion characters will be inserted into the line as if
4906 they had been mapped to `self-insert'. The default is `off'.
4909 The `editing-mode' variable controls which editing mode you
4910 are using. By default, Readline starts up in Emacs editing
4911 mode, where the keystrokes are most similar to Emacs. This
4912 variable can be set to either `emacs' or `vi'.
4915 When set to `on', readline will try to enable the application
4916 keypad when it is called. Some systems need this to enable
4917 the arrow keys. The default is `off'.
4920 If set to `on', tilde expansion is performed when Readline
4921 attempts word completion. The default is `off'.
4923 `horizontal-scroll-mode'
4924 This variable can be set to either `on' or `off'. Setting it
4925 to `on' means that the text of the lines that you edit will
4926 scroll horizontally on a single screen line when they are
4927 longer than the width of the screen, instead of wrapping onto
4928 a new screen line. By default, this variable is set to `off'.
4931 Sets Readline's idea of the current keymap for key binding
4932 commands. Acceptable `keymap' names are `emacs',
4933 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
4934 `vi-command', and `vi-insert'. `vi' is equivalent to
4935 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
4936 default value is `emacs'. The value of the `editing-mode'
4937 variable also affects the default keymap.
4940 If set to `on', completed directory names have a slash
4941 appended. The default is `on'.
4943 `mark-modified-lines'
4944 This variable, when set to `on', says to display an asterisk
4945 (`*') at the start of history lines which have been modified.
4946 This variable is `off' by default.
4949 If set to `on', Readline will enable eight-bit input (it will
4950 not strip the eighth bit from the characters it reads),
4951 regardless of what the terminal claims it can support. The
4952 default value is `off'. The name `meta-flag' is a synonym
4956 If set to `on', Readline will display characters with the
4957 eighth bit set directly rather than as a meta-prefixed escape
4958 sequence. The default is `off'.
4960 `show-all-if-ambiguous'
4961 This alters the default behavior of the completion functions.
4962 If set to `on', words which have more than one possible
4963 completion cause the matches to be listed immediately instead
4964 of ringing the bell. The default value is `off'.
4967 If set to `on', a character denoting a file's type is
4968 appended to the filename when listing possible completions.
4969 The default is `off'.
4972 The syntax for controlling key bindings in the init file is
4973 simple. First you have to know the name of the command that you
4974 want to change. The following pages contain tables of the command
4975 name, the default keybinding, and a short description of what the
4978 Once you know the name of the command, simply place the name of
4979 the key you wish to bind the command to, a colon, and then the
4980 name of the command on a line in the init file. The name of the
4981 key can be expressed in different ways, depending on which is most
4982 comfortable for you.
4984 KEYNAME: FUNCTION-NAME or MACRO
4985 KEYNAME is the name of a key spelled out in English. For
4987 Control-u: universal-argument
4988 Meta-Rubout: backward-kill-word
4989 Control-o: "> output"
4991 In the above example, `C-u' is bound to the function
4992 `universal-argument', and `C-o' is bound to run the macro
4993 expressed on the right hand side (that is, to insert the text
4994 `> output' into the line).
4996 "KEYSEQ": FUNCTION-NAME or MACRO
4997 KEYSEQ differs from KEYNAME above in that strings denoting an
4998 entire key sequence can be specified, by placing the key
4999 sequence in double quotes. Some GNU Emacs style key escapes
5000 can be used, as in the following example, but the special
5001 character names are not recognized.
5003 "\C-u": universal-argument
5004 "\C-x\C-r": re-read-init-file
5005 "\e[11~": "Function Key 1"
5007 In the above example, `C-u' is bound to the function
5008 `universal-argument' (just as it was in the first example),
5009 `C-x C-r' is bound to the function `re-read-init-file', and
5010 `ESC [ 1 1 ~' is bound to insert the text `Function Key 1'.
5011 The following escape sequences are available when specifying
5032 When entering the text of a macro, single or double quotes
5033 should be used to indicate a macro definition. Unquoted text
5034 is assumed to be a function name. Backslash will quote any
5035 character in the macro text, including `"' and `''. For
5036 example, the following binding will make `C-x \' insert a
5037 single `\' into the line:
5041 File: bashref.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File
5043 Conditional Init Constructs
5044 ---------------------------
5046 Readline implements a facility similar in spirit to the conditional
5047 compilation features of the C preprocessor which allows key bindings
5048 and variable settings to be performed as the result of tests. There
5049 are three parser directives used.
5052 The `$if' construct allows bindings to be made based on the
5053 editing mode, the terminal being used, or the application using
5054 Readline. The text of the test extends to the end of the line; no
5055 characters are required to isolate it.
5058 The `mode=' form of the `$if' directive is used to test
5059 whether Readline is in `emacs' or `vi' mode. This may be
5060 used in conjunction with the `set keymap' command, for
5061 instance, to set bindings in the `emacs-standard' and
5062 `emacs-ctlx' keymaps only if Readline is starting out in
5066 The `term=' form may be used to include terminal-specific key
5067 bindings, perhaps to bind the key sequences output by the
5068 terminal's function keys. The word on the right side of the
5069 `=' is tested against the full name of the terminal and the
5070 portion of the terminal name before the first `-'. This
5071 allows `sun' to match both `sun' and `sun-cmd', for instance.
5074 The APPLICATION construct is used to include
5075 application-specific settings. Each program using the
5076 Readline library sets the APPLICATION NAME, and you can test
5077 for it. This could be used to bind key sequences to
5078 functions useful for a specific program. For instance, the
5079 following command adds a key sequence that quotes the current
5080 or previous word in Bash:
5082 # Quote the current or previous word
5083 "\C-xq": "\eb\"\ef\""
5087 This command, as you saw in the previous example, terminates an
5091 Commands in this branch of the `$if' directive are executed if the
5095 File: bashref.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File
5100 Here is an example of an inputrc file. This illustrates key
5101 binding, variable assignment, and conditional syntax.
5104 # This file controls the behaviour of line input editing for
5105 # programs that use the Gnu Readline library. Existing programs
5106 # include FTP, Bash, and Gdb.
5108 # You can re-read the inputrc file with C-x C-r.
5109 # Lines beginning with '#' are comments.
5111 # Set various bindings for emacs mode.
5113 set editing-mode emacs
5117 Meta-Control-h: backward-kill-word Text after the function name is ignored
5120 # Arrow keys in keypad mode
5122 #"\M-OD": backward-char
5123 #"\M-OC": forward-char
5124 #"\M-OA": previous-history
5125 #"\M-OB": next-history
5127 # Arrow keys in ANSI mode
5129 "\M-[D": backward-char
5130 "\M-[C": forward-char
5131 "\M-[A": previous-history
5132 "\M-[B": next-history
5134 # Arrow keys in 8 bit keypad mode
5136 #"\M-\C-OD": backward-char
5137 #"\M-\C-OC": forward-char
5138 #"\M-\C-OA": previous-history
5139 #"\M-\C-OB": next-history
5141 # Arrow keys in 8 bit ANSI mode
5143 #"\M-\C-[D": backward-char
5144 #"\M-\C-[C": forward-char
5145 #"\M-\C-[A": previous-history
5146 #"\M-\C-[B": next-history
5152 # An old-style binding. This happens to be the default.
5155 # Macros that are convenient for shell interaction
5158 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
5159 # prepare to type a quoted word -- insert open and close double quotes
5160 # and move to just after the open quote
5161 "\C-x\"": "\"\"\C-b"
5162 # insert a backslash (testing backslash escapes in sequences and macros)
5164 # Quote the current or previous word
5165 "\C-xq": "\eb\"\ef\""
5166 # Add a binding to refresh the line, which is unbound
5167 "\C-xr": redraw-current-line
5168 # Edit variable on current line.
5169 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
5172 # use a visible bell if one is available
5173 set bell-style visible
5175 # don't strip characters to 7 bits when reading
5178 # allow iso-latin1 characters to be inserted rather than converted to
5179 # prefix-meta sequences
5180 set convert-meta off
5182 # display characters with the eighth bit set directly rather than
5183 # as meta-prefixed characters
5186 # if there are more than 150 possible completions for a word, ask the
5187 # user if he wants to see all of them
5188 set completion-query-items 150
5194 "\M-.": yank-last-arg
5198 File: bashref.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
5200 Bindable Readline Commands
5201 ==========================
5205 * Commands For Moving:: Moving about the line.
5206 * Commands For History:: Getting at previous lines.
5207 * Commands For Text:: Commands for changing text.
5208 * Commands For Killing:: Commands for killing and yanking.
5209 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
5210 * Commands For Completion:: Getting Readline to do the typing for you.
5211 * Keyboard Macros:: Saving and re-executing typed characters
5212 * Miscellaneous Commands:: Other miscellaneous commands.
5214 This section describes Readline commands that may be bound to key
5218 File: bashref.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
5223 `beginning-of-line (C-a)'
5224 Move to the start of the current line.
5227 Move to the end of the line.
5229 `forward-char (C-f)'
5230 Move forward a character.
5232 `backward-char (C-b)'
5233 Move back a character.
5235 `forward-word (M-f)'
5236 Move forward to the end of the next word. Words are composed of
5239 `backward-word (M-b)'
5240 Move back to the start of this, or the previous, word. Words are
5241 composed of letters and digits.
5243 `clear-screen (C-l)'
5244 Clear the screen and redraw the current line, leaving the current
5245 line at the top of the screen.
5247 `redraw-current-line ()'
5248 Refresh the current line. By default, this is unbound.
5251 File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
5253 Commands For Manipulating The History
5254 -------------------------------------
5256 `accept-line (Newline, Return)'
5257 Accept the line regardless of where the cursor is. If this line is
5258 non-empty, add it to the history list according to the setting of
5259 the `HISTCONTROL' variable. If this line was a history line, then
5260 restore the history line to its original state.
5262 `previous-history (C-p)'
5263 Move `up' through the history list.
5265 `next-history (C-n)'
5266 Move `down' through the history list.
5268 `beginning-of-history (M-<)'
5269 Move to the first line in the history.
5271 `end-of-history (M->)'
5272 Move to the end of the input history, i.e., the line you are
5275 `reverse-search-history (C-r)'
5276 Search backward starting at the current line and moving `up'
5277 through the history as necessary. This is an incremental search.
5279 `forward-search-history (C-s)'
5280 Search forward starting at the current line and moving `down'
5281 through the the history as necessary. This is an incremental
5284 `non-incremental-reverse-search-history (M-p)'
5285 Search backward starting at the current line and moving `up'
5286 through the history as necessary using a non-incremental search
5287 for a string supplied by the user.
5289 `non-incremental-forward-search-history (M-n)'
5290 Search forward starting at the current line and moving `down'
5291 through the the history as necessary using a non-incremental search
5292 for a string supplied by the user.
5294 `history-search-forward ()'
5295 Search forward through the history for the string of characters
5296 between the start of the current line and the current cursor
5297 position (the `point'). This is a non-incremental search. By
5298 default, this command is unbound.
5300 `history-search-backward ()'
5301 Search backward through the history for the string of characters
5302 between the start of the current line and the point. This is a
5303 non-incremental search. By default, this command is unbound.
5305 `yank-nth-arg (M-C-y)'
5306 Insert the first argument to the previous command (usually the
5307 second word on the previous line). With an argument N, insert the
5308 Nth word from the previous command (the words in the previous
5309 command begin with word 0). A negative argument inserts the Nth
5310 word from the end of the previous command.
5312 `yank-last-arg (M-., M-_)'
5313 Insert last argument to the previous command (the last word of the
5314 previous history entry). With an argument, behave exactly like
5318 File: bashref.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
5320 Commands For Changing Text
5321 --------------------------
5324 Delete the character under the cursor. If the cursor is at the
5325 beginning of the line, there are no characters in the line, and
5326 the last character typed was not `C-d', then return `EOF'.
5328 `backward-delete-char (Rubout)'
5329 Delete the character behind the cursor. A numeric arg says to kill
5330 the characters instead of deleting them.
5332 `quoted-insert (C-q, C-v)'
5333 Add the next character that you type to the line verbatim. This is
5334 how to insert key sequences like C-q, for example.
5336 `tab-insert (M-TAB)'
5337 Insert a tab character.
5339 `self-insert (a, b, A, 1, !, ...)'
5342 `transpose-chars (C-t)'
5343 Drag the character before the cursor forward over the character at
5344 the cursor, moving the cursor forward as well. If the insertion
5345 point is at the end of the line, then this transposes the last two
5346 characters of the line. Negative argumentss don't work.
5348 `transpose-words (M-t)'
5349 Drag the word behind the cursor past the word in front of the
5350 cursor moving the cursor over that word as well.
5353 Uppercase the current (or following) word. With a negative
5354 argument, do the previous word, but do not move the cursor.
5356 `downcase-word (M-l)'
5357 Lowercase the current (or following) word. With a negative
5358 argument, do the previous word, but do not move the cursor.
5360 `capitalize-word (M-c)'
5361 Capitalize the current (or following) word. With a negative
5362 argument, do the previous word, but do not move the cursor.
5365 File: bashref.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
5371 Kill the text from the current cursor position to the end of the
5374 `backward-kill-line (C-x Rubout)'
5375 Kill backward to the beginning of the line.
5377 `unix-line-discard (C-u)'
5378 Kill backward from the cursor to the beginning of the current line.
5379 Save the killed text on the kill-ring.
5381 `kill-whole-line ()'
5382 Kill all characters on the current line, no matter where the
5383 cursor is. By default, this is unbound.
5386 Kill from the cursor to the end of the current word, or if between
5387 words, to the end of the next word. Word boundaries are the same
5390 `backward-kill-word (M-DEL)'
5391 Kill the word behind the cursor. Word boundaries are the same as
5394 `unix-word-rubout (C-w)'
5395 Kill the word behind the cursor, using white space as a word
5396 boundary. The killed text is saved on the kill-ring.
5398 `delete-horizontal-space ()'
5399 Delete all spaces and tabs around point. By default, this is
5403 Kill the text between the point and the *mark* (saved cursor
5404 position. This text is referred to as the REGION. By default,
5405 this command is unbound.
5407 `copy-region-as-kill ()'
5408 Copy the text in the region to the kill buffer, so you can yank it
5409 right away. By default, this command is unbound.
5411 `copy-backward-word ()'
5412 Copy the word before point to the kill buffer. By default, this
5415 `copy-forward-word ()'
5416 Copy the word following point to the kill buffer. By default,
5417 this command is unbound.
5420 Yank the top of the kill ring into the buffer at the current
5424 Rotate the kill-ring, and yank the new top. You can only do this
5425 if the prior command is yank or yank-pop.
5428 File: bashref.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
5430 Specifying Numeric Arguments
5431 ----------------------------
5433 `digit-argument (M-0, M-1, ... M--)'
5434 Add this digit to the argument already accumulating, or start a new
5435 argument. M- starts a negative argument.
5437 `universal-argument ()'
5438 This is another way to specify an argument. If this command is
5439 followed by one or more digits, optionally with a leading minus
5440 sign, those digits define the argument. If the command is
5441 followed by digits, executing `universal-argument' again ends the
5442 numeric argument, but is otherwise ignored. As a special case, if
5443 this command is immediately followed by a character that is
5444 neither a digit or minus sign, the argument count for the next
5445 command is multiplied by four. The argument count is initially
5446 one, so executing this function the first time makes the argument
5447 count four, a second time makes the argument count sixteen, and so
5448 on. By default, this is not bound to a key.
5451 File: bashref.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
5453 Letting Readline Type For You
5454 -----------------------------
5457 Attempt to do completion on the text before the cursor. This is
5458 application-specific. Generally, if you are typing a filename
5459 argument, you can do filename completion; if you are typing a
5460 command, you can do command completion, if you are typing in a
5461 symbol to GDB, you can do symbol name completion, if you are
5462 typing in a variable to Bash, you can do variable name completion,
5463 and so on. Bash attempts completion treating the text as a
5464 variable (if the text begins with `$'), username (if the text
5465 begins with `~'), hostname (if the text begins with `@'), or
5466 command (including aliases and functions) in turn. If none of
5467 these produces a match, filename completion is attempted.
5469 `possible-completions (M-?)'
5470 List the possible completions of the text before the cursor.
5472 `insert-completions (M-*)'
5473 Insert all completions of the text before point that would have
5474 been generated by `possible-completions'.
5476 `complete-filename (M-/)'
5477 Attempt filename completion on the text before point.
5479 `possible-filename-completions (C-x /)'
5480 List the possible completions of the text before point, treating
5483 `complete-username (M-~)'
5484 Attempt completion on the text before point, treating it as a
5487 `possible-username-completions (C-x ~)'
5488 List the possible completions of the text before point, treating
5491 `complete-variable (M-$)'
5492 Attempt completion on the text before point, treating it as a
5495 `possible-variable-completions (C-x $)'
5496 List the possible completions of the text before point, treating
5497 it as a shell variable.
5499 `complete-hostname (M-@)'
5500 Attempt completion on the text before point, treating it as a
5503 `possible-hostname-completions (C-x @)'
5504 List the possible completions of the text before point, treating
5507 `complete-command (M-!)'
5508 Attempt completion on the text before point, treating it as a
5509 command name. Command completion attempts to match the text
5510 against aliases, reserved words, shell functions, builtins, and
5511 finally executable filenames, in that order.
5513 `possible-command-completions (C-x !)'
5514 List the possible completions of the text before point, treating
5515 it as a command name.
5517 `dynamic-complete-history (M-TAB)'
5518 Attempt completion on the text before point, comparing the text
5519 against lines from the history list for possible completion
5522 `complete-into-braces (M-{)'
5523 Perform filename completion and return the list of possible
5524 completions enclosed within braces so the list is available to the
5525 shell (*note Brace Expansion::.).
5528 File: bashref.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
5533 `start-kbd-macro (C-x ()'
5534 Begin saving the characters typed into the current keyboard macro.
5536 `end-kbd-macro (C-x ))'
5537 Stop saving the characters typed into the current keyboard macro
5538 and save the definition.
5540 `call-last-kbd-macro (C-x e)'
5541 Re-execute the last keyboard macro defined, by making the
5542 characters in the macro appear as if typed at the keyboard.
5545 File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
5547 Some Miscellaneous Commands
5548 ---------------------------
5550 `re-read-init-file (C-x C-r)'
5551 Read in the contents of the inputrc file, and incorporate any
5552 bindings or variable assignments found there.
5555 Abort the current editing command and ring the terminal's bell
5556 (subject to the setting of `bell-style').
5558 `do-uppercase-version (M-a, M-b, M-X, ...)'
5559 If the metafied character X is lowercase, run the command that is
5560 bound to the corresponding uppercase character.
5563 Make the next character that you type be metafied. This is for
5564 people without a meta key. Typing `ESC f' is equivalent to typing
5567 `undo (C-_, C-x C-u)'
5568 Incremental undo, separately remembered for each line.
5571 Undo all changes made to this line. This is like typing the `undo'
5572 command enough times to get back to the beginning.
5574 `tilde-expand (M-~)'
5575 Perform tilde expansion on the current word.
5578 Set the mark to the current point. If a numeric argument is
5579 supplied, the mark is set to that position.
5581 `exchange-point-and-mark (C-x C-x)'
5582 Swap the point with the mark. The current cursor position is set
5583 to the saved position, and the old cursor position is saved as the
5586 `character-search (C-])'
5587 A character is read and point is moved to the next occurrence of
5588 that character. A negative count searches for previous
5591 `character-search-backward (M-C-])'
5592 A character is read and point is moved to the previous occurrence
5593 of that character. A negative count searches for subsequent
5596 `insert-comment (M-#)'
5597 The value of the `comment-begin' variable is inserted at the
5598 beginning of the current line, and the line is accepted as if a
5599 newline had been typed. This makes the current line a shell
5603 Print all of the functions and their key bindings to the readline
5604 output stream. If a numeric argument is supplied, the output is
5605 formatted in such a way that it can be made part of an INPUTRC
5606 file. This command is unbound by default.
5609 Print all of the settable variables and their values to the
5610 readline output stream. If a numeric argument is supplied, the
5611 output is formatted in such a way that it can be made part of an
5612 INPUTRC file. This command is unbound by default.
5615 Print all of the readline key sequences bound to macros and the
5616 strings they ouput. If a numeric argument is supplied, the output
5617 is formatted in such a way that it can be made part of an INPUTRC
5618 file. This command is unbound by default.
5620 `glob-expand-word (C-x *)'
5621 The word before point is treated as a pattern for pathname
5622 expansion, and the list of matching file names is inserted,
5625 `glob-list-expansions (C-x g)'
5626 The list of expansions that would have been generated by
5627 `glob-expand-word' is inserted into the line, replacing the word
5630 `display-shell-version (C-x C-v)'
5631 Display version information about the current instance of Bash.
5633 `shell-expand-line (M-C-e)'
5634 Expand the line the way the shell does when it reads it. This
5635 performs alias and history expansion as well as all of the shell
5638 `history-expand-line (M-^)'
5639 Perform history expansion on the current line.
5642 Perform alias expansion on the current line (*note Aliases::.).
5644 `history-and-alias-expand-line'
5645 Perform history and alias expansion on the current line.
5647 `insert-last-argument (M-., M-_)'
5648 A synonym for `yank-last-arg'.
5650 `operate-and-get-next (C-o)'
5651 Accept the current line for execution and fetch the next line
5652 relative to the current line from the history for editing. Any
5653 argument is ignored.
5655 `emacs-editing-mode (C-e)'
5656 When in `vi' editing mode, this causes a switch back to `emacs'
5657 editing mode, as if the command `set -o emacs' had been executed.
5660 File: bashref.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
5665 While the Readline library does not have a full set of `vi' editing
5666 functions, it does contain enough to allow simple editing of the line.
5667 The Readline `vi' mode behaves as specified in the POSIX 1003.2
5670 In order to switch interactively between `emacs' and `vi' editing
5671 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
5672 Builtin::.). The Readline default is `emacs' mode.
5674 When you enter a line in `vi' mode, you are already placed in
5675 `insertion' mode, as if you had typed an `i'. Pressing ESC switches
5676 you into `command' mode, where you can edit the text of the line with
5677 the standard `vi' movement keys, move to previous history lines with
5678 `k' and subsequent lines with `j', and so forth.
5681 File: bashref.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Command Line Editing, Up: Top
5686 This chapter provides basic instructions for installing Bash on the
5687 various supported platforms. The distribution supports nearly every
5688 version of Unix (and, someday, GNU). Other independent ports exist for
5689 OS/2, Windows 95, and Windows NT.
5693 * Basic Installation:: Installation instructions.
5695 * Compilers and Options:: How to set special options for various
5698 * Compiling For Multiple Architectures:: How to compile Bash for more
5699 than one kind of system from
5700 the same source tree.
5702 * Installation Names:: How to set the various paths used by the installation.
5704 * Specifying the System Type:: How to configure Bash for a particular system.
5706 * Sharing Defaults:: How to share default configuration values among GNU
5709 * Operation Controls:: Options recognized by the configuration program.
5711 * Optional Features:: How to enable and disable optional features when
5715 File: bashref.info, Node: Basic Installation, Next: Compilers and Options, Up: Installing Bash
5720 These are installation instructions for Bash.
5722 The `configure' shell script attempts to guess correct values for
5723 various system-dependent variables used during compilation. It uses
5724 those values to create a `Makefile' in each directory of the package
5725 (the top directory, the `builtins' and `doc' directories, and the each
5726 directory under `lib'). It also creates a `config.h' file containing
5727 system-dependent definitions. Finally, it creates a shell script named
5728 `config.status' that you can run in the future to recreate the current
5729 configuration, a file `config.cache' that saves the results of its
5730 tests to speed up reconfiguring, and a file `config.log' containing
5731 compiler output (useful mainly for debugging `configure'). If at some
5732 point `config.cache' contains results you don't want to keep, you may
5735 If you need to do unusual things to compile the package, please try
5736 to figure out how `configure' could check whether or not to do them,
5737 and mail diffs or instructions to `bash-maintainers@prep.ai.mit.edu' so
5738 they can be considered for the next release.
5740 The file `configure.in' is used to create `configure' by a program
5741 called Autoconf. You only need `configure.in' if you want to change it
5742 or regenerate `configure' using a newer version of Autoconf. If you do
5743 this, make sure you are using Autoconf version 2.10 or newer.
5745 If you need to change `configure.in' or regenerate `configure', you
5746 will need to create two files: `_distribution' and `_patchlevel'.
5747 `_distribution' should contain the major and minor version numbers of
5748 the Bash distribution, for example `2.01'. `_patchlevel' should
5749 contain the patch level of the Bash distribution, `0' for example. The
5750 script `support/mkconffiles' has been provided to automate the creation
5753 The simplest way to compile Bash is:
5755 1. `cd' to the directory containing the source code and type
5756 `./configure' to configure Bash for your system. If you're using
5757 `csh' on an old version of System V, you might need to type `sh
5758 ./configure' instead to prevent `csh' from trying to execute
5761 Running `configure' takes awhile. While running, it prints some
5762 messages telling which features it is checking for.
5764 2. Type `make' to compile Bash and build the `bashbug' bug reporting
5767 3. Optionally, type `make tests' to run the Bash test suite.
5769 4. Type `make install' to install `bash' and `bashbug'. This will
5770 also install the manual pages and Info file.
5773 You can remove the program binaries and object files from the source
5774 code directory by typing `make clean'. To also remove the files that
5775 `configure' created (so you can compile Bash for a different kind of
5776 computer), type `make distclean'.
5779 File: bashref.info, Node: Compilers and Options, Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
5781 Compilers and Options
5782 =====================
5784 Some systems require unusual options for compilation or linking that
5785 the `configure' script does not know about. You can give `configure'
5786 initial values for variables by setting them in the environment. Using
5787 a Bourne-compatible shell, you can do that on the command line like
5790 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
5792 On systems that have the `env' program, you can do it like this:
5794 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
5796 The configuration process uses GCC to build Bash if it is available.
5799 File: bashref.info, Node: Compiling For Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
5801 Compiling For Multiple Architectures
5802 ====================================
5804 You can compile Bash for more than one kind of computer at the same
5805 time, by placing the object files for each architecture in their own
5806 directory. To do this, you must use a version of `make' that supports
5807 the `VPATH' variable, such as GNU `make'. `cd' to the directory where
5808 you want the object files and executables to go and run the `configure'
5809 script from the source directory. You may need to supply the
5810 `--srcdir=PATH' argument to tell `configure' where the source files
5811 are. `configure' automatically checks for the source code in the
5812 directory that `configure' is in and in `..'.
5814 If you have to use a `make' that does not supports the `VPATH'
5815 variable, you can compile Bash for one architecture at a time in the
5816 source code directory. After you have installed Bash for one
5817 architecture, use `make distclean' before reconfiguring for another
5820 Alternatively, if your system supports symbolic links, you can use
5821 the `support/mkclone' script to create a build tree which has symbolic
5822 links back to each file in the source directory. Here's an example
5823 that creates a build directory in the current directory from a source
5824 directory `/usr/gnu/src/bash-2.0':
5826 bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
5828 The `mkclone' script requires Bash, so you must have already built Bash
5829 for at least one architecture before you can create build directories
5830 for other architectures.
5833 File: bashref.info, Node: Installation Names, Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
5838 By default, `make install' will install into `/usr/local/bin',
5839 `/usr/local/man', etc. You can specify an installation prefix other
5840 than `/usr/local' by giving `configure' the option `--prefix=PATH'.
5842 You can specify separate installation prefixes for
5843 architecture-specific files and architecture-independent files. If you
5844 give `configure' the option `--exec-prefix=PATH', the package will use
5845 `PATH' as the prefix for installing programs and libraries.
5846 Documentation and other data files will still use the regular prefix.
5849 File: bashref.info, Node: Specifying the System Type, Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
5851 Specifying the System Type
5852 ==========================
5854 There may be some features `configure' can not figure out
5855 automatically, but needs to determine by the type of host the package
5856 will run on. Usually `configure' can figure that out, but if it prints
5857 a message saying it can not guess the host type, give it the
5858 `--host=TYPE' option. `TYPE' can either be a short name for the system
5859 type, such as `sun4', or a canonical name with three fields:
5860 `CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2').
5862 See the file `support/config.sub' for the possible values of each field.
5865 File: bashref.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
5870 If you want to set default values for `configure' scripts to share,
5871 you can create a site shell script called `config.site' that gives
5872 default values for variables like `CC', `cache_file', and `prefix'.
5873 `configure' looks for `PREFIX/share/config.site' if it exists, then
5874 `PREFIX/etc/config.site' if it exists. Or, you can set the
5875 `CONFIG_SITE' environment variable to the location of the site script.
5876 A warning: the Bash `configure' looks for a site script, but not all
5877 `configure' scripts do.
5880 File: bashref.info, Node: Operation Controls, Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
5885 `configure' recognizes the following options to control how it
5889 Use and save the results of the tests in FILE instead of
5890 `./config.cache'. Set FILE to `/dev/null' to disable caching, for
5891 debugging `configure'.
5894 Print a summary of the options to `configure', and exit.
5899 Do not print messages saying which checks are being made.
5902 Look for the Bash source code in directory DIR. Usually
5903 `configure' can determine that directory automatically.
5906 Print the version of Autoconf used to generate the `configure'
5909 `configure' also accepts some other, not widely used, boilerplate
5913 File: bashref.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash
5918 The Bash `configure' has a number of `--enable-FEATURE' options,
5919 where FEATURE indicates an optional part of the package. There are
5920 also several `--with-PACKAGE' options, where PACKAGE is something like
5921 `gnu-malloc' or `purify' (for the Purify memory allocation checker). To
5922 turn off the default use of a package, use `--without-PACKAGE'. To
5923 configure Bash without a feature that is enabled by default, use
5924 `--disable-FEATURE'.
5926 Here is a complete list of the `--enable-' and `--with-' options
5927 that the Bash `configure' recognizes.
5930 Define if you are using the Andrew File System from Transarc.
5933 Use the curses library instead of the termcap library. This should
5934 be supplied if your system has an inadequate or incomplete termcap
5937 `--with-glibc-malloc'
5938 Use the GNU libc version of `malloc' in `lib/malloc/gmalloc.c'.
5939 This is somewhat slower than the default `malloc', but wastes
5940 considerably less space.
5943 Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
5944 not the same `malloc' that appears in GNU libc, but an older
5945 version derived from the 4.2 BSD `malloc'. This `malloc' is very
5946 fast, but wastes a lot of space. This option is enabled by
5947 default. The `NOTES' file contains a list of systems for which
5948 this should be turned off, and `configure' disables this option
5949 automatically for a number of systems.
5952 Define this to use the Purify memory allocation checker from Pure
5955 `--enable-minimal-config'
5956 This produces a shell with minimal features, close to the
5957 historical Bourne shell.
5959 The `minimal-config' option can be used to disable all of the following
5960 options, but it is processed first, so individual options may be
5961 enabled using `enable-FEATURE'.
5963 All of the following options except for `disabled-builtins' and
5964 `usg-echo-default' are enabled by default, unless the operating system
5965 does not provide the necessary support.
5968 Allow alias expansion and include the `alias' and `unalias'
5971 `--enable-array-variables'
5972 Include support for one-dimensional array shell variables.
5974 `--enable-bang-history'
5975 Include support for `csh'-like history substitution.
5977 `--enable-brace-expansion'
5978 Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
5980 `--enable-command-timing'
5981 Include support for recognizing `time' as a reserved word and for
5982 displaying timing statistics for the pipeline following `time'.
5983 This allows pipelines as well as shell builtins and functions to
5986 `--enable-directory-stack'
5987 Include support for a `csh'-like directory stack and the `pushd',
5988 `popd', and `dirs' builtins.
5990 `--enable-disabled-builtins'
5991 Allow builtin commands to be invoked via `builtin xxx' even after
5992 `xxx' has been disabled using `enable -n xxx'. See *Note Bash
5993 Builtins::, for details of the `builtin' and `enable' builtin
5996 `--enable-dparen-arithmetic'
5997 Include support for the `ksh' `((...))' command.
5999 `--enable-help-builtin'
6000 Include the `help' builtin, which displays help on shell builtins
6004 Include command history and the `fc' and `history' builtin
6007 `--enable-job-control'
6008 This enables job control features, if the OS supports them.
6010 `--enable-process-substitution'
6011 This enables process substitution (*note Process Substitution::.)
6012 if the OS provides the necessary support.
6014 `--enable-prompt-string-decoding'
6015 Turn on the interpretation of a number of backslash-escaped
6016 characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
6020 Include support for command-line editing and history with the Bash
6021 version of the Readline library.
6023 `--enable-restricted'
6024 Include support for a "restricted shell". If this is enabled,
6025 Bash, when called as `rbash', enters a restricted mode. See *Note
6026 The Restricted Shell::, for a description of restricted mode.
6029 Include the `ksh' `select' builtin, which allows the generation of
6032 `--enable-usg-echo-default'
6033 Make the `echo' builtin expand backslash-escaped characters by
6034 default, without requiring the `-e' option. This makes the Bash
6035 `echo' behave more like the System V version.
6037 The file `config.h.top' contains C Preprocessor `#define' statements
6038 for options which are not settable from `configure'. Some of these are
6039 not meant to be changed; beware of the consequences if you do. Read
6040 the comments associated with each definition for more information about
6044 File: bashref.info, Node: Reporting Bugs, Next: Builtin Index, Prev: Installing Bash, Up: Top
6049 Please report all bugs you find in Bash. But first, you should make
6050 sure that it really is a bug, and that it appears in the latest version
6051 of Bash that you have.
6053 Once you have determined that a bug actually exists, use the
6054 `bashbug' command to submit a bug report. If you have a fix, you are
6055 encouraged to mail that as well! Suggestions and `philosophical' bug
6056 reports may be mailed to `bug-bash@prep.ai.MIT.Edu' or posted to the
6057 Usenet newsgroup `gnu.bash.bug'.
6059 All bug reports should include:
6060 * The version number of Bash.
6062 * The hardware and operating system.
6064 * The compiler used to compile Bash.
6066 * A description of the bug behaviour.
6068 * A short script or `recipe' which exercises the bug and may be used
6071 `bashbug' inserts the first three items automatically into the template
6072 it provides for filing a bug report.
6074 Please send all reports concerning this manual to
6075 `chet@ins.CWRU.Edu'.
6078 File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Prev: Reporting Bugs, Up: Top
6080 Index of Shell Builtin Commands
6081 *******************************
6085 * .: Bourne Shell Builtins.
6086 * :: Bourne Shell Builtins.
6087 * [: Bourne Shell Builtins.
6088 * alias: Alias Builtins.
6089 * bg: Job Control Builtins.
6090 * bind: Bash Builtins.
6091 * break: Bourne Shell Builtins.
6092 * builtin: Bash Builtins.
6093 * cd: Bourne Shell Builtins.
6094 * command: Bash Builtins.
6095 * continue: Bourne Shell Builtins.
6096 * declare: Bash Builtins.
6097 * dirs: C Shell Builtins.
6098 * disown: Job Control Builtins.
6099 * echo: Bash Builtins.
6100 * enable: Bash Builtins.
6101 * eval: Bourne Shell Builtins.
6102 * exec: Bourne Shell Builtins.
6103 * exit: Bourne Shell Builtins.
6104 * export: Bourne Shell Builtins.
6105 * fc: Korn Shell Builtins.
6106 * fg: Job Control Builtins.
6107 * getopts: Bourne Shell Builtins.
6108 * hash: Bourne Shell Builtins.
6109 * help: Bash Builtins.
6110 * history: C Shell Builtins.
6111 * jobs: Job Control Builtins.
6112 * kill: Job Control Builtins.
6113 * let <1>: Arithmetic Builtins.
6114 * let: Korn Shell Builtins.
6115 * local: Bash Builtins.
6116 * logout <1>: Bash Builtins.
6117 * logout: C Shell Builtins.
6118 * popd: C Shell Builtins.
6119 * pushd: C Shell Builtins.
6120 * pwd: Bourne Shell Builtins.
6121 * read: Bash Builtins.
6122 * readonly: Bourne Shell Builtins.
6123 * return: Bourne Shell Builtins.
6124 * set: The Set Builtin.
6125 * shift: Bourne Shell Builtins.
6126 * shopt: Bash Builtins.
6127 * source: C Shell Builtins.
6128 * suspend: Job Control Builtins.
6129 * test: Bourne Shell Builtins.
6130 * times: Bourne Shell Builtins.
6131 * trap: Bourne Shell Builtins.
6132 * type: Bash Builtins.
6133 * typeset: Korn Shell Builtins.
6134 * ulimit: Bash Builtins.
6135 * umask: Bourne Shell Builtins.
6136 * unalias: Alias Builtins.
6137 * unset: Bourne Shell Builtins.
6138 * wait: Job Control Builtins.
6141 File: bashref.info, Node: Reserved Word Index, Next: Variable Index, Prev: Builtin Index, Up: Top
6143 Shell Reserved Words
6144 ********************
6149 * {: Command Grouping.
6150 * }: Command Grouping.
6151 * case: Conditional Constructs.
6152 * do: Looping Constructs.
6153 * done: Looping Constructs.
6154 * elif: Conditional Constructs.
6155 * else: Conditional Constructs.
6156 * esac: Conditional Constructs.
6157 * fi: Conditional Constructs.
6158 * for: Looping Constructs.
6159 * function: Shell Functions.
6160 * if: Conditional Constructs.
6161 * in: Conditional Constructs.
6162 * select: Korn Shell Constructs.
6163 * then: Conditional Constructs.
6165 * until: Looping Constructs.
6166 * while: Looping Constructs.
6169 File: bashref.info, Node: Variable Index, Next: Function Index, Prev: Reserved Word Index, Up: Top
6171 Parameter and Variable Index
6172 ****************************
6176 * !: Special Parameters.
6177 * #: Special Parameters.
6178 * $: Special Parameters.
6179 * *: Special Parameters.
6180 * -: Special Parameters.
6181 * 0: Special Parameters.
6182 * ?: Special Parameters.
6183 * @: Special Parameters.
6184 * _: Special Parameters.
6185 * auto_resume: Job Control Variables.
6186 * BASH: Bash Variables.
6187 * BASH_ENV: Bash Variables.
6188 * BASH_VERSINFO: Bash Variables.
6189 * BASH_VERSION: Bash Variables.
6190 * bell-style: Readline Init File Syntax.
6191 * CDPATH: Bourne Shell Variables.
6192 * comment-begin: Readline Init File Syntax.
6193 * completion-query-items: Readline Init File Syntax.
6194 * convert-meta: Readline Init File Syntax.
6195 * DIRSTACK: Bash Variables.
6196 * disable-completion: Readline Init File Syntax.
6197 * editing-mode: Readline Init File Syntax.
6198 * enable-keypad: Readline Init File Syntax.
6199 * EUID: Bash Variables.
6200 * expand-tilde: Readline Init File Syntax.
6201 * FCEDIT: Korn Shell Variables.
6202 * FIGNORE: Bash Variables.
6203 * GLOBIGNORE: Bash Variables.
6204 * GROUPS: Bash Variables.
6205 * histchars: Bash Variables.
6206 * HISTCMD: Bash Variables.
6207 * HISTCONTROL: Bash Variables.
6208 * HISTFILE: Bash Variables.
6209 * HISTFILESIZE: Bash Variables.
6210 * HISTIGNORE: Bash Variables.
6211 * HISTSIZE: Bash Variables.
6212 * HOME: Bourne Shell Variables.
6213 * horizontal-scroll-mode: Readline Init File Syntax.
6214 * HOSTFILE: Bash Variables.
6215 * HOSTNAME: Bash Variables.
6216 * HOSTTYPE: Bash Variables.
6217 * IFS: Bourne Shell Variables.
6218 * IGNOREEOF <1>: Bash Variables.
6219 * IGNOREEOF: C Shell Variables.
6220 * input-meta: Readline Init File Syntax.
6221 * INPUTRC: Bash Variables.
6222 * keymap: Readline Init File Syntax.
6223 * LANG: Bash Variables.
6224 * LC_ALL: Bash Variables.
6225 * LC_COLLATE: Bash Variables.
6226 * LC_MESSAGES: Bash Variables.
6227 * LINENO: Korn Shell Variables.
6228 * MACHTYPE: Bash Variables.
6229 * MAIL: Bourne Shell Variables.
6230 * MAILCHECK: Bash Variables.
6231 * MAILPATH: Bourne Shell Variables.
6232 * mark-modified-lines: Readline Init File Syntax.
6233 * meta-flag: Readline Init File Syntax.
6234 * OLDPWD: Korn Shell Variables.
6235 * OPTARG: Bourne Shell Variables.
6236 * OPTERR: Bash Variables.
6237 * OPTIND: Bourne Shell Variables.
6238 * OSTYPE: Bash Variables.
6239 * output-meta: Readline Init File Syntax.
6240 * PATH: Bourne Shell Variables.
6241 * PIPESTATUS: Bash Variables.
6242 * PPID: Bash Variables.
6243 * PROMPT_COMMAND: Bash Variables.
6244 * PS1: Bourne Shell Variables.
6245 * PS2: Bourne Shell Variables.
6246 * PS3: Korn Shell Variables.
6247 * PS4: Korn Shell Variables.
6248 * PWD: Korn Shell Variables.
6249 * RANDOM: Korn Shell Variables.
6250 * REPLY: Korn Shell Variables.
6251 * SECONDS: Korn Shell Variables.
6252 * SHELLOPTS: Bash Variables.
6253 * SHLVL: Bash Variables.
6254 * show-all-if-ambiguous: Readline Init File Syntax.
6255 * TIMEFORMAT: Bash Variables.
6256 * TMOUT: Korn Shell Variables.
6257 * UID: Bash Variables.
6258 * visible-stats: Readline Init File Syntax.
6261 File: bashref.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Top
6268 * abort (C-g): Miscellaneous Commands.
6269 * accept-line (Newline, Return): Commands For History.
6270 * backward-char (C-b): Commands For Moving.
6271 * backward-delete-char (Rubout): Commands For Text.
6272 * backward-kill-line (C-x Rubout): Commands For Killing.
6273 * backward-kill-word (M-DEL): Commands For Killing.
6274 * backward-word (M-b): Commands For Moving.
6275 * beginning-of-history (M-<): Commands For History.
6276 * beginning-of-line (C-a): Commands For Moving.
6277 * call-last-kbd-macro (C-x e): Keyboard Macros.
6278 * capitalize-word (M-c): Commands For Text.
6279 * character-search (C-]): Miscellaneous Commands.
6280 * character-search-backward (M-C-]): Miscellaneous Commands.
6281 * clear-screen (C-l): Commands For Moving.
6282 * complete (TAB): Commands For Completion.
6283 * copy-backward-word (): Commands For Killing.
6284 * copy-forward-word (): Commands For Killing.
6285 * copy-region-as-kill (): Commands For Killing.
6286 * delete-char (C-d): Commands For Text.
6287 * delete-horizontal-space (): Commands For Killing.
6288 * digit-argument (M-0, M-1, ... M-): Numeric Arguments.
6289 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
6290 * downcase-word (M-l): Commands For Text.
6291 * dump-functions (): Miscellaneous Commands.
6292 * dump-macros (): Miscellaneous Commands.
6293 * dump-variables (): Miscellaneous Commands.
6294 * end-kbd-macro (C-x )): Keyboard Macros.
6295 * end-of-history (M->): Commands For History.
6296 * end-of-line (C-e): Commands For Moving.
6297 * exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
6298 * forward-char (C-f): Commands For Moving.
6299 * forward-search-history (C-s): Commands For History.
6300 * forward-word (M-f): Commands For Moving.
6301 * history-search-backward (): Commands For History.
6302 * history-search-forward (): Commands For History.
6303 * insert-comment (M-#): Miscellaneous Commands.
6304 * insert-completions (M-*): Commands For Completion.
6305 * kill-line (C-k): Commands For Killing.
6306 * kill-region (): Commands For Killing.
6307 * kill-whole-line (): Commands For Killing.
6308 * kill-word (M-d): Commands For Killing.
6309 * next-history (C-n): Commands For History.
6310 * non-incremental-forward-search-history (M-n): Commands For History.
6311 * non-incremental-reverse-search-history (M-p): Commands For History.
6312 * possible-completions (M-?): Commands For Completion.
6313 * prefix-meta (ESC): Miscellaneous Commands.
6314 * previous-history (C-p): Commands For History.
6315 * quoted-insert (C-q, C-v): Commands For Text.
6316 * re-read-init-file (C-x C-r): Miscellaneous Commands.
6317 * redraw-current-line (): Commands For Moving.
6318 * reverse-search-history (C-r): Commands For History.
6319 * revert-line (M-r): Miscellaneous Commands.
6320 * self-insert (a, b, A, 1, !, ...): Commands For Text.
6321 * set-mark (C-@): Miscellaneous Commands.
6322 * start-kbd-macro (C-x (): Keyboard Macros.
6323 * tab-insert (M-TAB): Commands For Text.
6324 * tilde-expand (M-~): Miscellaneous Commands.
6325 * transpose-chars (C-t): Commands For Text.
6326 * transpose-words (M-t): Commands For Text.
6327 * undo (C-_, C-x C-u): Miscellaneous Commands.
6328 * universal-argument (): Numeric Arguments.
6329 * unix-line-discard (C-u): Commands For Killing.
6330 * unix-word-rubout (C-w): Commands For Killing.
6331 * upcase-word (M-u): Commands For Text.
6332 * yank (C-y): Commands For Killing.
6333 * yank-last-arg (M-., M-_): Commands For History.
6334 * yank-nth-arg (M-C-y): Commands For History.
6335 * yank-pop (M-y): Commands For Killing.
6338 File: bashref.info, Node: Concept Index, Prev: Function Index, Up: Top
6345 * alias expansion: Aliases.
6346 * arithmetic evaluation: Arithmetic Evaluation.
6347 * arithmetic expansion: Arithmetic Expansion.
6348 * arithmetic, shell: Shell Arithmetic.
6350 * background: Job Control Basics.
6351 * Bash configuration: Basic Installation.
6352 * Bash installation: Basic Installation.
6353 * Bourne shell: Basic Shell Features.
6354 * brace expansion: Brace Expansion.
6355 * builtin: Definitions.
6356 * command editing: Readline Bare Essentials.
6357 * command execution: Command Search and Execution.
6358 * command history: Bash History Facilities.
6359 * command search: Command Search and Execution.
6360 * command substitution: Command Substitution.
6361 * command timing: Pipelines.
6362 * commands, conditional: Conditional Constructs.
6363 * commands, grouping: Command Grouping.
6364 * commands, lists: Lists.
6365 * commands, looping: Looping Constructs.
6366 * commands, pipelines: Pipelines.
6367 * commands, simple: Simple Commands.
6368 * comments, shell: Comments.
6369 * configuration: Basic Installation.
6370 * control operator: Definitions.
6371 * editing command lines: Readline Bare Essentials.
6372 * environment: Environment.
6373 * evaluation, arithmetic: Arithmetic Evaluation.
6374 * event designators: Event Designators.
6375 * exit status <1>: Definitions.
6376 * exit status: Exit Status.
6377 * expansion: Shell Expansions.
6378 * expansion, arithmetic: Arithmetic Expansion.
6379 * expansion, brace: Brace Expansion.
6380 * expansion, filename: Filename Expansion.
6381 * expansion, parameter: Shell Parameter Expansion.
6382 * expansion, pathname: Filename Expansion.
6383 * expansion, tilde: Tilde Expansion.
6384 * expressions, arithmetic: Arithmetic Evaluation.
6385 * expressions, conditional: Bash Conditional Expressions.
6386 * field: Definitions.
6387 * filename: Definitions.
6388 * filename expansion: Filename Expansion.
6389 * foreground: Job Control Basics.
6390 * functions, shell: Shell Functions.
6391 * history events: Event Designators.
6392 * history expansion: History Interaction.
6393 * history list: Bash History Facilities.
6394 * History, how to use: Job Control Variables.
6395 * identifier: Definitions.
6396 * initialization file, readline: Readline Init File.
6397 * installation: Basic Installation.
6398 * interaction, readline: Readline Interaction.
6399 * interactive shell <1>: Is This Shell Interactive?.
6400 * interactive shell: Invoking Bash.
6402 * job control <1>: Definitions.
6403 * job control: Job Control Basics.
6404 * kill ring: Readline Killing Commands.
6405 * killing text: Readline Killing Commands.
6406 * localization: Locale Translation.
6407 * metacharacter: Definitions.
6408 * name: Definitions.
6409 * notation, readline: Readline Bare Essentials.
6410 * operator, shell: Definitions.
6411 * parameter expansion: Shell Parameter Expansion.
6412 * parameters: Shell Parameters.
6413 * parameters, positional: Positional Parameters.
6414 * parameters, special: Special Parameters.
6415 * pathname expansion: Filename Expansion.
6416 * pipeline: Pipelines.
6417 * POSIX: Definitions.
6418 * POSIX Mode: Bash POSIX Mode.
6419 * process group: Definitions.
6420 * process group ID: Definitions.
6421 * process substitution: Process Substitution.
6422 * prompting: Printing a Prompt.
6424 * quoting, ANSI: ANSI-C Quoting.
6425 * Readline, how to use: Modifiers.
6426 * redirection: Redirections.
6427 * reserved word: Definitions.
6428 * restricted shell: The Restricted Shell.
6429 * return status: Definitions.
6430 * shell function: Shell Functions.
6431 * shell script: Shell Scripts.
6432 * shell variable: Shell Parameters.
6433 * signal: Definitions.
6434 * signal handling: Signals.
6435 * special builtin: Definitions.
6436 * startup files: Bash Startup Files.
6437 * suspending jobs: Job Control Basics.
6438 * tilde expansion: Tilde Expansion.
6439 * token: Definitions.
6440 * variable, shell: Shell Parameters.
6441 * word: Definitions.
6442 * word splitting: Word Splitting.
6443 * yanking text: Readline Killing Commands.
6449 Node: Introduction
\7f3109
6450 Node: What is Bash?
\7f3334
6451 Node: What is a shell?
\7f4418
6452 Node: Definitions
\7f6299
6453 Node: Basic Shell Features
\7f8960
6454 Node: Shell Syntax
\7f10481
6455 Node: Shell Operation
\7f10771
6456 Node: Quoting
\7f12005
6457 Node: Escape Character
\7f13040
6458 Node: Single Quotes
\7f13471
6459 Node: Double Quotes
\7f13800
6460 Node: ANSI-C Quoting
\7f14496
6461 Node: Locale Translation
\7f15228
6462 Node: Comments
\7f15649
6463 Node: Simple Commands
\7f16173
6464 Node: Pipelines
\7f16762
6466 Node: Looping Constructs
\7f19108
6467 Node: Conditional Constructs
\7f20285
6468 Node: Command Grouping
\7f22352
6469 Node: Shell Functions
\7f23738
6470 Node: Shell Parameters
\7f25511
6471 Node: Positional Parameters
\7f26834
6472 Node: Special Parameters
\7f27528
6473 Node: Shell Expansions
\7f30094
6474 Node: Shell Parameter Expansion
\7f32098
6475 Node: Command Substitution
\7f38106
6476 Node: Process Substitution
\7f39106
6477 Node: Word Splitting
\7f40012
6478 Node: Filename Expansion
\7f41464
6479 Node: Quote Removal
\7f43830
6480 Node: Redirections
\7f44116
6481 Node: Executing Commands
\7f49857
6482 Node: Command Search and Execution
\7f50312
6483 Node: Environment
\7f52046
6484 Node: Exit Status
\7f53682
6485 Node: Signals
\7f54699
6486 Node: Shell Scripts
\7f55910
6487 Node: Bourne Shell Features
\7f57779
6488 Node: Bourne Shell Builtins
\7f58449
6489 Node: Bourne Shell Variables
\7f66803
6490 Node: Other Bourne Shell Features
\7f68340
6491 Node: Major Differences From The Bourne Shell
\7f69097
6492 Node: Csh Features
\7f79457
6493 Node: Brace Expansion
\7f80375
6494 Node: Tilde Expansion
\7f81930
6495 Node: C Shell Builtins
\7f82562
6496 Node: C Shell Variables
\7f87118
6497 Node: Korn Shell Features
\7f87526
6498 Node: Korn Shell Constructs
\7f88254
6499 Node: Korn Shell Builtins
\7f89969
6500 Node: Korn Shell Variables
\7f92127
6501 Node: Aliases
\7f93686
6502 Node: Alias Builtins
\7f96150
6503 Node: Bash Features
\7f96766
6504 Node: Invoking Bash
\7f97757
6505 Node: Bash Startup Files
\7f101622
6506 Node: Is This Shell Interactive?
\7f105197
6507 Node: Bash Builtins
\7f106180
6508 Node: The Set Builtin
\7f122035
6509 Node: Bash Conditional Expressions
\7f127410
6510 Node: Bash Variables
\7f132061
6511 Node: Shell Arithmetic
\7f142095
6512 Node: Arithmetic Evaluation
\7f142563
6513 Node: Arithmetic Expansion
\7f144593
6514 Node: Arithmetic Builtins
\7f145397
6515 Node: Arrays
\7f145868
6516 Node: Printing a Prompt
\7f148895
6517 Node: The Restricted Shell
\7f150493
6518 Node: Bash POSIX Mode
\7f151723
6519 Node: Job Control
\7f155407
6520 Node: Job Control Basics
\7f155872
6521 Node: Job Control Builtins
\7f160015
6522 Node: Job Control Variables
\7f162938
6523 Node: Using History Interactively
\7f164085
6524 Node: Bash History Facilities
\7f164674
6525 Node: History Interaction
\7f167072
6526 Node: Event Designators
\7f169634
6527 Node: Word Designators
\7f170557
6528 Node: Modifiers
\7f171806
6529 Node: Command Line Editing
\7f173123
6530 Node: Introduction and Notation
\7f173783
6531 Node: Readline Interaction
\7f174791
6532 Node: Readline Bare Essentials
\7f175979
6533 Node: Readline Movement Commands
\7f177508
6534 Node: Readline Killing Commands
\7f178398
6535 Node: Readline Arguments
\7f180100
6536 Node: Searching
\7f181073
6537 Node: Readline Init File
\7f182709
6538 Node: Readline Init File Syntax
\7f183765
6539 Node: Conditional Init Constructs
\7f191554
6540 Node: Sample Init File
\7f193835
6541 Node: Bindable Readline Commands
\7f196868
6542 Node: Commands For Moving
\7f197618
6543 Node: Commands For History
\7f198465
6544 Node: Commands For Text
\7f201138
6545 Node: Commands For Killing
\7f202880
6546 Node: Numeric Arguments
\7f204906
6547 Node: Commands For Completion
\7f206030
6548 Node: Keyboard Macros
\7f208992
6549 Node: Miscellaneous Commands
\7f209550
6550 Node: Readline vi Mode
\7f213766
6551 Node: Installing Bash
\7f214642
6552 Node: Basic Installation
\7f215711
6553 Node: Compilers and Options
\7f218636
6554 Node: Compiling For Multiple Architectures
\7f219370
6555 Node: Installation Names
\7f221027
6556 Node: Specifying the System Type
\7f221749
6557 Node: Sharing Defaults
\7f222460
6558 Node: Operation Controls
\7f223125
6559 Node: Optional Features
\7f224030
6560 Node: Reporting Bugs
\7f228913
6561 Node: Builtin Index
\7f229993
6562 Node: Reserved Word Index
\7f233406
6563 Node: Variable Index
\7f234714
6564 Node: Function Index
\7f239899
6565 Node: Concept Index
\7f244257