neulab/tldr huggingface dataset:
2.     The words that are not variable assignments or redirections are expanded.  If any words remain after expansion, the first word is taken to be the name of the command and the remaining words are the arguments.
3.     Redirections are performed as described above under REDIRECTION.
4.     The text after the = in each variable assignment undergoes tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal before being assigned to the variable.
If no command name results, the variable assignments affect the current shell environment.  Otherwise, the variables are added to the environment of the executed command and do not affect the current shell environment. If any of the assignments attempts to assign a value to a readonly variable, an error occurs, and the command exits with a non-zero status.
If no command name results, redirections are performed, but do not affect the current shell environment.  A redirection error causes the command to exit with a non-zero status.
If there is a command name left after expansion, execution proceeds as described below.  Otherwise, the command exits.  If one of the expansions contained a command substitution, the exit status of the command is the exit status of the last command substitution performed.  If there were no command substitutions, the command exits with a status of zero.
After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.
If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is invoked as described above in FUNCTIONS.  If the name does not match a function, the shell searches for it in the list of shell builtins.  If a match is found, that builtin is invoked.
If the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for a directory containing an executable file by that name.  Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below).  A full search of the directories in PATH is performed only if the command is not found in the hash table.  If the search is unsuccessful, the shell searches for a defined shell function named command_not_found_handle.  If that function exists, it is invoked in a separate execution environment with the original command and the original command's arguments as its arguments, and the function's exit status becomes the exit status of that subshell.  If that function is not defined, the shell prints an error message and returns an exit status of 127.
If the search is successful, or if the command name contains one or more slashes, the shell executes the named program in a separate execution environment.  Argument 0 is set to the name given, and the remaining arguments to the command are set to the arguments given, if any.
If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script, a file containing shell commands.  A subshell is spawned to execute it.  This subshell reinitializes itself, so that the effect is as if a new shell had been invoked to handle the script, with the exception that the locations of commands remembered by the parent (see hash below under SHELL BUILTIN COMMANDS) are retained by the child.
If the program is a file beginning with #!, the remainder of the first line specifies an interpreter for the program.  The shell executes the specified interpreter on operating systems that do not handle this executable format themselves.  The arguments to the interpreter consist of a single optional argument following the interpreter name on the first line of the program, followed by the name of the program, followed by the command arguments, if any.
The shell has an execution environment, which consists of the following:
•      open files inherited by the shell at invocation, as modified by redirections supplied to the exec builtin
•      the current working directory as set by cd, pushd, or popd, or inherited by the shell at invocation
•      the file creation mode mask as set by umask or inherited from the shell's parent
•      current traps set by trap
•      shell parameters that are set by variable assignment or with set or inherited from the shell's parent in the environment
•      shell functions defined during execution or inherited from the shell's parent in the environment
•      options enabled at invocation (either by default or with command- line arguments) or by set
•      options enabled by shopt
•      shell aliases defined with alias
•      various process IDs, including those of background jobs, the value of $$, and the value of PPID
When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of the following.  Unless otherwise noted, the values are inherited from the shell.
•      the shell's open files, plus any modifications and additions specified by redirections to the command
•      the current working directory
•      the file creation mode mask
•      shell variables and functions marked for export, along with variables exported for the command, passed in the environment
•      traps caught by the shell are reset to the values inherited from the shell's parent, and traps ignored by the shell are ignored
A command invoked in this separate environment cannot affect the shell's execution environment.
Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are reset to the values that the shell inherited from its parent at invocation.  Builtin commands that are invoked as part of a pipeline are also executed in a subshell environment.  Changes made to the subshell environment cannot affect the shell's execution environment.
Subshells spawned to execute command substitutions inherit the value of the -e option from the parent shell.  When not in posix mode, bash clears the -e option in such subshells.
If a command is followed by a & and job control is not active, the default standard input for the command is the empty file /dev/null. Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections.
When a program is invoked it is given an array of strings called the environment.  This is a list of name-value pairs, of the form name=value.
The shell provides several ways to manipulate the environment.  On invocation, the shell scans its own environment and creates a parameter for each name found, automatically marking it for export to child processes.  Executed commands inherit the environment.  The export and declare -x commands allow parameters and functions to be added to and deleted from the environment.  If the value of a parameter in the environment is modified, the new value becomes part of the environment, replacing the old.  The environment inherited by any executed command consists of the shell's initial environment, whose values may be modified in the shell, less any pairs removed by the unset command, plus any additions via the export and declare -x commands.
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in PARAMETERS.  These assignment statements affect only the environment seen by that command.
If the -k option is set (see the set builtin command below), then all parameter assignments are placed in the environment for a command, not just those that precede the command name.
When bash invokes an external command, the variable _ is set to the full filename of the command and passed to that command in its environment.
The exit status of an executed command is the value returned by the waitpid system call or equivalent function.  Exit statuses fall between 0 and 255, though, as explained below, the shell may use values above 125 specially.  Exit statuses from shell builtins and compound commands are also limited to this range.  Under certain circumstances, the shell will use special values to indicate specific failure modes.
For the shell's purposes, a command which exits with a zero exit status has succeeded.  An exit status of zero indicates success.  A non-zero exit status indicates failure.  When a command terminates on a fatal signal N, bash uses the value of 128+N as the exit status.
If a command is not found, the child process created to execute it returns a status of 127.  If a command is found but is not executable, the return status is 126.
If a command fails because of an error during expansion or redirection, the exit status is greater than zero.
Shell builtin commands return a status of 0 (true) if successful, and non-zero (false) if an error occurs while they execute.  All builtins return an exit status of 2 to indicate incorrect usage, generally invalid options or missing arguments.
Bash itself returns the exit status of the last command executed, unless a syntax error occurs, in which case it exits with a non-zero value.  See also the exit builtin command below.
When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible).  In all cases, bash ignores SIGQUIT.  If job control is in effect, bash ignores SIGTTIN, SIGTTOU, and SIGTSTP.
Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent.  When job control is not in effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers.  Commands run as a result of command substitution ignore the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.
The shell exits by default upon receipt of a SIGHUP.  Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP.  To prevent the shell from sending the signal to a particular job, it should be removed from the jobs table with the disown builtin (see SHELL BUILTIN COMMANDS below) or marked to not receive SIGHUP using disown -h.
If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all jobs when an interactive login shell exits.
If bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes.  When bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit status greater than 128, immediately after which the trap is executed.
Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point.  A user typically employs this facility via an interactive interface supplied jointly by the operating system kernel's terminal driver and bash.
The shell associates a job with each pipeline.  It keeps a table of currently executing jobs, which may be listed with the jobs command. When bash starts a job asynchronously (in the background), it prints a line that looks like:
[1] 25647
indicating that this job is job number 1 and that the process ID of the last process in the pipeline associated with this job is 25647.  All of the processes in a single pipeline are members of the same job.  Bash uses the job abstraction as the basis for job control.
To facilitate the implementation of the user interface to job control, the operating system maintains the notion of a current terminal process group ID.  Members of this process group (processes whose process group ID is equal to the current terminal process group ID) receive keyboard- generated signals such as SIGINT.  These processes are said to be in the foreground.  Background processes are those whose process group ID differs from the terminal's; such processes are immune to keyboard- generated signals.  Only foreground processes are allowed to read from or, if the user so specifies with stty tostop, write to the terminal. Background processes which attempt to read from (write to when stty tostop is in effect) the terminal are sent a SIGTTIN (SIGTTOU) signal by the kernel's terminal driver, which, unless caught, suspends the process.
If the operating system on which bash is running supports job control, bash contains facilities to use it.  Typing the suspend character (typically ^Z, Control-Z) while a process is running causes that process to be stopped and returns control to bash.  Typing the delayed suspend character (typically ^Y, Control-Y) causes the process to be stopped when it attempts to read input from the terminal, and control to be returned to bash.  The user may then manipulate the state of this job, using the bg command to continue it in the background, the fg command to continue it in the foreground, or the kill command to kill it.  A ^Z takes effect immediately, and has the additional side effect of causing pending output and typeahead to be discarded.
There are a number of ways to refer to a job in the shell.  The character % introduces a job specification (jobspec).  Job number n may be referred to as %n.  A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line.  For example, %ce refers to a stopped job whose command name begins with ce. If a prefix matches more than one job, bash reports an error.  Using %?ce, on the other hand, refers to any job containing the string ce in its command line.  If the substring matches more than one job, bash reports an error.  The symbols %% and %+ refer to the shell's notion of the current job, which is the last job stopped while it was in the foreground or started in the background.  The previous job may be referenced using %-.  If there is only a single job, %+ and %- can both be used to refer to that job.  In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -.  A single % (with no accompanying job specification) also refers to the current job.
Simply naming a job can be used to bring it into the foreground: %1 is a synonym for ``fg %1'', bringing job 1 from the background into the foreground.  Similarly, ``%1 &'' resumes job 1 in the background, equivalent to ``bg %1''.
The shell learns immediately whenever a job changes state.  Normally, bash waits until it is about to print a prompt before reporting changes in a job's status so as to not interrupt any other output.  If the -b option to the set builtin command is enabled, bash reports such changes immediately.  Any trap on SIGCHLD is executed for each child that exits.
If an attempt to exit bash is made while jobs are stopped (or, if the checkjobs shell option has been enabled using the shopt builtin, running), the shell prints a warning message, and, if the checkjobs option is enabled, lists the jobs and their statuses.  The jobs command may then be used to inspect their status.  If a second attempt to exit is made without an intervening command, the shell does not print another warning, and any stopped jobs are terminated.
When the shell is waiting for a job or process using the wait builtin, and job control is enabled, wait will return when the job changes state. The -f option causes wait to wait until the job or process terminates before returning.
When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command.  Bash displays PS0 after it reads a command but before executing it.  Bash displays PS4 as described above before tracing each command when the -x option is enabled.  Bash allows these prompt strings to be customized by inserting a number of backslash- escaped special characters that are decoded as follows: \a     an ASCII bell character (07) \d     the date in "Weekday Month Date" format (e.g., "Tue May 26") \D{format} the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required \e     an ASCII escape character (033) \h     the hostname up to the first `.' \H     the hostname \j     the number of jobs currently managed by the shell \l     the basename of the shell's terminal device name \n     newline \r     carriage return \s     the name of the shell, the basename of $0 (the portion following the final slash) \t     the current time in 24-hour HH:MM:SS format \T     the current time in 12-hour HH:MM:SS format \@     the current time in 12-hour am/pm format \A     the current time in 24-hour HH:MM format \u     the username of the current user \v     the version of bash (e.g., 2.00) \V     the release of bash, version + patch level (e.g., 2.00.0) \w     the current working directory, with $HOME abbreviated with a tilde (uses the value of the PROMPT_DIRTRIM variable) \W     the basename of the current working directory, with $HOME abbreviated with a tilde \!     the history number of this command \#     the command number of this command \$     if the effective UID is 0, a #, otherwise a $ \nnn   the character corresponding to the octal number nnn \\     a backslash \[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt \]     end a sequence of non-printing characters
The command number and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file (see HISTORY below), while the command number is the position in the sequence of commands executed during the current shell session.  After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option (see the description of the shopt command under SHELL BUILTIN COMMANDS below).  This can have unwanted side effects if escaped portions of the string appear within command substitution or contain characters special to word expansion.
This is the library that handles reading input when using an interactive shell, unless the --noediting option is given at shell invocation.  Line editing is also used when using the -e option to the read builtin.  By default, the line editing commands are similar to those of Emacs.  A vi- style line editing interface is also available.  Line editing can be enabled at any time using the -o emacs or -o vi options to the set builtin (see SHELL BUILTIN COMMANDS below).  To turn off line editing after the shell is running, use the +o emacs or +o vi options to the set builtin.
Readline Notation In this section, the Emacs-style notation is used to denote keystrokes. Control keys are denoted by C-key, e.g., C-n means Control-N.  Similarly, meta keys are denoted by M-key, so M-x means Meta-X.  (On keyboards without a meta key, M-x means ESC x, i.e., press the Escape key then the x key.  This makes ESC the meta prefix.  The combination M-C-x means ESC-Control-x, or press the Escape key then hold the Control key while pressing the x key.)
Readline commands may be given numeric arguments, which normally act as a repeat count.  Sometimes, however, it is the sign of the argument that is significant.  Passing a negative argument to a command that acts in the forward direction (e.g., kill-line) causes that command to act in a backward direction.  Commands whose behavior with arguments deviates from this are noted below.
When a command is described as killing text, the text deleted is saved for possible future retrieval (yanking).  The killed text is saved in a kill ring.  Consecutive kills cause the text to be accumulated into one unit, which can be yanked all at once.  Commands which do not kill text separate the chunks of text on the kill ring.
Readline Initialization Readline is customized by putting commands in an initialization file (the inputrc file).  The name of this file is taken from the value of the INPUTRC variable.  If that variable is unset, the default is ~/.inputrc. If that file  does not exist or cannot be read, the ultimate default is /etc/inputrc.  When a program which uses the readline library starts up, the initialization file is read, and the key bindings and variables are set.  There are only a few basic constructs allowed in the readline initialization file.  Blank lines are ignored.  Lines beginning with a # are comments.  Lines beginning with a $ indicate conditional constructs. Other lines denote key bindings and variable settings.
The default key-bindings may be changed with an inputrc file.  Other programs that use this library may add their own commands and bindings.
For example, placing
M-Control-u: universal-argument or C-Meta-u: universal-argument into the inputrc would make M-C-u execute the readline command universal-argument.
The following symbolic character names are recognized: RUBOUT, DEL, ESC, LFD, NEWLINE, RET, RETURN, SPC, SPACE, and TAB.
In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a macro).
Readline Key Bindings The syntax for controlling key bindings in the inputrc file is simple. All that is required is the name of the command or the text of a macro and a key sequence to which it should be bound.  The name may be specified in one of two ways: as a symbolic key name, possibly with Meta- or Control- prefixes, or as a key sequence.
When using the form keyname:function-name or macro, keyname is the name of a key spelled out in English.  For example:
Control-u: universal-argument Meta-Rubout: backward-kill-word Control-o: "> output"
In the above example, C-u is bound to the function universal-argument, M-DEL is bound to the function backward-kill-word, and C-o is bound to run the macro expressed on the right hand side (that is, to insert the text ``> output'' into the line).
In the second form, "keyseq":function-name or macro, keyseq differs from keyname above in that strings denoting an entire key sequence may be specified by placing the sequence within double quotes.  Some GNU Emacs style key escapes can be used, as in the following example, but the symbolic character names are not recognized.
"\C-u": universal-argument "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1"
In this example, C-u is again bound to the function universal-argument. C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~ is bound to insert the text ``Function Key 1''.
The full set of GNU Emacs style escape sequences is \C-    control prefix \M-    meta prefix \e     an escape character \\     backslash \"     literal " \'     literal '
In addition to the GNU Emacs style escape sequences, a second set of backslash escapes is available: \a     alert (bell) \b     backspace \d     delete \f     form feed \n     newline \r     carriage return \t     horizontal tab \v     vertical tab \nnn   the eight-bit character whose value is the octal value nnn (one to three digits) \xHH   the eight-bit character whose value is the hexadecimal value HH (one or two hex digits)
When entering the text of a macro, single or double quotes must be used to indicate a macro definition.  Unquoted text is assumed to be a function name.  In the macro body, the backslash escapes described above are expanded.  Backslash will quote any other character in the macro text, including " and '.
Bash allows the current readline key bindings to be displayed or modified with the bind builtin command.  The editing mode may be switched during interactive use by using the -o option to the set builtin command (see SHELL BUILTIN COMMANDS below).
Readline Variables Readline has variables that can be used to further customize its behavior.  A variable may be set in the inputrc file with a statement of the form
set variable-name value or using the bind builtin command (see SHELL BUILTIN COMMANDS below).
Except where noted, readline variables can take the values On or Off (without regard to case).  Unrecognized variable names are ignored.  When a variable value is read, empty or null values, "on" (case-insensitive), and "1" are equivalent to On.  All other values are equivalent to Off. The variables and their default values are:
Readline Conditional Constructs Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests.  There are four parser directives used.
$if    The $if construct allows bindings to be made based on the editing mode, the terminal being used, or the application using readline. The text of the test, after any comparison operator, extends to the end of the line; unless otherwise noted, no characters are required to isolate it.
mode   The mode= form of the $if directive is used to test whether readline is in emacs or vi mode.  This may be used in conjunction with the set keymap command, for instance, to set bindings in the emacs-standard and emacs-ctlx keymaps only if readline is starting out in emacs mode.
term   The term= form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys.  The word on the right side of the = is tested against both the full name of the terminal and the portion of the terminal name before the first -. This allows sun to match both sun and sun-cmd, for instance.
version The version test may be used to perform comparisons against specific readline versions.  The version expands to the current readline version.  The set of comparison operators includes =, (and ==), !=, <=, >=, <, and >.  The version number supplied on the right side of the operator consists of a major version number, an optional decimal point, and an optional minor version (e.g., 7.1). If the minor version is omitted, it is assumed to be 0.  The operator may be separated from the string version and from the version number argument by whitespace.
application The application construct is used to include application- specific settings.  Each program using the readline library sets the application name, and an initialization file can test for a particular value.  This could be used to bind key sequences to functions useful for a specific program. For instance, the following command adds a key sequence that quotes the current or previous word in bash:
$if Bash # Quote the current or previous word "\C-xq": "\eb\"\ef\"" $endif
variable The variable construct provides simple equality tests for readline variables and values.  The permitted comparison operators are =, ==, and !=.  The variable name must be separated from the comparison operator by whitespace; the operator may be separated from the value on the right hand side by whitespace.  Both string and boolean variables may be tested. Boolean variables must be tested against the values on and off.
$endif This command, as seen in the previous example, terminates an $if command.
$else  Commands in this branch of the $if directive are executed if the test fails.
$include This directive takes a single filename as an argument and reads commands and bindings from that file.  For example, the following directive would read /etc/inputrc:
$include  /etc/inputrc
Searching Readline provides commands for searching through the command history (see HISTORY below) for lines containing a specified string.  There are two search modes: incremental and non-incremental.
Incremental searches begin before the user has finished typing the search string.  As each character of the search string is typed, readline displays the next entry from the history matching the string typed so far.  An incremental search requires only as many characters as needed to find the desired history entry.  The characters present in the value of the isearch-terminators variable are used to terminate an incremental search.  If that variable has not been assigned a value the Escape and Control-J characters will terminate an incremental search.  Control-G will abort an incremental search and restore the original line.  When the search is terminated, the history entry containing the search string becomes the current line.
To find other matching entries in the history list, type Control-S or Control-R as appropriate.  This will search backward or forward in the history for the next entry matching the search string typed so far.  Any other key sequence bound to a readline command will terminate the search and execute that command.  For instance, a newline will terminate the search and accept the line, thereby executing the command from the history list.
Readline remembers the last incremental search string.  If two Control-Rs are typed without any intervening characters defining a new search string, any remembered search string is used.
Non-incremental searches read the entire search string before starting to search for matching history lines.  The search string may be typed by the user or be part of the contents of the current line.
Readline Command Names The following is a list of the names of the commands and the default key sequences to which they are bound.  Command names without an accompanying key sequence are unbound by default.  In the following descriptions, point refers to the current cursor position, and mark refers to a cursor position saved by the set-mark command.  The text between the point and mark is referred to as the region.
Commands for Moving beginning-of-line (C-a) Move to the start of the current line. end-of-line (C-e) Move to the end of the line. forward-char (C-f) Move forward a character. backward-char (C-b) Move back a character. forward-word (M-f) Move forward to the end of the next word.  Words are composed of alphanumeric characters (letters and digits). backward-word (M-b) Move back to the start of the current or previous word.  Words are composed of alphanumeric characters (letters and digits). shell-forward-word Move forward to the end of the next word.  Words are delimited by non-quoted shell metacharacters. shell-backward-word Move back to the start of the current or previous word.  Words are delimited by non-quoted shell metacharacters. previous-screen-line Attempt to move point to the same physical screen column on the previous physical screen line. This will not have the desired effect if the current Readline line does not take up more than one physical line or if point is not greater than the length of the prompt plus the screen width. next-screen-line Attempt to move point to the same physical screen column on the next physical screen line. This will not have the desired effect if the current Readline line does not take up more than one physical line or if the length of the current Readline line is not greater than the length of the prompt plus the screen width. clear-display (M-C-l) Clear the screen and, if possible, the terminal's scrollback buffer, then redraw the current line, leaving the current line at the top of the screen. clear-screen (C-l) Clear the screen, then redraw the current line, leaving the current line at the top of the screen.  With an argument, refresh the current line without clearing the screen. redraw-current-line Refresh the current line.
Commands for Changing Text end-of-file (usually C-d) The character indicating end-of-file as set, for example, by ``stty''.  If this character is read when there are no characters on the line, and point is at the beginning of the line, Readline interprets it as the end of input and returns EOF. delete-char (C-d) Delete the character at point.  If this function is bound to the same character as the tty EOF character, as C-d commonly is, see above for the effects. backward-delete-char (Rubout) Delete the character behind the cursor.  When given a numeric argument, save the deleted text on the kill ring. forward-backward-delete-char Delete the character under the cursor, unless the cursor is at the end of the line, in which case the character behind the cursor is deleted. quoted-insert (C-q, C-v) Add the next character typed to the line verbatim.  This is how to insert characters like C-q, for example. tab-insert (C-v TAB) Insert a tab character. self-insert (a, b, A, 1, !, ...) Insert the character typed. transpose-chars (C-t) Drag the character before point forward over the character at point, moving point forward as well.  If point is at the end of the line, then this transposes the two characters before point. Negative arguments have no effect. transpose-words (M-t) Drag the word before point past the word after point, moving point over that word as well.  If point is at the end of the line, this transposes the last two words on the line. upcase-word (M-u) Uppercase the current (or following) word.  With a negative argument, uppercase the previous word, but do not move point. downcase-word (M-l) Lowercase the current (or following) word.  With a negative argument, lowercase the previous word, but do not move point. capitalize-word (M-c) Capitalize the current (or following) word.  With a negative argument, capitalize the previous word, but do not move point. overwrite-mode Toggle overwrite mode.  With an explicit positive numeric argument, switches to overwrite mode.  With an explicit non- positive numeric argument, switches to insert mode.  This command affects only emacs mode; vi mode does overwrite differently.  Each call to readline() starts in insert mode.  In overwrite mode, characters bound to self-insert replace the text at point rather than pushing the text to the right.  Characters bound to backward-delete-char replace the character before point with a space.  By default, this command is unbound.
Killing and Yanking kill-line (C-k) Kill the text from point to the end of the line. backward-kill-line (C-x Rubout) Kill backward to the beginning of the line. unix-line-discard (C-u) Kill backward from point to the beginning of the line.  The killed text is saved on the kill-ring. kill-whole-line Kill all characters on the current line, no matter where point is. kill-word (M-d) Kill from point to the end of the current word, or if between words, to the end of the next word.  Word boundaries are the same as those used by forward-word. backward-kill-word (M-Rubout) Kill the word behind point.  Word boundaries are the same as those used by backward-word. shell-kill-word Kill from point to the end of the current word, or if between words, to the end of the next word.  Word boundaries are the same as those used by shell-forward-word. shell-backward-kill-word Kill the word behind point.  Word boundaries are the same as those used by shell-backward-word. unix-word-rubout (C-w) Kill the word behind point, using white space as a word boundary. The killed text is saved on the kill-ring. unix-filename-rubout Kill the word behind point, using white space and the slash character as the word boundaries.  The killed text is saved on the kill-ring. delete-horizontal-space (M-\) Delete all spaces and tabs around point. kill-region Kill the text in the current region. copy-region-as-kill Copy the text in the region to the kill buffer. copy-backward-word Copy the word before point to the kill buffer.  The word boundaries are the same as backward-word. copy-forward-word Copy the word following point to the kill buffer.  The word boundaries are the same as forward-word. yank (C-y) Yank the top of the kill ring into the buffer at point. yank-pop (M-y) Rotate the kill ring, and yank the new top.  Only works following yank or yank-pop.
Numeric Arguments digit-argument (M-0, M-1, ..., M--) Add this digit to the argument already accumulating, or start a new argument.  M-- starts a negative argument. universal-argument This is another way to specify an argument.  If this command is followed by one or more digits, optionally with a leading minus sign, those digits define the argument.  If the command is followed by digits, executing universal-argument again ends the numeric argument, but is otherwise ignored.  As a special case, if this command is immediately followed by a character that is neither a digit nor minus sign, the argument count for the next command is multiplied by four.  The argument count is initially one, so executing this function the first time makes the argument count four, a second time makes the argument count sixteen, and so on.
Keyboard Macros start-kbd-macro (C-x () Begin saving the characters typed into the current keyboard macro. end-kbd-macro (C-x )) Stop saving the characters typed into the current keyboard macro and store the definition. call-last-kbd-macro (C-x e) Re-execute the last keyboard macro defined, by making the characters in the macro appear as if typed at the keyboard. print-last-kbd-macro () Print the last keyboard macro defined in a format suitable for the inputrc file.
Programmable Completion When word completion is attempted for an argument to a command for which a completion specification (a compspec) has been defined using the complete builtin (see SHELL BUILTIN COMMANDS below), the programmable completion facilities are invoked.
First, the command name is identified.  If the command word is the empty string (completion attempted at the beginning of an empty line), any compspec defined with the -E option to complete is used.  If a compspec has been defined for that command, the compspec is used to generate the list of possible completions for the word.  If the command word is a full pathname, a compspec for the full pathname is searched for first.  If no compspec is found for the full pathname, an attempt is made to find a compspec for the portion following the final slash.  If those searches do not result in a compspec, any compspec defined with the -D option to complete is used as the default.  If there is no default compspec, bash attempts alias expansion on the command word as a final resort, and attempts to find a compspec for the command word from any successful expansion.
Once a compspec has been found, it is used to generate the list of matching words.  If a compspec is not found, the default bash completion as described above under Completing is performed.
First, the actions specified by the compspec are used.  Only matches which are prefixed by the word being completed are returned.  When the -f or -d option is used for filename or directory name completion, the shell variable FIGNORE is used to filter the matches.
Any completions specified by a pathname expansion pattern to the -G option are generated next.  The words generated by the pattern need not match the word being completed.  The GLOBIGNORE shell variable is not used to filter the matches, but the FIGNORE variable is used.
Next, the string specified as the argument to the -W option is considered.  The string is first split using the characters in the IFS special variable as delimiters.  Shell quoting is honored.  Each word is then expanded using brace expansion, tilde expansion, parameter and variable expansion, command substitution, and arithmetic expansion, as described above under EXPANSION.  The results are split using the rules described above under Word Splitting.  The results of the expansion are prefix-matched against the word being completed, and the matching words become the possible completions.
After these matches have been generated, any shell function or command specified with the -F and -C options is invoked.  When the command or function is invoked, the COMP_LINE, COMP_POINT, COMP_KEY, and COMP_TYPE variables are assigned values as described above under Shell Variables. If a shell function is being invoked, the COMP_WORDS and COMP_CWORD variables are also set.  When the function or command is invoked, the first argument ($1) is the name of the command whose arguments are being completed, the second argument ($2) is the word being completed, and the third argument ($3) is the word preceding the word being completed on the current command line.  No filtering of the generated completions against the word being completed is performed; the function or command has complete freedom in generating the matches.
Any function specified with -F is invoked first.  The function may use any of the shell facilities, including the compgen builtin described below, to generate the matches.  It must put the possible completions in the COMPREPLY array variable, one per array element.
Next, any command specified with the -C option is invoked in an environment equivalent to command substitution.  It should print a list of completions, one per line, to the standard output.  Backslash may be used to escape a newline, if necessary.
After all of the possible completions are generated, any filter specified with the -X option is applied to the list.  The filter is a pattern as used for pathname expansion; a & in the pattern is replaced with the text of the word being completed.  A literal & may be escaped with a backslash; the backslash is removed before attempting a match.  Any completion that matches the pattern will be removed from the list.  A leading ! negates the pattern; in this case any completion not matching the pattern will be removed.  If the nocasematch shell option is enabled, the match is performed without regard to the case of alphabetic characters.
Finally, any prefix and suffix specified with the -P and -S options are added to each member of the completion list, and the result is returned to the readline completion code as the list of possible completions.
If the previously-applied actions do not generate any matches, and the -o dirnames option was supplied to complete when the compspec was defined, directory name completion is attempted.
If the -o plusdirs option was supplied to complete when the compspec was defined, directory name completion is attempted and any matches are added to the results of the other actions.
By default, if a compspec is found, whatever it generates is returned to the completion code as the full set of possible completions.  The default bash completions are not attempted, and the readline default of filename completion is disabled.  If the -o bashdefault option was supplied to complete when the compspec was defined, the bash default completions are attempted if the compspec generates no matches.  If the -o default option was supplied to complete when the compspec was defined, readline's default completion will be performed if the compspec (and, if attempted, the default bash completions) generate no matches.
When a compspec indicates that directory name completion is desired, the programmable completion functions force readline to append a slash to completed names which are symbolic links to directories, subject to the value of the mark-directories readline variable, regardless of the setting of the mark-symlinked-directories readline variable.
There is some support for dynamically modifying completions.  This is most useful when used in combination with a default completion specified with complete -D.  It's possible for shell functions executed as completion handlers to indicate that completion should be retried by returning an exit status of 124.  If a shell function returns 124, and changes the compspec associated with the command on which completion is being attempted (supplied as the first argument when the function is executed), programmable completion restarts from the beginning, with an attempt to find a new compspec for that command.  This allows a set of completions to be built dynamically as completion is attempted, rather than being loaded all at once.
For instance, assuming that there is a library of compspecs, each kept in a file corresponding to the name of the command, the following default completion function would load completions dynamically:
_completion_loader() { . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 } complete -D -F _completion_loader -o bashdefault -o default
When the -o history option to the set builtin is enabled, the shell provides access to the command history, the list of commands previously typed.  The value of the HISTSIZE variable is used as the number of commands to save in a history list.  The text of the last HISTSIZE commands (default 500) is saved.  The shell stores each command in the history list prior to parameter and variable expansion (see EXPANSION above) but after history expansion is performed, subject to the values of the shell variables HISTIGNORE and HISTCONTROL.
On startup, the history is initialized from the file named by the variable HISTFILE (default ~/.bash_history).  The file named by the value of HISTFILE is truncated, if necessary, to contain no more than the number of lines specified by the value of HISTFILESIZE.  If HISTFILESIZE is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated.  When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history line.  These timestamps are optionally displayed depending on the value of the HISTTIMEFORMAT variable.  When a shell with history enabled exits, the last $HISTSIZE lines are copied from the history list to $HISTFILE.  If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is overwritten. If HISTFILE is unset, or if the history file is unwritable, the history is not saved.  If the HISTTIMEFORMAT variable is set, time stamps are written to the history file, marked with the history comment character, so they may be preserved across shell sessions.  This uses the history comment character to distinguish timestamps from other history lines. After saving the history, the history file is truncated to contain no more than HISTFILESIZE lines.  If HISTFILESIZE is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated.
The builtin command fc (see SHELL BUILTIN COMMANDS below) may be used to list or edit and re-execute a portion of the history list.  The history builtin may be used to display or modify the history list and manipulate the history file.  When using command-line editing, search commands are available in each editing mode that provide access to the history list.
The shell allows control over which commands are saved on the history list.  The HISTCONTROL and HISTIGNORE variables may be set to cause the shell to save only a subset of the commands entered.  The cmdhist shell option, if enabled, causes the shell to attempt to save each line of a multi-line command in the same history entry, adding semicolons where necessary to preserve syntactic correctness.  The lithist shell option causes the shell to save the command with embedded newlines instead of semicolons.  See the description of the shopt builtin below under SHELL BUILTIN COMMANDS for information on setting and unsetting shell options.
The shell supports a history expansion feature that is similar to the history expansion in csh.  This section describes what syntax features are available.  This feature is enabled by default for interactive shells, and can be disabled using the +H option to the set builtin command (see SHELL BUILTIN COMMANDS below).  Non-interactive shells do not perform history expansion by default.
History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.