1 This is Info file features.info, produced by Makeinfo-1.55 from the
2 input file features.texi.
4 This text is a brief description of the features that are present in
7 This is Edition 1.14, last updated 4 August 1994,
8 of `The GNU Bash Features Guide',
9 for `Bash', Version 1.14.
11 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
13 This file is part of GNU Bash, the Bourne Again SHell.
15 Bash is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 1, or (at your option)
20 Bash is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
23 License for more details.
25 You should have received a copy of the GNU General Public License
26 along with Bash; see the file COPYING. If not, write to the Free
27 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30 File: features.info, Node: Top, Next: Bourne Shell Features, Prev: (DIR), Up: (DIR)
35 Bash contains features that appear in other popular shells, and some
36 features that only appear in Bash. Some of the shells that Bash has
37 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
38 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
39 following menu breaks the features up into categories based upon which
40 one of these other shells inspired the feature.
42 This manual is meant as a brief introduction to features found in
43 Bash. The Bash manual page should be used as the definitive reference
48 * Bourne Shell Features:: Features originally found in the
51 * Csh Features:: Features originally found in the
54 * Korn Shell Features:: Features originally found in the Korn
57 * Bash Specific Features:: Features found only in Bash.
59 * Job Control:: A chapter describing what job control is
60 and how bash allows you to use it.
62 * Using History Interactively:: Chapter dealing with history expansion
65 * Command Line Editing:: Chapter describing the command line
68 * Variable Index:: Quick reference helps you find the
71 * Concept Index:: General index for this manual.
74 File: features.info, Node: Bourne Shell Features, Next: Csh Features, Prev: Top, Up: Top
76 Bourne Shell Style Features
77 ***************************
79 Bash is an acronym for Bourne Again SHell. The Bourne shell is the
80 traditional Unix shell originally written by Stephen Bourne. All of
81 the Bourne shell builtin commands are available in Bash, and the rules
82 for evaluation and quoting are taken from the Posix 1003.2
83 specification for the `standard' Unix shell.
85 This section briefly summarizes things which Bash inherits from the
86 Bourne shell: shell control structures, builtins, variables, and other
87 features. It also lists the significant differences between Bash and
92 * Looping Constructs:: Shell commands for iterative action.
93 * Conditional Constructs:: Shell commands for conditional execution.
94 * Shell Functions:: Grouping commands by name.
95 * Bourne Shell Builtins:: Builtin commands inherited from the Bourne
97 * Bourne Shell Variables:: Variables which Bash uses in the same way
99 * Other Bourne Shell Features:: Addtional aspects of Bash which behave in
100 the same way as the Bourne Shell.
103 File: features.info, Node: Looping Constructs, Next: Conditional Constructs, Up: Bourne Shell Features
108 Note that wherever you see a `;' in the description of a command's
109 syntax, it may be replaced indiscriminately with one or more newlines.
111 Bash supports the following looping constructs.
114 The syntax of the `until' command is:
115 until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
116 Execute CONSEQUENT-COMMANDS as long as the final command in
117 TEST-COMMANDS has an exit status which is not zero.
120 The syntax of the `while' command is:
121 while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
123 Execute CONSEQUENT-COMMANDS as long as the final command in
124 TEST-COMMANDS has an exit status of zero.
127 The syntax of the for command is:
129 for NAME [in WORDS ...]; do COMMANDS; done
130 Execute COMMANDS for each member in WORDS, with NAME bound to the
131 current member. If "`in WORDS'" is not present, "`in "$@"'" is
135 File: features.info, Node: Conditional Constructs, Next: Shell Functions, Prev: Looping Constructs, Up: Bourne Shell Features
137 Conditional Constructs
138 ======================
141 The syntax of the `if' command is:
143 if TEST-COMMANDS; then
145 [elif MORE-TEST-COMMANDS; then
147 [else ALTERNATE-CONSEQUENTS;]
150 Execute CONSEQUENT-COMMANDS only if the final command in
151 TEST-COMMANDS has an exit status of zero. Otherwise, each `elif'
152 list is executed in turn, and if its exit status is zero, the
153 corresponding MORE-CONSEQUENTS is executed and the command
154 completes. If "`else ALTERNATE-CONSEQUENTS'" is present, and the
155 final command in the final `if' or `elif' clause has a non-zero
156 exit status, then execute ALTERNATE-CONSEQUENTS.
159 The syntax of the `case' command is:
161 `case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
163 Selectively execute COMMANDS based upon WORD matching PATTERN.
164 The ``|'' is used to separate multiple patterns.
166 Here is an example using `case' in a script that could be used to
167 describe an interesting feature of an animal:
169 echo -n "Enter the name of an animal: "
171 echo -n "The $ANIMAL has "
173 horse | dog | cat) echo -n "four";;
174 man | kangaroo ) echo -n "two";;
175 *) echo -n "an unknown number of";;
180 File: features.info, Node: Shell Functions, Next: Bourne Shell Builtins, Prev: Conditional Constructs, Up: Bourne Shell Features
185 Shell functions are a way to group commands for later execution
186 using a single name for the group. They are executed just like a
187 "regular" command. Shell functions are executed in the current shell
188 context; no new process is created to interpret them.
190 Functions are declared using this syntax:
192 [ `function' ] NAME () { COMMAND-LIST; }
194 This defines a function named NAME. The BODY of the function is the
195 COMMAND-LIST between { and }. This list is executed whenever NAME is
196 specified as the name of a command. The exit status of a function is
197 the exit status of the last command executed in the body.
199 When a function is executed, the arguments to the function become
200 the positional parameters during its execution. The special parameter
201 `#' that gives the number of positional parameters is updated to
202 reflect the change. Positional parameter 0 is unchanged.
204 If the builtin command `return' is executed in a function, the
205 function completes and execution resumes with the next command after
206 the function call. When a function completes, the values of the
207 positional parameters and the special parameter `#' are restored to the
208 values they had prior to function execution.
211 File: features.info, Node: Bourne Shell Builtins, Next: Bourne Shell Variables, Prev: Shell Functions, Up: Bourne Shell Features
213 Bourne Shell Builtins
214 =====================
216 The following shell builtin commands are inherited from the Bourne
217 shell. These commands are implemented as specified by the Posix 1003.2
221 Do nothing beyond expanding any arguments and performing
225 Read and execute commands from the FILENAME argument in the
226 current shell context.
229 Exit from a `for', `while', or `until' loop.
232 Change the current working directory.
235 Resume the next iteration of an enclosing `for', `while', or
239 Print the arguments, separated by spaces, to the standard output.
242 The arguments are concatenated together into a single command,
243 which is then read and executed.
246 If a COMMAND argument is supplied, it replaces the shell. If no
247 COMMAND is specified, redirections may be used to affect the
248 current shell environment.
254 Mark the arguments as variables to be passed to child processes in
258 Parse options to shell scripts or functions.
261 Remember the full pathnames of commands specified as arguments, so
262 they need not be searched for on subsequent invocations.
265 Send a signal to a process.
268 Print the current working directory.
271 Read a line from the shell input and use it to set the values of
275 Mark variables as unchangable.
278 Cause a shell function to exit with a specified value.
281 Shift positional parameters to the left.
285 Evaluate a conditional expression.
288 Print out the user and system times used by the shell and its
292 Specify commands to be executed when the shell receives signals.
295 Set the shell process's file creation mask.
298 Cause shell variables to disappear.
301 Wait until child processes exit and report their exit status.
304 File: features.info, Node: Bourne Shell Variables, Next: Other Bourne Shell Features, Prev: Bourne Shell Builtins, Up: Bourne Shell Features
306 Bourne Shell Variables
307 ======================
309 Bash uses certain shell variables in the same way as the Bourne
310 shell. In some cases, Bash assigns a default value to the variable.
313 A list of characters that separate fields; used when the shell
314 splits words as part of expansion.
317 A colon-separated list of directories in which the shell looks for
321 The current user's home directory.
324 A colon-separated list of directories used as a search path for
328 A colon-separated list of files which the shell periodically checks
329 for new mail. You can also specify what message is printed by
330 separating the file name from the message with a `?'. When used
331 in the text of the message, `$_' stands for the name of the
335 The primary prompt string.
338 The secondary prompt string.
341 The index of the last option processed by the `getopts' builtin.
344 The value of the last option argument processed by the `getopts'
348 File: features.info, Node: Other Bourne Shell Features, Prev: Bourne Shell Variables, Up: Bourne Shell Features
350 Other Bourne Shell Features
351 ===========================
355 * Major Differences from the Bourne Shell:: Major differences between
356 Bash and the Bourne shell.
358 Bash implements essentially the same grammar, parameter and variable
359 expansion, redirection, and quoting as the Bourne Shell. Bash uses the
360 Posix 1003.2 standard as the specification of how these features are to
361 be implemented. There are some differences between the traditional
362 Bourne shell and the Posix standard; this section quickly details the
363 differences of significance. A number of these differences are
364 explained in greater depth in subsequent sections.
367 File: features.info, Node: Major Differences from the Bourne Shell, Up: Other Bourne Shell Features
369 Major Differences from the Bourne Shell
370 ---------------------------------------
372 Bash implements the `!' keyword to negate the return value of a
373 pipeline. Very useful when an `if' statement needs to act only if a
376 Bash includes brace expansion (*note Brace Expansion::.).
378 Bash includes the Posix and `ksh'-style pattern removal `%%' and
379 `##' constructs to remove leading or trailing substrings from variables.
381 The Posix and `ksh'-style `$()' form of command substitution is
382 implemented, and preferred to the Bourne shell's ```' (which is also
383 implemented for backwards compatibility).
385 Variables present in the shell's initial environment are
386 automatically exported to child processes. The Bourne shell does not
387 normally do this unless the variables are explicitly marked using the
390 The expansion `${#xx}', which returns the length of `$xx', is
393 The `IFS' variable is used to split only the results of expansion,
394 not all words. This closes a longstanding shell security hole.
396 It is possible to have a variable and a function with the same name;
397 `sh' does not separate the two name spaces.
399 Bash functions are permitted to have local variables, and thus useful
400 recursive functions may be written.
402 The `noclobber' option is available to avoid overwriting existing
403 files with output redirection.
405 Bash allows you to write a function to override a builtin, and
406 provides access to that builtin's functionality within the function via
407 the `builtin' and `command' builtins.
409 The `command' builtin allows selective disabling of functions when
410 command lookup is performed.
412 Individual builtins may be enabled or disabled using the `enable'
415 Functions may be exported to children via the environment.
417 The Bash `read' builtin will read a line ending in \ with the `-r'
418 option, and will use the `$REPLY' variable as a default if no arguments
421 The `return' builtin may be used to abort execution of scripts
422 executed with the `.' or `source' builtins.
424 The `umask' builtin allows symbolic mode arguments similar to those
427 The `test' builtin is slightly different, as it implements the Posix
428 1003.2 algorithm, which specifies the behavior based on the number of
432 File: features.info, Node: Csh Features, Next: Korn Shell Features, Prev: Bourne Shell Features, Up: Top
434 C-Shell Style Features
435 **********************
437 The C-Shell ("`csh'") was created by Bill Joy at UC Berkeley. It is
438 generally considered to have better features for interactive use than
439 the original Bourne shell. Some of the `csh' features present in Bash
440 include job control, history expansion, `protected' redirection, and
441 several variables for controlling the interactive behaviour of the shell
444 *Note Using History Interactively:: for details on history expansion.
448 * Tilde Expansion:: Expansion of the ~ character.
449 * Brace Expansion:: Expansion of expressions within braces.
450 * C Shell Builtins:: Builtin commands adopted from the C Shell.
451 * C Shell Variables:: Variables which Bash uses in essentially
452 the same way as the C Shell.
455 File: features.info, Node: Tilde Expansion, Next: Brace Expansion, Up: Csh Features
460 Bash has tilde (~) expansion, similar, but not identical, to that of
461 `csh'. The following table shows what unquoted words beginning with a
465 The current value of `$HOME'.
471 The subdirectory `foo' of the home directory of the user `fred'.
479 Bash will also tilde expand words following redirection operators
480 and words following `=' in assignment statements.
483 File: features.info, Node: Brace Expansion, Next: C Shell Builtins, Prev: Tilde Expansion, Up: Csh Features
488 Brace expansion is a mechanism by which arbitrary strings may be
489 generated. This mechanism is similar to PATHNAME EXPANSION (see the
490 Bash manual page for details), but the file names generated need not
491 exist. Patterns to be brace expanded take the form of an optional
492 PREAMBLE, followed by a series of comma-separated strings between a
493 pair of braces, followed by an optional POSTAMBLE. The preamble is
494 prepended to each string contained within the braces, and the postamble
495 is then appended to each resulting string, expanding left to right.
497 Brace expansions may be nested. The results of each expanded string
498 are not sorted; left to right order is preserved. For example,
500 expands into ADE ACE ABE.
502 Brace expansion is performed before any other expansions, and any
503 characters special to other expansions are preserved in the result. It
504 is strictly textual. Bash does not apply any syntactic interpretation
505 to the context of the expansion or the text between the braces.
507 A correctly-formed brace expansion must contain unquoted opening and
508 closing braces, and at least one unquoted comma. Any incorrectly
509 formed brace expansion is left unchanged.
511 This construct is typically used as shorthand when the common prefix
512 of the strings to be generated is longer than in the above example:
513 mkdir /usr/local/src/bash/{old,new,dist,bugs}
515 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
518 File: features.info, Node: C Shell Builtins, Next: C Shell Variables, Prev: Brace Expansion, Up: Csh Features
523 Bash has several builtin commands whose definition is very similar
527 pushd [DIR | +N | -N]
529 Save the current directory on a list and then `cd' to DIR. With no
530 arguments, exchanges the top two directories.
533 Brings the Nth directory (counting from the left of the list
534 printed by `dirs') to the top of the list by rotating the
538 Brings the Nth directory (counting from the right of the list
539 printed by `dirs') to the top of the list by rotating the
543 Makes the current working directory be the top of the stack,
544 and then CDs to DIR. You can see the saved directory list
545 with the `dirs' command.
550 Pops the directory stack, and `cd's to the new top directory. When
551 no arguments are given, removes the top directory from the stack
552 and `cd's to the new top directory. The elements are numbered
553 from 0 starting at the first directory listed with `dirs'; i.e.
554 `popd' is equivalent to `popd +0'.
556 Removes the Nth directory (counting from the left of the list
557 printed by `dirs'), starting with zero.
560 Removes the Nth directory (counting from the right of the
561 list printed by `dirs'), starting with zero.
565 Display the list of currently remembered directories. Directories
566 find their way onto the list with the `pushd' command; you can get
567 back up through the list with the `popd' command.
569 Displays the Nth directory (counting from the left of the
570 list printed by `dirs' when invoked without options), starting
574 Displays the Nth directory (counting from the right of the
575 list printed by `dirs' when invoked without options), starting
579 Produces a longer listing; the default listing format uses a
580 tilde to denote the home directory.
583 history [N] [ [-w -r -a -n] [FILENAME]]
585 Display the history list with line numbers. Lines prefixed with
586 with a `*' have been modified. An argument of N says to list only
587 the last N lines. Option `-w' means write out the current history
588 to the history file; `-r' means to read the current history file
589 and make its contents the history list. An argument of `-a' means
590 to append the new history lines (history lines entered since the
591 beginning of the current Bash session) to the history file.
592 Finally, the `-n' argument means to read the history lines not
593 already read from the history file into the current history list.
594 These are lines appended to the history file since the beginning
595 of the current Bash session. If FILENAME is given, then it is used
596 as the history file, else if `$HISTFILE' has a value, that is
597 used, otherwise `~/.bash_history' is used.
603 A synonym for `.' (*note Bourne Shell Builtins::.)
606 File: features.info, Node: C Shell Variables, Prev: C Shell Builtins, Up: Csh Features
612 If this variable is set, it represents the number of consecutive
613 `EOF's Bash will read before exiting. By default, Bash will exit
614 upon reading a single `EOF'.
617 If this variable is set, Bash treats arguments to the `cd' command
618 which are not directories as names of variables whose values are
619 the directories to change to.
622 File: features.info, Node: Korn Shell Features, Next: Bash Specific Features, Prev: Csh Features, Up: Top
624 Korn Shell Style Features
625 *************************
627 This section describes features primarily inspired by the Korn Shell
628 (`ksh'). In some cases, the Posix 1003.2 standard has adopted these
629 commands and variables from the Korn Shell; Bash implements those
630 features using the Posix standard as a guide.
634 * Korn Shell Constructs:: Shell grammar constructs adopted from the
636 * Korn Shell Builtins:: Builtin commands adopted from the Korn Shell.
637 * Korn Shell Variables:: Variables which bash uses in essentially
638 the same way as the Korn Shell.
639 * Aliases:: Substituting one command for another.
642 File: features.info, Node: Korn Shell Constructs, Next: Korn Shell Builtins, Up: Korn Shell Features
644 Korn Shell Constructs
645 =====================
647 Bash includes the Korn Shell `select' construct. This construct
648 allows the easy generation of menus. It has almost the same syntax as
651 The syntax of the `select' command is:
652 select NAME [in WORDS ...]; do COMMANDS; done
654 The list of words following `in' is expanded, generating a list of
655 items. The set of expanded words is printed on the standard error,
656 each preceded by a number. If the "`in WORDS'" is omitted, the
657 positional parameters are printed. The `PS3' prompt is then displayed
658 and a line is read from the standard input. If the line consists of the
659 number corresponding to one of the displayed words, then the value of
660 NAME is set to that word. If the line is empty, the words and prompt
661 are displayed again. If `EOF' is read, the `select' command completes.
662 Any other value read causes NAME to be set to null. The line read is
663 saved in the variable `REPLY'.
665 The COMMANDS are executed after each selection until a `break' or
666 `return' command is executed, at which point the `select' command
670 File: features.info, Node: Korn Shell Builtins, Next: Korn Shell Variables, Prev: Korn Shell Constructs, Up: Korn Shell Features
675 This section describes Bash builtin commands taken from `ksh'.
678 `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
679 `fc -s [PAT=REP] [COMMAND]'
681 Fix Command. In the first form, a range of commands from FIRST to
682 LAST is selected from the history list. Both FIRST and LAST may
683 be specified as a string (to locate the most recent command
684 beginning with that string) or as a number (an index into the
685 history list, where a negative number is used as an offset from the
686 current command number). If LAST is not specified it is set to
687 FIRST. If FIRST is not specified it is set to the previous
688 command for editing and -16 for listing. If the `-l' flag is
689 given, the commands are listed on standard output. The `-n' flag
690 suppresses the command numbers when listing. The `-r' flag
691 reverses the order of the listing. Otherwise, the editor given by
692 ENAME is invoked on a file containing those commands. If ENAME is
693 not given, the value of the following variable expansion is used:
694 `${FCEDIT:-${EDITOR:-vi}}'. This says to use the value of the
695 `FCEDIT' variable if set, or the value of the `EDITOR' variable if
696 that is set, or `vi' if neither is set. When editing is complete,
697 the edited commands are echoed and executed.
699 In the second form, COMMAND is re-executed after each instance of
700 PAT in the selected command is replaced by REP.
702 A useful alias to use with the `fc' command is `r='fc -s'', so
703 that typing `r cc' runs the last command beginning with `cc' and
704 typing `r' re-executes the last command (*note Aliases::.).
707 The `let' builtin allows arithmetic to be performed on shell
708 variables. For details, refer to *Note Arithmetic Builtins::.
711 The `typeset' command is supplied for compatibility with the Korn
712 shell; however, it has been made obsolete by the `declare' command
713 (*note Bash Builtins::.).
716 File: features.info, Node: Korn Shell Variables, Next: Aliases, Prev: Korn Shell Builtins, Up: Korn Shell Features
722 The default variable for the `read' builtin.
725 Each time this parameter is referenced, a random integer is
726 generated. Assigning a value to this variable seeds the random
730 This variable expands to the number of seconds since the shell was
731 started. Assignment to this variable resets the count to the
732 value assigned, and the expanded value becomes the value assigned
733 plus the number of seconds since the assignment.
736 The value of this variable is used as the prompt for the `select'
740 This is the prompt printed before the command line is echoed when
741 the `-x' option is set (*note The Set Builtin::.).
744 The current working directory as set by the `cd' builtin.
747 The previous working directory as set by the `cd' builtin.
750 If set to a value greater than zero, the value is interpreted as
751 the number of seconds to wait for input after issuing the primary
752 prompt. Bash terminates after that number of seconds if input does
756 File: features.info, Node: Aliases, Prev: Korn Shell Variables, Up: Korn Shell Features
763 * Alias Builtins:: Builtins commands to maniuplate aliases.
765 The shell maintains a list of ALIASES that may be set and unset with
766 the `alias' and `unalias' builtin commands.
768 The first word of each command, if unquoted, is checked to see if it
769 has an alias. If so, that word is replaced by the text of the alias.
770 The alias name and the replacement text may contain any valid shell
771 input, including shell metacharacters, with the exception that the
772 alias name may not contain =. The first word of the replacement text
773 is tested for aliases, but a word that is identical to an alias being
774 expanded is not expanded a second time. This means that one may alias
775 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
776 expand the replacement text. If the last character of the alias value
777 is a space or tab character, then the next command word following the
778 alias is also checked for alias expansion.
780 Aliases are created and listed with the `alias' command, and removed
781 with the `unalias' command.
783 There is no mechanism for using arguments in the replacement text,
784 as in `csh'. If arguments are needed, a shell function should be used.
786 Aliases are not expanded when the shell is not interactive.
788 The rules concerning the definition and use of aliases are somewhat
789 confusing. Bash always reads at least one complete line of input
790 before executing any of the commands on that line. Aliases are
791 expanded when a command is read, not when it is executed. Therefore, an
792 alias definition appearing on the same line as another command does not
793 take effect until the next line of input is read. This means that the
794 commands following the alias definition on that line are not affected
795 by the new alias. This behavior is also an issue when functions are
796 executed. Aliases are expanded when the function definition is read,
797 not when the function is executed, because a function definition is
798 itself a compound command. As a consequence, aliases defined in a
799 function are not available until after that function is executed. To
800 be safe, always put alias definitions on a separate line, and do not
801 use `alias' in compound commands.
803 Note that for almost every purpose, aliases are superseded by shell
807 File: features.info, Node: Alias Builtins, Up: Aliases
813 alias [NAME[=VALUE] ...]
815 Without arguments, print the list of aliases on the standard
816 output. If arguments are supplied, an alias is defined for each
817 NAME whose VALUE is given. If no VALUE is given, the name and
818 value of the alias is printed.
821 unalias [-a] [NAME ... ]
823 Remove each NAME from the list of aliases. If `-a' is supplied,
824 all aliases are removed.
827 File: features.info, Node: Bash Specific Features, Next: Job Control, Prev: Korn Shell Features, Up: Top
829 Bash Specific Features
830 **********************
832 This section describes the features unique to Bash.
836 * Invoking Bash:: Command line options that you can give
838 * Bash Startup Files:: When and how Bash executes scripts.
839 * Is This Shell Interactive?:: Determining the state of a running Bash.
840 * Bash Builtins:: Table of builtins specific to Bash.
841 * The Set Builtin:: This builtin is so overloaded it
842 deserves its own section.
843 * Bash Variables:: List of variables that exist in Bash.
844 * Shell Arithmetic:: Arithmetic on shell variables.
845 * Printing a Prompt:: Controlling the PS1 string.
848 File: features.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Specific Features
853 In addition to the single-character shell command-line options
854 (*note The Set Builtin::.), there are several multi-character options
855 that you can use. These options must appear on the command line before
856 the single-character options to be recognized.
859 Don't read the `~/.bashrc' initialization file in an interactive
860 shell. This is on by default if the shell is invoked as `sh'.
863 Execute commands from FILENAME (instead of `~/.bashrc') in an
867 Don't load the system-wide startup file `/etc/profile' or any of
868 the personal initialization files `~/.bash_profile',
869 `~/.bash_login', or `~/.profile' when bash is invoked as a login
873 Display the version number of this shell.
876 Make this shell act as if it were directly invoked from login.
877 This is equivalent to `exec - bash' but can be issued from another
878 shell, such as `csh'. If you wanted to replace your current login
879 shell with a Bash login shell, you would say `exec bash -login'.
882 Do not perform curly brace expansion (*note Brace Expansion::.).
885 Do not use the GNU Readline library (*note Command Line Editing::.)
886 to read interactive command lines.
889 Change the behavior of Bash where the default operation differs
890 from the Posix 1003.2 standard to match the standard. This is
891 intended to make Bash behave as a strict superset of that standard.
893 There are several single-character options you can give which are
894 not available with the `set' builtin.
897 Read and execute commands from STRING after processing the
901 Force the shell to run interactively.
904 If this flag is present, or if no arguments remain after option
905 processing, then commands are read from the standard input. This
906 option allows the positional parameters to be set when invoking an
909 An *interactive* shell is one whose input and output are both
910 connected to terminals (as determined by `isatty()'), or one started
911 with the `-i' option.
914 File: features.info, Node: Bash Startup Files, Next: Is This Shell Interactive?, Prev: Invoking Bash, Up: Bash Specific Features
919 When and how Bash executes startup files.
921 For Login shells (subject to the -noprofile option):
924 If `/etc/profile' exists, then source it.
926 If `~/.bash_profile' exists, then source it,
927 else if `~/.bash_login' exists, then source it,
928 else if `~/.profile' exists, then source it.
931 If `~/.bash_logout' exists, source it.
933 For non-login interactive shells (subject to the -norc and -rcfile options):
935 If `~/.bashrc' exists, then source it.
937 For non-interactive shells:
939 If the environment variable `ENV' is non-null, expand the
940 variable and source the file named by the value. If Bash is
941 not started in Posix mode, it looks for `BASH_ENV' before
944 So, typically, your `~/.bash_profile' contains the line
945 `if [ -f `~/.bashrc' ]; then source `~/.bashrc'; fi'
947 after (or before) any login specific initializations.
949 If Bash is invoked as `sh', it tries to mimic the behavior of `sh'
950 as closely as possible. For a login shell, it attempts to source only
951 `/etc/profile' and `~/.profile', in that order. The `-noprofile'
952 option may still be used to disable this behavior. A shell invoked as
953 `sh' does not attempt to source any other startup files.
955 When Bash is started in POSIX mode, as with the `-posix' command
956 line option, it follows the Posix 1003.2 standard for startup files.
957 In this mode, the `ENV' variable is expanded and that file sourced; no
958 other startup files are read.
961 File: features.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Specific Features
963 Is This Shell Interactive?
964 ==========================
966 You may wish to determine within a startup script whether Bash is
967 running interactively or not. To do this, examine the variable `$PS1';
968 it is unset in non-interactive shells, and set in interactive shells.
971 if [ -z "$PS1" ]; then
972 echo This shell is not interactive
974 echo This shell is interactive
977 You can ask an interactive Bash to not run your `~/.bashrc' file
978 with the `-norc' flag. You can change the name of the `~/.bashrc' file
979 to any other file name with `-rcfile FILENAME'. You can ask Bash to
980 not run your `~/.bash_profile' file with the `-noprofile' flag.
983 File: features.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Is This Shell Interactive?, Up: Bash Specific Features
985 Bash Builtin Commands
986 =====================
988 This section describes builtin commands which are unique to or have
989 been extended in Bash.
992 builtin [SHELL-BUILTIN [ARGS]]
993 Run a shell builtin. This is useful when you wish to rename a
994 shell builtin to be a function, but need the functionality of the
995 builtin within the function itself.
998 bind [-m KEYMAP] [-lvd] [-q NAME]
999 bind [-m KEYMAP] -f FILENAME
1000 bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
1002 Display current Readline (*note Command Line Editing::.) key and
1003 function bindings, or bind a key sequence to a Readline function
1004 or macro. The binding syntax accepted is identical to that of
1005 `.inputrc' (*note Readline Init File::.), but each binding must be
1006 passed as a separate argument: `"\C-x\C-r":re-read-init-file'.
1007 Options, if supplied, have the following meanings:
1010 Use KEYMAP as the keymap to be affected by the subsequent
1011 bindings. Acceptable KEYMAP names are `emacs',
1012 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
1013 `vi-command', and `vi-insert'. `vi' is equivalent to
1014 `vi-command'; `emacs' is equivalent to `emacs-standard'.
1017 List the names of all readline functions
1020 List current function names and bindings
1023 Dump function names and bindings in such a way that they can
1027 Read key bindings from FILENAME
1030 Query about which keys invoke the named FUNCTION
1033 command [-pVv] COMMAND [ARGS ...]
1034 Runs COMMAND with ARG ignoring shell functions. If you have a
1035 shell function called `ls', and you wish to call the command `ls',
1036 you can say `command ls'. The `-p' option means to use a default
1037 value for `$PATH' that is guaranteed to find all of the standard
1040 If either the `-V' or `-v' option is supplied, a description of
1041 COMMAND is printed. The `-v' option causes a single word
1042 indicating the command or file name used to invoke COMMAND to be
1043 printed; the `-V' option produces a more verbose description.
1046 declare [-frxi] [NAME[=VALUE]]
1048 Declare variables and/or give them attributes. If no NAMEs are
1049 given, then display the values of variables instead. `-f' means
1050 to use function names only. `-r' says to make NAMEs readonly.
1051 `-x' says to mark NAMEs for export. `-i' says that the variable
1052 is to be treated as an integer; arithmetic evaluation (*note Shell
1053 Arithmetic::.) is performed when the variable is assigned a value.
1054 Using `+' instead of `-' turns off the attribute instead. When
1055 used in a function, `declare' makes NAMEs local, as with the
1059 enable [-n] [-a] [NAME ...]
1060 Enable and disable builtin shell commands. This allows you to use
1061 a disk command which has the same name as a shell builtin. If
1062 `-n' is used, the NAMEs become disabled. Otherwise NAMEs are
1063 enabled. For example, to use the `test' binary found via `$PATH'
1064 instead of the shell builtin version, type `enable -n test'. The
1065 `-a' option means to list each builtin with an indication of
1066 whether or not it is enabled.
1070 Display helpful information about builtin commands. If PATTERN is
1071 specified, `help' gives detailed help on all commands matching
1072 PATTERN, otherwise a list of the builtins is printed.
1076 For each argument, create a local variable called NAME, and give
1077 it VALUE. `local' can only be used within a function; it makes
1078 the variable NAME have a visible scope restricted to that function
1082 type [-all] [-type | -path] [NAME ...]
1083 For each NAME, indicate how it would be interpreted if used as a
1086 If the `-type' flag is used, `type' returns a single word which is
1087 one of "alias", "function", "builtin", "file" or "keyword", if
1088 NAME is an alias, shell function, shell builtin, disk file, or
1089 shell reserved word, respectively.
1091 If the `-path' flag is used, `type' either returns the name of the
1092 disk file that would be executed, or nothing if `-type' would not
1095 If the `-all' flag is used, returns all of the places that contain
1096 an executable named FILE. This includes aliases and functions, if
1097 and only if the `-path' flag is not also used.
1099 `Type' accepts `-a', `-t', and `-p' as equivalent to `-all',
1100 `-type', and `-path', respectively.
1103 ulimit [-acdmstfpnuvSH] [LIMIT]
1104 `Ulimit' provides control over the resources available to processes
1105 started by the shell, on systems that allow such control. If an
1106 option is given, it is interpreted as follows:
1108 change and report the soft limit associated with a resource
1109 (the default if the `-H' option is not given).
1112 change and report the hard limit associated with a resource.
1115 all current limits are reported.
1118 the maximum size of core files created.
1121 the maximum size of a process's data segment.
1124 the maximum resident set size.
1127 the maximum stack size.
1130 the maximum amount of cpu time in seconds.
1133 the maximum size of files created by the shell.
1136 the pipe buffer size.
1139 the maximum number of open file descriptors.
1142 the maximum number of processes available to a single user.
1145 the maximum amount of virtual memory available to the process.
1147 If LIMIT is given, it is the new value of the specified resource.
1148 Otherwise, the current value of the specified resource is printed.
1149 If no option is given, then `-f' is assumed. Values are in
1150 1024-byte increments, except for `-t', which is in seconds, `-p',
1151 which is in units of 512-byte blocks, and `-n' and `-u', which are
1155 File: features.info, Node: The Set Builtin, Next: Bash Variables, Prev: Bash Builtins, Up: Bash Specific Features
1160 This builtin is so overloaded that it deserves its own section.
1163 set [-abefhkmnptuvxldCHP] [-o OPTION] [ARGUMENT ...]
1166 Mark variables which are modified or created for export.
1169 Cause the status of terminated background jobs to be reported
1170 immediately, rather than before printing the next primary
1174 Exit immediately if a command exits with a non-zero status.
1177 Disable file name generation (globbing).
1180 Locate and remember (hash) commands as functions are defined,
1181 rather than when the function is executed.
1184 All keyword arguments are placed in the environment for a
1185 command, not just those that precede the command name.
1188 Job control is enabled (*note Job Control::.).
1191 Read commands but do not execute them.
1194 Set the flag corresponding to OPTION-NAME:
1200 the shell will perform brace expansion (*note Brace
1204 use an emacs-style line editing interface (*note Command
1214 the shell will not exit upon reading EOF.
1216 `interactive-comments'
1217 allow a word beginning with a `#' to cause that word and
1218 all remaining characters on that line to be ignored in an
1246 change the behavior of Bash where the default operation
1247 differs from the Posix 1003.2 standard to match the
1248 standard. This is intended to make Bash behave as a
1249 strict superset of that standard.
1258 use a `vi'-style line editing interface.
1264 Turn on privileged mode. In this mode, the `$ENV' file is
1265 not processed, and shell functions are not inherited from the
1266 environment. This is enabled automatically on startup if the
1267 effective user (group) id is not equal to the real user
1268 (group) id. Turning this option off causes the effective user
1269 and group ids to be set to the real user and group ids.
1272 Exit after reading and executing one command.
1275 Treat unset variables as an error when substituting.
1278 Print shell input lines as they are read.
1281 Print commands and their arguments as they are executed.
1284 Save and restore the binding of the NAME in a `for' command.
1287 Disable the hashing of commands that are looked up for
1288 execution. Normally, commands are remembered in a hash
1289 table, and once found, do not have to be looked up again.
1292 Disallow output redirection to existing files.
1295 Enable ! style history substitution. This flag is on by
1299 If set, do not follow symbolic links when performing commands
1300 such as `cd' which change the current directory. The
1301 physical directory is used instead.
1304 If no arguments follow this flag, then the positional
1305 parameters are unset. Otherwise, the positional parameters
1306 are set to the ARGUMENTS, even if some of them begin with a
1310 Signal the end of options, cause all remaining ARGUMENTS to
1311 be assigned to the positional parameters. The `-x' and `-v'
1312 options are turned off. If there are no arguments, the
1313 positional parameters remain unchanged.
1315 Using `+' rather than `-' causes these flags to be turned off.
1316 The flags can also be used upon invocation of the shell. The
1317 current set of flags may be found in `$-'. The remaining N
1318 ARGUMENTS are positional parameters and are assigned, in order, to
1319 `$1', `$2', .. `$N'. If no arguments are given, all shell
1320 variables are printed.
1323 File: features.info, Node: Bash Variables, Next: Shell Arithmetic, Prev: The Set Builtin, Up: Bash Specific Features
1328 These variables are set or used by bash, but other shells do not
1329 normally treat them specially.
1333 Set to a value of `ignorespace', it means don't enter lines which
1334 begin with a space or tab into the history list. Set to a value
1335 of `ignoredups', it means don't enter lines which match the last
1336 entered line. A value of `ignoreboth' combines the two options.
1337 Unset, or set to any other value than those above, means to save
1338 all lines on the history list.
1341 The name of the file to which the command history is saved.
1344 If set, this is the maximum number of commands to remember in the
1348 Up to three characters which control history expansion, quick
1349 substitution, and tokenization (*note History Interaction::.).
1350 The first character is the "history-expansion-char", that is, the
1351 character which signifies the start of a history expansion,
1352 normally `!'. The second character is the character which
1353 signifies `quick substitution' when seen as the first character on
1354 a line, normally `^'. The optional third character is the
1355 character which signifies the remainder of the line is a comment,
1356 when found as the first character of a word, usually `#'. The
1357 history comment character causes history substitution to be
1358 skipped for the remaining words on the line. It does not
1359 necessarily cause the shell parser to treat the rest of the line
1363 The history number, or index in the history list, of the current
1364 command. If `HISTCMD' is unset, it loses its special properties,
1365 even if it is subsequently reset.
1367 `hostname_completion_file'
1369 Contains the name of a file in the same format as `/etc/hosts' that
1370 should be read when the shell needs to complete a hostname. You
1371 can change the file interactively; the next time you attempt to
1372 complete a hostname, Bash will add the contents of the new file to
1373 the already existing database.
1376 How often (in seconds) that the shell should check for mail in the
1377 files specified in `MAILPATH'.
1380 If present, this contains a string which is a command to execute
1381 before the printing of each primary prompt (`$PS1').
1384 The numeric real user id of the current user.
1387 The numeric effective user id of the current user.
1390 A string describing the machine Bash is running on.
1393 A string describing the operating system Bash is running on.
1396 A colon-separated list of suffixes to ignore when performing
1397 filename completion A file name whose suffix matches one of the
1398 entries in `FIGNORE' is excluded from the list of matched file
1399 names. A sample value is `.o:~'
1402 The name of the Readline startup file, overriding the default of
1406 The version number of the current instance of Bash.
1409 Controls the action of the shell on receipt of an `EOF' character
1410 as the sole input. If set, then the value of it is the number of
1411 consecutive `EOF' characters that can be read as the first
1412 characters on an input line before the shell will exit. If the
1413 variable exists but does not have a numeric value (or has no
1414 value) then the default is 10. If the variable does not exist,
1415 then `EOF' signifies the end of input to the shell. This is only
1416 in effect for interactive shells.
1418 `no_exit_on_failed_exec'
1419 If this variable exists, the shell will not exit in the case that
1420 it couldn't execute the file specified in the `exec' command.
1423 If present, says not to follow symbolic links when doing commands
1424 that change the current working directory. By default, bash
1425 follows the logical chain of directories when performing commands
1426 such as `cd' which change the current directory.
1428 For example, if `/usr/sys' is a link to `/usr/local/sys' then:
1429 $ cd /usr/sys; echo $PWD
1434 If `nolinks' exists, then:
1435 $ cd /usr/sys; echo $PWD
1440 See also the description of the `-P' option to the `set' builtin,
1441 *Note The Set Builtin::.
1444 File: features.info, Node: Shell Arithmetic, Next: Printing a Prompt, Prev: Bash Variables, Up: Bash Specific Features
1451 * Arithmetic Evaluation:: How shell arithmetic works.
1452 * Arithmetic Expansion:: How to use arithmetic in shell expansions.
1453 * Arithmetic Builtins:: Builtin commands that use shell arithmetic.
1456 File: features.info, Node: Arithmetic Evaluation, Next: Arithmetic Expansion, Up: Shell Arithmetic
1458 Arithmetic Evaluation
1459 ---------------------
1461 The shell allows arithmetic expressions to be evaluated, as one of
1462 the shell expansions or by the `let' builtin.
1464 Evaluation is done in long integers with no check for overflow,
1465 though division by 0 is trapped and flagged as an error. The following
1466 list of operators is grouped into levels of equal-precedence operators.
1467 The levels are listed in order of decreasing precedence.
1470 unary minus and plus
1473 logical and bitwise negation
1476 multiplication, division, remainder
1479 addition, subtraction
1482 left and right bitwise shifts
1488 equality and inequality
1494 bitwise exclusive OR
1505 `= *= /= %= += -= <<= >>= &= ^= |='
1508 Shell variables are allowed as operands; parameter expansion is
1509 performed before the expression is evaluated. The value of a parameter
1510 is coerced to a long integer within an expression. A shell variable
1511 need not have its integer attribute turned on to be used in an
1514 Constants with a leading 0 are interpreted as octal numbers. A
1515 leading `0x' or `0X' denotes hexadecimal. Otherwise, numbers take the
1516 form [BASE#]n, where BASE is a decimal number between 2 and 36
1517 representing the arithmetic base, and N is a number in that base. If
1518 BASE is omitted, then base 10 is used.
1520 Operators are evaluated in order of precedence. Sub-expressions in
1521 parentheses are evaluated first and may override the precedence rules
1525 File: features.info, Node: Arithmetic Expansion, Next: Arithmetic Builtins, Prev: Arithmetic Evaluation, Up: Shell Arithmetic
1527 Arithmetic Expansion
1528 --------------------
1530 Arithmetic expansion allows the evaluation of an arithmetic
1531 expression and the substitution of the result. There are two formats
1532 for arithmetic expansion:
1537 The expression is treated as if it were within double quotes, but a
1538 double quote inside the braces or parentheses is not treated specially.
1539 All tokens in the expression undergo parameter expansion, command
1540 substitution, and quote removal. Arithmetic substitutions may be
1543 The evaluation is performed according to the rules listed above. If
1544 the expression is invalid, Bash prints a message indicating failure and
1545 no substitution occurs.
1548 File: features.info, Node: Arithmetic Builtins, Prev: Arithmetic Expansion, Up: Shell Arithmetic
1554 let EXPRESSION [EXPRESSION]
1555 The `let' builtin allows arithmetic to be performed on shell
1556 variables. Each EXPRESSION is evaluated according to the rules
1557 given previously (*note Arithmetic Evaluation::.). If the last
1558 EXPRESSION evaluates to 0, `let' returns 1; otherwise 0 is
1562 File: features.info, Node: Printing a Prompt, Prev: Shell Arithmetic, Up: Bash Specific Features
1564 Controlling the Prompt
1565 ======================
1567 The value of the variable `$PROMPT_COMMAND' is examined just before
1568 Bash prints each primary prompt. If it is set and non-null, then the
1569 value is executed just as if you had typed it on the command line.
1571 In addition, the following table describes the special characters
1572 which can appear in the `PS1' variable:
1575 the time, in HH:MM:SS format.
1578 the date, in "Weekday Month Date" format (e.g. "Tue May 26").
1584 the name of the shell, the basename of `$0' (the portion following
1588 the current working directory.
1591 the basename of `$PWD'.
1600 the command number of this command.
1603 the history number of this command.
1606 the character corresponding to the octal number `nnn'.
1609 if the effective uid is 0, `#', otherwise `$'.
1615 begin a sequence of non-printing characters. This could be used to
1616 embed a terminal control sequence into the prompt.
1619 end a sequence of non-printing characters.
1622 File: features.info, Node: Job Control, Next: Using History Interactively, Prev: Bash Specific Features, Up: Top
1627 This chapter disusses what job control is, how it works, and how
1628 Bash allows you to access its facilities.
1632 * Job Control Basics:: How job control works.
1633 * Job Control Builtins:: Bash builtin commands used to interact
1635 * Job Control Variables:: Variables Bash uses to customize job
1639 File: features.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control
1644 Job control refers to the ability to selectively stop (suspend) the
1645 execution of processes and continue (resume) their execution at a later
1646 point. A user typically employs this facility via an interactive
1647 interface supplied jointly by the system's terminal driver and Bash.
1649 The shell associates a JOB with each pipeline. It keeps a table of
1650 currently executing jobs, which may be listed with the `jobs' command.
1651 When Bash starts a job asynchronously (in the background), it prints a
1652 line that looks like:
1654 indicating that this job is job number 1 and that the process ID of
1655 the last process in the pipeline associated with this job is 25647.
1656 All of the processes in a single pipeline are members of the same job.
1657 Bash uses the JOB abstraction as the basis for job control.
1659 To facilitate the implementation of the user interface to job
1660 control, the system maintains the notion of a current terminal process
1661 group ID. Members of this process group (processes whose process group
1662 ID is equal to the current terminal process group ID) receive
1663 keyboard-generated signals such as `SIGINT'. These processes are said
1664 to be in the foreground. Background processes are those whose process
1665 group ID differs from the terminal's; such processes are immune to
1666 keyboard-generated signals. Only foreground processes are allowed to
1667 read from or write to the terminal. Background processes which attempt
1668 to read from (write to) the terminal are sent a `SIGTTIN' (`SIGTTOU')
1669 signal by the terminal driver, which, unless caught, suspends the
1672 If the operating system on which Bash is running supports job
1673 control, Bash allows you to use it. Typing the SUSPEND character
1674 (typically `^Z', Control-Z) while a process is running causes that
1675 process to be stopped and returns you to Bash. Typing the DELAYED
1676 SUSPEND character (typically `^Y', Control-Y) causes the process to be
1677 stopped when it attempts to read input from the terminal, and control to
1678 be returned to Bash. You may then manipulate the state of this job,
1679 using the `bg' command to continue it in the background, the `fg'
1680 command to continue it in the foreground, or the `kill' command to kill
1681 it. A `^Z' takes effect immediately, and has the additional side
1682 effect of causing pending output and typeahead to be discarded.
1684 There are a number of ways to refer to a job in the shell. The
1685 character `%' introduces a job name. Job number `n' may be referred to
1686 as `%n'. A job may also be referred to using a prefix of the name used
1687 to start it, or using a substring that appears in its command line.
1688 For example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the
1689 other hand, refers to any job containing the string `ce' in its command
1690 line. If the prefix or substring matches more than one job, Bash
1691 reports an error. The symbols `%%' and `%+' refer to the shell's
1692 notion of the current job, which is the last job stopped while it was
1693 in the foreground. The previous job may be referenced using `%-'. In
1694 output pertaining to jobs (e.g., the output of the `jobs' command), the
1695 current job is always flagged with a `+', and the previous job with a
1698 Simply naming a job can be used to bring it into the foreground:
1699 `%1' is a synonym for `fg %1' bringing job 1 from the background into
1700 the foreground. Similarly, `%1 &' resumes job 1 in the background,
1701 equivalent to `bg %1'
1703 The shell learns immediately whenever a job changes state.
1704 Normally, Bash waits until it is about to print a prompt before
1705 reporting changes in a job's status so as to not interrupt any other
1706 output. If the the `-b' option to the `set' builtin is set, Bash
1707 reports such changes immediately (*note The Set Builtin::.). This
1708 feature is also controlled by the variable `notify'.
1710 If you attempt to exit bash while jobs are stopped, the shell prints
1711 a message warning you. You may then use the `jobs' command to inspect
1712 their status. If you do this, or try to exit again immediately, you
1713 are not warned again, and the stopped jobs are terminated.
1716 File: features.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control
1718 Job Control Builtins
1719 ====================
1723 Place JOBSPEC into the background, as if it had been started with
1724 `&'. If JOBSPEC is not supplied, the current job is used.
1728 Bring JOBSPEC into the foreground and make it the current job. If
1729 JOBSPEC is not supplied, the current job is used.
1732 jobs [-lpn] [JOBSPEC]
1733 jobs -x COMMAND [JOBSPEC]
1735 The first form lists the active jobs. The `-l' option lists
1736 process IDs in addition to the normal information; the `-p' option
1737 lists only the process ID of the job's process group leader. The
1738 `-n' option displays only jobs that have changed status since last
1739 notfied. If JOBSPEC is given, output is restricted to information
1740 about that job. If JOBSPEC is not supplied, the status of all
1743 If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
1744 in COMMAND or ARGUMENTS with the corresponding process group ID,
1745 and executes COMMAND, passing it ARGUMENTs, returning its exit
1750 Suspend the execution of this shell until it receives a `SIGCONT'
1751 signal. The `-f' option means to suspend even if the shell is a
1754 When job control is active, the `kill' and `wait' builtins also
1755 accept JOBSPEC arguments.
1758 File: features.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control
1760 Job Control Variables
1761 =====================
1764 This variable controls how the shell interacts with the user and
1765 job control. If this variable exists then single word simple
1766 commands without redirects are treated as candidates for resumption
1767 of an existing job. There is no ambiguity allowed; if you have
1768 more than one job beginning with the string that you have typed,
1769 then the most recently accessed job will be selected. The name of
1770 a stopped job, in this context, is the command line used to start
1771 it. If this variable is set to the value `exact', the string
1772 supplied must match the name of a stopped job exactly; if set to
1773 `substring', the string supplied needs to match a substring of the
1774 name of a stopped job. The `substring' value provides
1775 functionality analogous to the `%?' job id (*note Job Control
1776 Basics::.). If set to any other value, the supplied string must
1777 be a prefix of a stopped job's name; this provides functionality
1778 analogous to the `%' job id.
1781 Setting this variable to a value is equivalent to `set -b';
1782 unsetting it is equivalent to `set +b' (*note The Set Builtin::.).
1785 File: features.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
1787 Using History Interactively
1788 ***************************
1790 This chapter describes how to use the GNU History Library
1791 interactively, from a user's standpoint. It should be considered a
1792 user's guide. For information on using the GNU History Library in your
1793 own programs, see the GNU Readline Library Manual.
1797 * History Interaction:: What it feels like using History as a user.
1800 File: features.info, Node: History Interaction, Up: Using History Interactively
1805 The History library provides a history expansion feature that is
1806 similar to the history expansion provided by `csh'. The following text
1807 describes the syntax used to manipulate the history information.
1809 History expansion takes place in two parts. The first is to
1810 determine which line from the previous history should be used during
1811 substitution. The second is to select portions of that line for
1812 inclusion into the current one. The line selected from the previous
1813 history is called the "event", and the portions of that line that are
1814 acted upon are called "words". The line is broken into words in the
1815 same fashion that Bash does, so that several English (or Unix) words
1816 surrounded by quotes are considered as one word.
1820 * Event Designators:: How to specify which history line to use.
1821 * Word Designators:: Specifying which words are of interest.
1822 * Modifiers:: Modifying the results of substitution.
1825 File: features.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
1830 An event designator is a reference to a command line entry in the
1834 Start a history substitution, except when followed by a space, tab,
1835 the end of the line, = or (.
1838 Refer to the previous command. This is a synonym for `!-1'.
1841 Refer to command line N.
1844 Refer to the command N lines back.
1847 Refer to the most recent command starting with STRING.
1850 Refer to the most recent command containing STRING.
1853 The entire command line typed so far.
1856 Quick Substitution. Repeat the last command, replacing STRING1
1857 with STRING2. Equivalent to `!!:s/string1/string2/'.
1860 File: features.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
1865 A : separates the event specification from the word designator. It
1866 can be omitted if the word designator begins with a ^, $, * or %.
1867 Words are numbered from the beginning of the line, with the first word
1868 being denoted by a 0 (zero).
1871 The `0'th word. For many applications, this is the command word.
1877 The first argument; that is, word 1.
1883 The word matched by the most recent `?string?' search.
1886 A range of words; `-Y' abbreviates `0-Y'.
1889 All of the words, except the `0'th. This is a synonym for `1-$'.
1890 It is not an error to use * if there is just one word in the event;
1891 the empty string is returned in that case.
1897 Abbreviates `x-$' like `x*', but omits the last word.
1900 File: features.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
1905 After the optional word designator, you can add a sequence of one or
1906 more of the following modifiers, each preceded by a :.
1909 Remove a trailing pathname component, leaving only the head.
1912 Remove a trailing suffix of the form `.'SUFFIX, leaving the
1916 Remove all but the trailing suffix.
1919 Remove all leading pathname components, leaving the tail.
1922 Print the new command but do not execute it.
1925 Quote the substituted words, escaping further substitutions.
1928 Quote the substituted words as with `q', but break into words at
1929 spaces, tabs, and newlines.
1932 Substitute NEW for the first occurrence of OLD in the event line.
1933 Any delimiter may be used in place of /. The delimiter may be
1934 quoted in OLD and NEW with a single backslash. If & appears in
1935 NEW, it is replaced by OLD. A single backslash will quote the &.
1936 The final delimiter is optional if it is the last character on the
1940 Repeat the previous substitution.
1943 Cause changes to be applied over the entire event line. Used in
1944 conjunction with `s', as in `gs/old/new/', or with `&'.
1947 File: features.info, Node: Command Line Editing, Next: Variable Index, Prev: Using History Interactively, Up: Top
1949 Command Line Editing
1950 ********************
1952 This chapter describes the basic features of the GNU command line
1957 * Introduction and Notation:: Notation used in this text.
1958 * Readline Interaction:: The minimum set of commands for editing a line.
1959 * Readline Init File:: Customizing Readline from a user's view.
1960 * Bindable Readline Commands:: A description of most of the Readline commands
1961 available for binding
1962 * Readline vi Mode:: A short description of how to make Readline
1963 behave like the vi editor.
1966 File: features.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
1968 Introduction to Line Editing
1969 ============================
1971 The following paragraphs describe the notation used to represent
1974 The text C-k is read as `Control-K' and describes the character
1975 produced when the Control key is depressed and the k key is struck.
1977 The text M-k is read as `Meta-K' and describes the character
1978 produced when the meta key (if you have one) is depressed, and the k
1979 key is struck. If you do not have a meta key, the identical keystroke
1980 can be generated by typing ESC first, and then typing k. Either
1981 process is known as "metafying" the k key.
1983 The text M-C-k is read as `Meta-Control-k' and describes the
1984 character produced by "metafying" C-k.
1986 In addition, several keys have their own names. Specifically, DEL,
1987 ESC, LFD, SPC, RET, and TAB all stand for themselves when seen in this
1988 text, or in an init file (*note Readline Init File::., for more info).
1991 File: features.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
1993 Readline Interaction
1994 ====================
1996 Often during an interactive session you type in a long line of text,
1997 only to notice that the first word on the line is misspelled. The
1998 Readline library gives you a set of commands for manipulating the text
1999 as you type it in, allowing you to just fix your typo, and not forcing
2000 you to retype the majority of the line. Using these editing commands,
2001 you move the cursor to the place that needs correction, and delete or
2002 insert the text of the corrections. Then, when you are satisfied with
2003 the line, you simply press RETURN. You do not have to be at the end of
2004 the line to press RETURN; the entire line is accepted regardless of the
2005 location of the cursor within the line.
2009 * Readline Bare Essentials:: The least you need to know about Readline.
2010 * Readline Movement Commands:: Moving about the input line.
2011 * Readline Killing Commands:: How to delete text, and how to get it back!
2012 * Readline Arguments:: Giving numeric arguments to commands.
2015 File: features.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
2017 Readline Bare Essentials
2018 ------------------------
2020 In order to enter characters into the line, simply type them. The
2021 typed character appears where the cursor was, and then the cursor moves
2022 one space to the right. If you mistype a character, you can use your
2023 erase character to back up and delete the mistyped character.
2025 Sometimes you may miss typing a character that you wanted to type,
2026 and not notice your error until you have typed several other
2027 characters. In that case, you can type C-b to move the cursor to the
2028 left, and then correct your mistake. Afterwards, you can move the
2029 cursor to the right with C-f.
2031 When you add text in the middle of a line, you will notice that
2032 characters to the right of the cursor are `pushed over' to make room
2033 for the text that you have inserted. Likewise, when you delete text
2034 behind the cursor, characters to the right of the cursor are `pulled
2035 back' to fill in the blank space created by the removal of the text. A
2036 list of the basic bare essentials for editing the text of an input line
2040 Move back one character.
2043 Move forward one character.
2046 Delete the character to the left of the cursor.
2049 Delete the character underneath the cursor.
2052 Insert the character into the line at the cursor.
2055 Undo the last thing that you did. You can undo all the way back
2059 File: features.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
2061 Readline Movement Commands
2062 --------------------------
2064 The above table describes the most basic possible keystrokes that
2065 you need in order to do editing of the input line. For your
2066 convenience, many other commands have been added in addition to C-b,
2067 C-f, C-d, and DEL. Here are some commands for moving more rapidly
2071 Move to the start of the line.
2074 Move to the end of the line.
2077 Move forward a word.
2080 Move backward a word.
2083 Clear the screen, reprinting the current line at the top.
2085 Notice how C-f moves forward a character, while M-f moves forward a
2086 word. It is a loose convention that control keystrokes operate on
2087 characters while meta keystrokes operate on words.
2090 File: features.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
2092 Readline Killing Commands
2093 -------------------------
2095 "Killing" text means to delete the text from the line, but to save
2096 it away for later use, usually by "yanking" (re-inserting) it back into
2097 the line. If the description for a command says that it `kills' text,
2098 then you can be sure that you can get the text back in a different (or
2099 the same) place later.
2101 When you use a kill command, the text is saved in a "kill-ring".
2102 Any number of consecutive kills save all of the killed text together, so
2103 that when you yank it back, you get it all. The kill ring is not line
2104 specific; the text that you killed on a previously typed line is
2105 available to be yanked back later, when you are typing another line.
2107 Here is the list of commands for killing text.
2110 Kill the text from the current cursor position to the end of the
2114 Kill from the cursor to the end of the current word, or if between
2115 words, to the end of the next word.
2118 Kill from the cursor the start of the previous word, or if between
2119 words, to the start of the previous word.
2122 Kill from the cursor to the previous whitespace. This is
2123 different than M-DEL because the word boundaries differ.
2125 And, here is how to "yank" the text back into the line. Yanking
2126 means to copy the most-recently-killed text from the kill buffer.
2129 Yank the most recently killed text back into the buffer at the
2133 Rotate the kill-ring, and yank the new top. You can only do this
2134 if the prior command is C-y or M-y.
2137 File: features.info, Node: Readline Arguments, Prev: Readline Killing Commands, Up: Readline Interaction
2142 You can pass numeric arguments to Readline commands. Sometimes the
2143 argument acts as a repeat count, other times it is the sign of the
2144 argument that is significant. If you pass a negative argument to a
2145 command which normally acts in a forward direction, that command will
2146 act in a backward direction. For example, to kill text back to the
2147 start of the line, you might type M- C-k.
2149 The general way to pass numeric arguments to a command is to type
2150 meta digits before the command. If the first `digit' you type is a
2151 minus sign (-), then the sign of the argument will be negative. Once
2152 you have typed one meta digit to get the argument started, you can type
2153 the remainder of the digits, and then the command. For example, to give
2154 the C-d command an argument of 10, you could type M-1 0 C-d.
2157 File: features.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
2162 Although the Readline library comes with a set of Emacs-like
2163 keybindings installed by default, it is possible that you would like to
2164 use a different set of keybindings. You can customize programs that
2165 use Readline by putting commands in an "init" file in your home
2166 directory. The name of this file is taken from the value of the shell
2167 variable `INPUTRC'. If that variable is unset, the default is
2170 When a program which uses the Readline library starts up, the init
2171 file is read, and the key bindings are set.
2173 In addition, the `C-x C-r' command re-reads this init file, thus
2174 incorporating any changes that you might have made to it.
2178 * Readline Init Syntax:: Syntax for the commands in the inputrc file.
2179 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
2182 File: features.info, Node: Readline Init Syntax, Next: Conditional Init Constructs, Up: Readline Init File
2184 Readline Init Syntax
2185 --------------------
2187 There are only a few basic constructs allowed in the Readline init
2188 file. Blank lines are ignored. Lines beginning with a # are comments.
2189 Lines beginning with a $ indicate conditional constructs (*note
2190 Conditional Init Constructs::.). Other lines denote variable settings
2194 You can change the state of a few variables in Readline by using
2195 the `set' command within the init file. Here is how you would
2196 specify that you wish to use `vi' line editing commands:
2200 Right now, there are only a few variables which can be set; so
2201 few, in fact, that we just list them here:
2204 The `editing-mode' variable controls which editing mode you
2205 are using. By default, Readline starts up in Emacs editing
2206 mode, where the keystrokes are most similar to Emacs. This
2207 variable can be set to either `emacs' or `vi'.
2209 `horizontal-scroll-mode'
2210 This variable can be set to either `On' or `Off'. Setting it
2211 to `On' means that the text of the lines that you edit will
2212 scroll horizontally on a single screen line when they are
2213 longer than the width of the screen, instead of wrapping onto
2214 a new screen line. By default, this variable is set to `Off'.
2216 `mark-modified-lines'
2217 This variable, when set to `On', says to display an asterisk
2218 (`*') at the start of history lines which have been modified.
2219 This variable is `off' by default.
2222 Controls what happens when Readline wants to ring the
2223 terminal bell. If set to `none', Readline never rings the
2224 bell. If set to `visible', Readline uses a visible bell if
2225 one is available. If set to `audible' (the default),
2226 Readline attempts to ring the terminal's bell.
2229 The string to insert at the beginning of the line when the
2230 `vi-comment' command is executed. The default value is `"#"'.
2233 If set to `on', Readline will enable eight-bit input (it will
2234 not strip the eighth bit from the characters it reads),
2235 regardless of what the terminal claims it can support. The
2236 default value is `off'.
2239 If set to `on', Readline will convert characters with the
2240 eigth bit set to an ASCII key sequence by stripping the eigth
2241 bit and prepending an ESC character, converting them to a
2242 meta-prefixed key sequence. The default value is `on'.
2245 If set to `on', Readline will display characters with the
2246 eighth bit set directly rather than as a meta-prefixed escape
2247 sequence. The default is `off'.
2249 `completion-query-items'
2250 The number of possible completions that determines when the
2251 user is asked whether he wants to see the list of
2252 possibilities. If the number of possible completions is
2253 greater than this value, Readline will ask the user whether
2254 or not he wishes to view them; otherwise, they are simply
2255 listed. The default limit is `100'.
2258 Sets Readline's idea of the current keymap for key binding
2259 commands. Acceptable `keymap' names are `emacs',
2260 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
2261 `vi-command', and `vi-insert'. `vi' is equivalent to
2262 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
2263 default value is `emacs'. The value of the `editing-mode'
2264 variable also affects the default keymap.
2266 `show-all-if-ambiguous'
2267 This alters the default behavior of the completion functions.
2268 If set to `on', words which have more than one possible
2269 completion cause the matches to be listed immediately instead
2270 of ringing the bell. The default value is `off'.
2273 If set to `on', tilde expansion is performed when Readline
2274 attempts word completion. The default is `off'.
2277 The syntax for controlling key bindings in the init file is
2278 simple. First you have to know the name of the command that you
2279 want to change. The following pages contain tables of the command
2280 name, the default keybinding, and a short description of what the
2283 Once you know the name of the command, simply place the name of
2284 the key you wish to bind the command to, a colon, and then the
2285 name of the command on a line in the init file. The name of the
2286 key can be expressed in different ways, depending on which is most
2287 comfortable for you.
2289 KEYNAME: FUNCTION-NAME or MACRO
2290 KEYNAME is the name of a key spelled out in English. For
2292 Control-u: universal-argument
2293 Meta-Rubout: backward-kill-word
2294 Control-o: ">&output"
2296 In the above example, `C-u' is bound to the function
2297 `universal-argument', and `C-o' is bound to run the macro
2298 expressed on the right hand side (that is, to insert the text
2299 `>&output' into the line).
2301 "KEYSEQ": FUNCTION-NAME or MACRO
2302 KEYSEQ differs from KEYNAME above in that strings denoting an
2303 entire key sequence can be specified, by placing the key
2304 sequence in double quotes. Some GNU Emacs style key escapes
2305 can be used, as in the following example, but the special
2306 character names are not recognized.
2308 "\C-u": universal-argument
2309 "\C-x\C-r": re-read-init-file
2310 "\e[11~": "Function Key 1"
2312 In the above example, `C-u' is bound to the function
2313 `universal-argument' (just as it was in the first example),
2314 `C-x C-r' is bound to the function `re-read-init-file', and
2315 `ESC [ 1 1 ~' is bound to insert the text `Function Key 1'.
2316 The following escape sequences are available when specifying
2337 When entering the text of a macro, single or double quotes
2338 should be used to indicate a macro definition. Unquoted text
2339 is assumed to be a function name. Backslash will quote any
2340 character in the macro text, including " and '. For example,
2341 the following binding will make `C-x \' insert a single \
2346 File: features.info, Node: Conditional Init Constructs, Prev: Readline Init Syntax, Up: Readline Init File
2348 Conditional Init Constructs
2349 ---------------------------
2351 Readline implements a facility similar in spirit to the conditional
2352 compilation features of the C preprocessor which allows key bindings
2353 and variable settings to be performed as the result of tests. There
2354 are three parser directives used.
2357 The `$if' construct allows bindings to be made based on the
2358 editing mode, the terminal being used, or the application using
2359 Readline. The text of the test extends to the end of the line; no
2360 characters are required to isolate it.
2363 The `mode=' form of the `$if' directive is used to test
2364 whether Readline is in `emacs' or `vi' mode. This may be
2365 used in conjunction with the `set keymap' command, for
2366 instance, to set bindings in the `emacs-standard' and
2367 `emacs-ctlx' keymaps only if Readline is starting out in
2371 The `term=' form may be used to include terminal-specific key
2372 bindings, perhaps to bind the key sequences output by the
2373 terminal's function keys. The word on the right side of the
2374 `=' is tested against the full name of the terminal and the
2375 portion of the terminal name before the first `-'. This
2376 allows SUN to match both SUN and SUN-CMD, for instance.
2379 The APPLICATION construct is used to include
2380 application-specific settings. Each program using the
2381 Readline library sets the APPLICATION NAME, and you can test
2382 for it. This could be used to bind key sequences to
2383 functions useful for a specific program. For instance, the
2384 following command adds a key sequence that quotes the current
2385 or previous word in Bash:
2387 # Quote the current or previous word
2388 "\C-xq": "\eb\"\ef\""
2392 This command, as you saw in the previous example, terminates an
2396 Commands in this branch of the `$if' directive are executed if the
2400 File: features.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
2402 Bindable Readline Commands
2403 ==========================
2407 * Commands For Moving:: Moving about the line.
2408 * Commands For History:: Getting at previous lines.
2409 * Commands For Text:: Commands for changing text.
2410 * Commands For Killing:: Commands for killing and yanking.
2411 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
2412 * Commands For Completion:: Getting Readline to do the typing for you.
2413 * Keyboard Macros:: Saving and re-executing typed characters
2414 * Miscellaneous Commands:: Other miscellaneous commands.
2417 File: features.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
2422 `beginning-of-line (C-a)'
2423 Move to the start of the current line.
2426 Move to the end of the line.
2428 `forward-char (C-f)'
2429 Move forward a character.
2431 `backward-char (C-b)'
2432 Move back a character.
2434 `forward-word (M-f)'
2435 Move forward to the end of the next word. Words are composed of
2438 `backward-word (M-b)'
2439 Move back to the start of this, or the previous, word. Words are
2440 composed of letters and digits.
2442 `clear-screen (C-l)'
2443 Clear the screen and redraw the current line, leaving the current
2444 line at the top of the screen.
2446 `redraw-current-line ()'
2447 Refresh the current line. By default, this is unbound.
2450 File: features.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
2452 Commands For Manipulating The History
2453 -------------------------------------
2455 `accept-line (Newline, Return)'
2456 Accept the line regardless of where the cursor is. If this line is
2457 non-empty, add it to the history list according to the setting of
2458 the `HISTCONTROL' variable. If this line was a history line, then
2459 restore the history line to its original state.
2461 `previous-history (C-p)'
2462 Move `up' through the history list.
2464 `next-history (C-n)'
2465 Move `down' through the history list.
2467 `beginning-of-history (M-<)'
2468 Move to the first line in the history.
2470 `end-of-history (M->)'
2471 Move to the end of the input history, i.e., the line you are
2474 `reverse-search-history (C-r)'
2475 Search backward starting at the current line and moving `up'
2476 through the history as necessary. This is an incremental search.
2478 `forward-search-history (C-s)'
2479 Search forward starting at the current line and moving `down'
2480 through the the history as necessary. This is an incremental
2483 `non-incremental-reverse-search-history (M-p)'
2484 Search backward starting at the current line and moving `up'
2485 through the history as necessary using a non-incremental search
2486 for a string supplied by the user.
2488 `non-incremental-forward-search-history (M-n)'
2489 Search forward starting at the current line and moving `down'
2490 through the the history as necessary using a non-incremental search
2491 for a string supplied by the user.
2493 `history-search-forward ()'
2494 Search forward through the history for the string of characters
2495 between the start of the current line and the current point. This
2496 is a non-incremental search. By default, this command is unbound.
2498 `history-search-backward ()'
2499 Search backward through the history for the string of characters
2500 between the start of the current line and the current point. This
2501 is a non-incremental search. By default, this command is unbound.
2503 `yank-nth-arg (M-C-y)'
2504 Insert the first argument to the previous command (usually the
2505 second word on the previous line). With an argument N, insert the
2506 Nth word from the previous command (the words in the previous
2507 command begin with word 0). A negative argument inserts the Nth
2508 word from the end of the previous command.
2510 `yank-last-arg (M-., M-_)'
2511 Insert last argument to the previous command (the last word on the
2512 previous line). With an argument, behave exactly like
2516 File: features.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
2518 Commands For Changing Text
2519 --------------------------
2522 Delete the character under the cursor. If the cursor is at the
2523 beginning of the line, there are no characters in the line, and
2524 the last character typed was not C-d, then return EOF.
2526 `backward-delete-char (Rubout)'
2527 Delete the character behind the cursor. A numeric arg says to kill
2528 the characters instead of deleting them.
2530 `quoted-insert (C-q, C-v)'
2531 Add the next character that you type to the line verbatim. This is
2532 how to insert key sequences like C-q, for example.
2534 `tab-insert (M-TAB)'
2535 Insert a tab character.
2537 `self-insert (a, b, A, 1, !, ...)'
2540 `transpose-chars (C-t)'
2541 Drag the character before the cursor forward over the character at
2542 the cursor, moving the cursor forward as well. If the insertion
2543 point is at the end of the line, then this transposes the last two
2544 characters of the line. Negative argumentss don't work.
2546 `transpose-words (M-t)'
2547 Drag the word behind the cursor past the word in front of the
2548 cursor moving the cursor over that word as well.
2551 Uppercase the current (or following) word. With a negative
2552 argument, do the previous word, but do not move the cursor.
2554 `downcase-word (M-l)'
2555 Lowercase the current (or following) word. With a negative
2556 argument, do the previous word, but do not move the cursor.
2558 `capitalize-word (M-c)'
2559 Capitalize the current (or following) word. With a negative
2560 argument, do the previous word, but do not move the cursor.
2563 File: features.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
2569 Kill the text from the current cursor position to the end of the
2572 `backward-kill-line (C-x Rubout)'
2573 Kill backward to the beginning of the line.
2575 `unix-line-discard (C-u)'
2576 Kill backward from the cursor to the beginning of the current line.
2577 Save the killed text on the kill-ring.
2579 `kill-whole-line ()'
2580 Kill all characters on the current line, no matter where the
2581 cursor is. By default, this is unbound.
2584 Kill from the cursor to the end of the current word, or if between
2585 words, to the end of the next word. Word boundaries are the same
2588 `backward-kill-word (M-DEL)'
2589 Kill the word behind the cursor. Word boundaries are the same as
2592 `unix-word-rubout (C-w)'
2593 Kill the word behind the cursor, using white space as a word
2594 boundary. The killed text is saved on the kill-ring.
2596 `delete-horizontal-space ()'
2597 Delete all spaces and tabs around point. By default, this is
2601 Yank the top of the kill ring into the buffer at the current
2605 Rotate the kill-ring, and yank the new top. You can only do this
2606 if the prior command is yank or yank-pop.
2609 File: features.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
2611 Specifying Numeric Arguments
2612 ----------------------------
2614 `digit-argument (M-0, M-1, ... M--)'
2615 Add this digit to the argument already accumulating, or start a new
2616 argument. M- starts a negative argument.
2618 `universal-argument ()'
2619 Each time this is executed, the argument count is multiplied by
2620 four. The argument count is initially one, so executing this
2621 function the first time makes the argument count four. By
2622 default, this is not bound to a key.
2625 File: features.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
2627 Letting Readline Type For You
2628 -----------------------------
2631 Attempt to do completion on the text before the cursor. This is
2632 application-specific. Generally, if you are typing a filename
2633 argument, you can do filename completion; if you are typing a
2634 command, you can do command completion, if you are typing in a
2635 symbol to GDB, you can do symbol name completion, if you are
2636 typing in a variable to Bash, you can do variable name completion,
2637 and so on. See the Bash manual page for a complete list of
2638 available completion functions.
2640 `possible-completions (M-?)'
2641 List the possible completions of the text before the cursor.
2643 `insert-completions ()'
2644 Insert all completions of the text before point that would have
2645 been generated by `possible-completions'. By default, this is not
2649 File: features.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
2654 `start-kbd-macro (C-x ()'
2655 Begin saving the characters typed into the current keyboard macro.
2657 `end-kbd-macro (C-x ))'
2658 Stop saving the characters typed into the current keyboard macro
2659 and save the definition.
2661 `call-last-kbd-macro (C-x e)'
2662 Re-execute the last keyboard macro defined, by making the
2663 characters in the macro appear as if typed at the keyboard.
2666 File: features.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
2668 Some Miscellaneous Commands
2669 ---------------------------
2671 `re-read-init-file (C-x C-r)'
2672 Read in the contents of your init file, and incorporate any
2673 bindings or variable assignments found there.
2676 Abort the current editing command and ring the terminal's bell
2677 (subject to the setting of `bell-style').
2679 `do-uppercase-version (M-a, M-b, ...)'
2680 Run the command that is bound to the corresoponding uppercase
2684 Make the next character that you type be metafied. This is for
2685 people without a meta key. Typing `ESC f' is equivalent to typing
2688 `undo (C-_, C-x C-u)'
2689 Incremental undo, separately remembered for each line.
2692 Undo all changes made to this line. This is like typing the `undo'
2693 command enough times to get back to the beginning.
2695 `tilde-expand (M-~)'
2696 Perform tilde expansion on the current word.
2699 Print all of the functions and their key bindings to the readline
2700 output stream. If a numeric argument is supplied, the output is
2701 formatted in such a way that it can be made part of an INPUTRC
2704 `display-shell-version (C-x C-v)'
2705 Display version information about the current instance of Bash.
2707 `shell-expand-line (M-C-e)'
2708 Expand the line the way the shell does when it reads it. This
2709 performs alias and history expansion as well as all of the shell
2712 `history-expand-line (M-^)'
2713 Perform history expansion on the current line.
2715 `insert-last-argument (M-., M-_)'
2716 A synonym for `yank-last-arg'.
2718 `operate-and-get-next (C-o)'
2719 Accept the current line for execution and fetch the next line
2720 relative to the current line from the history for editing. Any
2721 argument is ignored.
2723 `emacs-editing-mode (C-e)'
2724 When in `vi' editing mode, this causes a switch back to emacs
2725 editing mode, as if the command `set -o emacs' had been executed.
2728 File: features.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
2733 While the Readline library does not have a full set of `vi' editing
2734 functions, it does contain enough to allow simple editing of the line.
2735 The Readline `vi' mode behaves as specified in the Posix 1003.2
2738 In order to switch interactively between `Emacs' and `Vi' editing
2739 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
2740 Builtin::.). The Readline default is `emacs' mode.
2742 When you enter a line in `vi' mode, you are already placed in
2743 `insertion' mode, as if you had typed an `i'. Pressing ESC switches
2744 you into `command' mode, where you can edit the text of the line with
2745 the standard `vi' movement keys, move to previous history lines with
2746 `k', and following lines with `j', and so forth.
2749 File: features.info, Node: Variable Index, Next: Concept Index, Prev: Command Line Editing, Up: Top
2756 * auto_resume: Job Control Variables.
2757 * BASH_VERSION: Bash Variables.
2758 * bell-style: Readline Init Syntax.
2759 * cdable_vars: C Shell Variables.
2760 * CDPATH: Bourne Shell Variables.
2761 * comment-begin: Readline Init Syntax.
2762 * completion-query-items: Readline Init Syntax.
2763 * convert-meta: Readline Init Syntax.
2764 * editing-mode: Readline Init Syntax.
2765 * EUID: Bash Variables.
2766 * expand-tilde: Readline Init Syntax.
2767 * FIGNORE: Bash Variables.
2768 * histchars: Bash Variables.
2769 * HISTCMD: Bash Variables.
2770 * HISTCONTROL: Bash Variables.
2771 * HISTFILE: Bash Variables.
2772 * history_control: Bash Variables.
2773 * HISTSIZE: Bash Variables.
2774 * HOME: Bourne Shell Variables.
2775 * horizontal-scroll-mode: Readline Init Syntax.
2776 * HOSTFILE: Bash Variables.
2777 * hostname_completion_file: Bash Variables.
2778 * HOSTTYPE: Bash Variables.
2779 * IFS: Bourne Shell Variables.
2780 * IGNOREEOF: C Shell Variables.
2781 * IGNOREEOF: Bash Variables.
2782 * INPUTRC: Bash Variables.
2783 * keymap: Readline Init Syntax.
2784 * MAILCHECK: Bash Variables.
2785 * MAILPATH: Bourne Shell Variables.
2786 * mark-modified-lines: Readline Init Syntax.
2787 * meta-flag: Readline Init Syntax.
2788 * nolinks: Bash Variables.
2789 * notify: Job Control Variables.
2790 * no_exit_on_failed_exec: Bash Variables.
2791 * OLDPWD: Korn Shell Variables.
2792 * OPTARG: Bourne Shell Variables.
2793 * OPTIND: Bourne Shell Variables.
2794 * OSTYPE: Bash Variables.
2795 * output-meta: Readline Init Syntax.
2796 * PATH: Bourne Shell Variables.
2797 * PROMPT_COMMAND: Bash Variables.
2798 * PS1: Bourne Shell Variables.
2799 * PS2: Bourne Shell Variables.
2800 * PS3: Korn Shell Variables.
2801 * PS4: Korn Shell Variables.
2802 * PWD: Korn Shell Variables.
2803 * RANDOM: Korn Shell Variables.
2804 * REPLY: Korn Shell Variables.
2805 * SECONDS: Korn Shell Variables.
2806 * show-all-if-ambiguous: Readline Init Syntax.
2807 * TMOUT: Korn Shell Variables.
2808 * UID: Bash Variables.
2811 File: features.info, Node: Concept Index, Prev: Variable Index, Up: Top
2818 * $else: Conditional Init Constructs.
2819 * $endif: Conditional Init Constructs.
2820 * $if: Conditional Init Constructs.
2821 * .: Bourne Shell Builtins.
2822 * :: Bourne Shell Builtins.
2823 * abort (C-g): Miscellaneous Commands.
2824 * accept-line (Newline, Return): Commands For History.
2825 * alias: Alias Builtins.
2826 * backward-char (C-b): Commands For Moving.
2827 * backward-delete-char (Rubout): Commands For Text.
2828 * backward-kill-line (C-x Rubout): Commands For Killing.
2829 * backward-kill-word (M-DEL): Commands For Killing.
2830 * backward-word (M-b): Commands For Moving.
2831 * beginning-of-history (M-<): Commands For History.
2832 * beginning-of-line (C-a): Commands For Moving.
2833 * bg: Job Control Builtins.
2834 * bind: Bash Builtins.
2835 * break: Bourne Shell Builtins.
2836 * builtin: Bash Builtins.
2837 * call-last-kbd-macro (C-x e): Keyboard Macros.
2838 * capitalize-word (M-c): Commands For Text.
2839 * case: Conditional Constructs.
2840 * cd: Bourne Shell Builtins.
2841 * clear-screen (C-l): Commands For Moving.
2842 * command: Bash Builtins.
2843 * complete (TAB): Commands For Completion.
2844 * continue: Bourne Shell Builtins.
2845 * declare: Bash Builtins.
2846 * delete-char (C-d): Commands For Text.
2847 * delete-horizontal-space (): Commands For Killing.
2848 * digit-argument (M-0, M-1, ... M-): Numeric Arguments.
2849 * dirs: C Shell Builtins.
2850 * do-uppercase-version (M-a, M-b, ...): Miscellaneous Commands.
2851 * downcase-word (M-l): Commands For Text.
2852 * dump-functions (): Miscellaneous Commands.
2853 * echo: Bourne Shell Builtins.
2854 * enable: Bash Builtins.
2855 * end-kbd-macro (C-x )): Keyboard Macros.
2856 * end-of-history (M->): Commands For History.
2857 * end-of-line (C-e): Commands For Moving.
2858 * eval: Bourne Shell Builtins.
2859 * event designators: Event Designators.
2860 * exec: Bourne Shell Builtins.
2861 * exit: Bourne Shell Builtins.
2862 * expansion: History Interaction.
2863 * export: Bourne Shell Builtins.
2864 * fc: Korn Shell Builtins.
2865 * fg: Job Control Builtins.
2866 * for: Looping Constructs.
2867 * forward-char (C-f): Commands For Moving.
2868 * forward-search-history (C-s): Commands For History.
2869 * forward-word (M-f): Commands For Moving.
2870 * getopts: Bourne Shell Builtins.
2871 * hash: Bourne Shell Builtins.
2872 * help: Bash Builtins.
2873 * history: C Shell Builtins.
2874 * history events: Event Designators.
2875 * History, how to use: Job Control Variables.
2876 * history-search-backward (): Commands For History.
2877 * history-search-forward (): Commands For History.
2878 * if: Conditional Constructs.
2879 * insert-completions (): Commands For Completion.
2880 * interaction, readline: Readline Interaction.
2881 * jobs: Job Control Builtins.
2882 * kill: Bourne Shell Builtins.
2883 * Kill ring: Readline Killing Commands.
2884 * kill-line (C-k): Commands For Killing.
2885 * kill-whole-line (): Commands For Killing.
2886 * kill-word (M-d): Commands For Killing.
2887 * Killing text: Readline Killing Commands.
2888 * let: Korn Shell Builtins.
2889 * let: Arithmetic Builtins.
2890 * local: Bash Builtins.
2891 * logout: C Shell Builtins.
2892 * next-history (C-n): Commands For History.
2893 * non-incremental-forward-search-history (M-n): Commands For History.
2894 * non-incremental-reverse-search-history (M-p): Commands For History.
2895 * popd: C Shell Builtins.
2896 * possible-completions (M-?): Commands For Completion.
2897 * prefix-meta (ESC): Miscellaneous Commands.
2898 * previous-history (C-p): Commands For History.
2899 * pushd: C Shell Builtins.
2900 * pwd: Bourne Shell Builtins.
2901 * quoted-insert (C-q, C-v): Commands For Text.
2902 * re-read-init-file (C-x C-r): Miscellaneous Commands.
2903 * read: Bourne Shell Builtins.
2904 * Readline, how to use: Modifiers.
2905 * readonly: Bourne Shell Builtins.
2906 * redraw-current-line (): Commands For Moving.
2907 * return: Bourne Shell Builtins.
2908 * reverse-search-history (C-r): Commands For History.
2909 * revert-line (M-r): Miscellaneous Commands.
2910 * self-insert (a, b, A, 1, !, ...): Commands For Text.
2911 * set: The Set Builtin.
2912 * shift: Bourne Shell Builtins.
2913 * source: C Shell Builtins.
2914 * start-kbd-macro (C-x (): Keyboard Macros.
2915 * suspend: Job Control Builtins.
2916 * tab-insert (M-TAB): Commands For Text.
2917 * test: Bourne Shell Builtins.
2918 * tilde-expand (M-~): Miscellaneous Commands.
2919 * times: Bourne Shell Builtins.
2920 * transpose-chars (C-t): Commands For Text.
2921 * transpose-words (M-t): Commands For Text.
2922 * trap: Bourne Shell Builtins.
2923 * type: Bash Builtins.
2924 * typeset: Korn Shell Builtins.
2925 * ulimit: Bash Builtins.
2926 * umask: Bourne Shell Builtins.
2927 * unalias: Alias Builtins.
2928 * undo (C-_, C-x C-u): Miscellaneous Commands.
2929 * universal-argument (): Numeric Arguments.
2930 * unix-line-discard (C-u): Commands For Killing.
2931 * unix-word-rubout (C-w): Commands For Killing.
2932 * unset: Bourne Shell Builtins.
2933 * until: Looping Constructs.
2934 * upcase-word (M-u): Commands For Text.
2935 * wait: Bourne Shell Builtins.
2936 * while: Looping Constructs.
2937 * yank (C-y): Commands For Killing.
2938 * yank-last-arg (M-., M-_): Commands For History.
2939 * yank-nth-arg (M-C-y): Commands For History.
2940 * yank-pop (M-y): Commands For Killing.
2941 * Yanking text: Readline Killing Commands.
2942 * [: Bourne Shell Builtins.
2948 Node: Bourne Shell Features
\7f2405
2949 Node: Looping Constructs
\7f3579
2950 Node: Conditional Constructs
\7f4634
2951 Node: Shell Functions
\7f6194
2952 Node: Bourne Shell Builtins
\7f7567
2953 Node: Bourne Shell Variables
\7f9766
2954 Node: Other Bourne Shell Features
\7f11025
2955 Node: Major Differences from the Bourne Shell
\7f11783
2956 Node: Csh Features
\7f14194
2957 Node: Tilde Expansion
\7f15087
2958 Node: Brace Expansion
\7f15691
2959 Node: C Shell Builtins
\7f17283
2960 Node: C Shell Variables
\7f20578
2961 Node: Korn Shell Features
\7f21088
2962 Node: Korn Shell Constructs
\7f21826
2963 Node: Korn Shell Builtins
\7f23037
2964 Node: Korn Shell Variables
\7f25190
2965 Node: Aliases
\7f26466
2966 Node: Alias Builtins
\7f28833
2967 Node: Bash Specific Features
\7f29356
2968 Node: Invoking Bash
\7f30085
2969 Node: Bash Startup Files
\7f32404
2970 Node: Is This Shell Interactive?
\7f34247
2971 Node: Bash Builtins
\7f35055
2972 Node: The Set Builtin
\7f41437
2973 Node: Bash Variables
\7f46377
2974 Node: Shell Arithmetic
\7f50945
2975 Node: Arithmetic Evaluation
\7f51307
2976 Node: Arithmetic Expansion
\7f53028
2977 Node: Arithmetic Builtins
\7f53862
2978 Node: Printing a Prompt
\7f54334
2979 Node: Job Control
\7f55599
2980 Node: Job Control Basics
\7f56074
2981 Node: Job Control Builtins
\7f60249
2982 Node: Job Control Variables
\7f61768
2983 Node: Using History Interactively
\7f63077
2984 Node: History Interaction
\7f63584
2985 Node: Event Designators
\7f64630
2986 Node: Word Designators
\7f65461
2987 Node: Modifiers
\7f66446
2988 Node: Command Line Editing
\7f67755
2989 Node: Introduction and Notation
\7f68415
2990 Node: Readline Interaction
\7f69435
2991 Node: Readline Bare Essentials
\7f70574
2992 Node: Readline Movement Commands
\7f72104
2993 Node: Readline Killing Commands
\7f72995
2994 Node: Readline Arguments
\7f74698
2995 Node: Readline Init File
\7f75649
2996 Node: Readline Init Syntax
\7f76647
2997 Node: Conditional Init Constructs
\7f83580
2998 Node: Bindable Readline Commands
\7f85826
2999 Node: Commands For Moving
\7f86496
3000 Node: Commands For History
\7f87344
3001 Node: Commands For Text
\7f89988
3002 Node: Commands For Killing
\7f91727
3003 Node: Numeric Arguments
\7f93176
3004 Node: Commands For Completion
\7f93803
3005 Node: Keyboard Macros
\7f94816
3006 Node: Miscellaneous Commands
\7f95375
3007 Node: Readline vi Mode
\7f97466
3008 Node: Variable Index
\7f98343
3009 Node: Concept Index
\7f101671