chapter_title stringclasses 9
values | section_title stringlengths 6 77 | num_words int64 7 5.33k | num_chars int64 47 32.6k | text stringlengths 47 32.6k |
|---|---|---|---|---|
Introduction | What is Bash? | 157 | 954 | Bash is the shell, or command language interpreter, for the gnu operating system. The name is an acronym for the ‘Bourne-Again SHell’, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix. Bash is largely compat... |
Introduction | What is a shell? | 350 | 2,378 | At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions. A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface t... |
Definitions | 2 Definitions | 427 | 2,569 | These definitions are used throughout the remainder of this manual. POSIX
A family of open system standards based on Unix. Bash is primarily concerned with the Shell and Utilities portion of the posix 1003.1 standard.
blank
A space or tab character.
whitespace A character belonging to the space character class in t... |
Basic Shell Features | 3 Basic Shell Features | 87 | 569 | Bash is an acronym for ‘Bourne-Again SHell’. The Bourne shell is the traditional Unix shell originally written by Stephen Bourne. All of the Bourne shell builtin commands are available in Bash, and the rules for evaluation and quoting are taken from the posix specification for the ‘standard’ Unix shell. This chapter br... |
Basic Shell Features | Shell Syntax | 113 | 720 | When the shell reads input, it proceeds through a sequence of operations. If the input indicates the beginning of a comment, the shell ignores the comment symbol (‘#’), and the rest of that line. Otherwise, roughly speaking, the shell reads its input and divides the input into words and operators, employing the quoting... |
Basic Shell Features | Shell Operation | 138 | 870 | The following is a brief description of the shell’s operation when it reads and executes a command. Basically, the shell does the following:
1. Reads its input from a file, from a string
supplied as an argument to the -c invocation option, or from the user’s terminal.
2. Breaks the input into words and operators, obeyi... |
Basic Shell Features | Quoting | 103 | 675 | Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. Each of the shell metacharacters has special meaning to the she... |
Basic Shell Features | Escape Character | 63 | 378 | A non-quoted backslash ‘\’ is the Bash escape character. It preserves the literal value of the next character that follows, removing any special meaning it has, with the exception of newline. If a \newline pair appears, and the backslash itself is not quoted, the \newline is treated as a line continuation (that is, it ... |
Basic Shell Features | Single Quotes | 31 | 195 | Enclosing characters in single quotes (‘’’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. |
Basic Shell Features | Double Quotes | 164 | 1,025 | Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘‘’, ‘\’, and, when history expansion is enabled, ‘!’. When the shell is in posix mode, the ‘!’ has no special meaning within double quotes, even when history expansion is enabled. The... |
Basic Shell Features | ANSI-C Quoting | 167 | 1,050 | Character sequences of the form $’string’ are treated as a special kind of single quotes. The sequence expands to string, with backslash-escaped characters in string replaced as
specified by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows:
\a
alert (bell)
\b
backspace
\e
\E
An ... |
Basic Shell Features | Locale-Specific Translation | 780 | 4,915 | Prefixing a double-quoted string with a dollar sign (‘$’), such as $"hello, world", causes the string to be translated according to the current locale. The gettext infrastructure performs the lookup and translation, using the LC_MESSAGES, TEXTDOMAINDIR, and TEXTDOMAIN shell variables, as explained below. See the gettex... |
Basic Shell Features | Comments | 88 | 569 | In a non-interactive shell, or an interactive shell in which the interactive_comments option to the shopt builtin is enabled, a word beginning with ‘#’ introduces a comment. A word begins at the beginning of a line, after unquoted whitespace, or after an operator. The comment causes that word and all remaining characte... |
Basic Shell Features | Shell Commands | 64 | 359 | A simple shell command such as echo a b c consists of the command itself followed by arguments, separated by spaces. More complex shell commands are composed of simple commands arranged together in a variety of ways: in a pipeline in which the output of one command becomes the input of a second, in a loop or conditiona... |
Basic Shell Features | Reserved Words | 101 | 522 | Reserved words are words that have special meaning to the shell. They are used to begin and end the shell’s compound commands. The following words are recognized as reserved when unquoted and the first word of a command (see below for exceptions):
if
then
elif
else
fi
time
for
in
until while do
done
case
esac
coproc se... |
Basic Shell Features | Simple Commands | 78 | 449 | A simple command is the kind of command that’s executed most often. It’s just a sequence of words separated by blanks, terminated by one of the shell’s control operators. The first word generally specifies a command to be executed, with the rest of the words being that command’s arguments. The return status of a simple... |
Basic Shell Features | Pipelines | 466 | 2,742 | A pipeline is a sequence of one or more commands separated by one of the control operators ‘|’ or ‘|&’. The format for a pipeline is [time [-p]] [!] command1 [ | or |& command2 ]... The output of each command in the pipeline is connected via a pipe to the input of the next command. That is, each command reads the previ... |
Basic Shell Features | Lists of Commands | 272 | 1,560 | A list is a sequence of one or more pipelines separated by one of the operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of ‘;’, ‘&’, or a newline. Of these list operators, ‘&&’ and ‘||’ have equal precedence, followed by ‘;’ and ‘&’, which have equal precedence. A sequence of one or more newlines may ... |
Basic Shell Features | Compound Commands | 101 | 639 | Compound commands are the shell programming language constructs. Each construct begins with a reserved word or control operator and is terminated by a corresponding reserved word or operator. Any redirections associated with a compound command apply to all commands within that compound command unless explicitly overrid... |
Basic Shell Features | Looping Constructs | 332 | 1,986 | Bash supports the following looping constructs. Note that wherever a ‘;’ appears in the description of a command’s syntax, it may be replaced with one or more newlines.
until
The syntax of the until command is:
until test-commands; do consequent-commands; done
Execute consequent-commands as long as test-commands has a... |
Basic Shell Features | Conditional Constructs | 2,104 | 12,805 | if
The syntax of the if command is:
if test-commands; then
consequent-commands; [elif more-test-commands; then
more-consequents;] [else alternate-consequents;]
fi
The test-commands list is executed, and if its return status is zero, the consequent-commands list is executed. If test-commands returns a non-zero status,... |
Basic Shell Features | Grouping Commands | 210 | 1,202 | Bash provides two ways to group a list of commands to be executed as a unit. When commands are grouped, redirections may be applied to the entire command list. For example, the output of all the commands in the list may be redirected to a single stream. () ( list ) Placing a list of commands between parentheses forces ... |
Basic Shell Features | Coprocesses | 387 | 2,330 | A coprocess is a shell command preceded by the coproc reserved word. A coprocess is executed asynchronously in a subshell, as if the command had been terminated with the ‘&’ control operator, with a two-way pipe established between the executing shell and the coprocess. The syntax for a coprocess is: coproc [NAME] comm... |
Basic Shell Features | GNU Parallel | 121 | 777 | There are ways to run commands in parallel that are not built into Bash. GNU Parallel is a tool to do just that. GNU Parallel, as its name suggests, can be used to build and run commands in parallel. You may run the same command with different arguments, whether they are filenames, usernames, hostnames, or lines read f... |
Basic Shell Features | Shell Functions | 1,230 | 7,428 | Shell functions are a way to group commands for later execution using a single name for the group. They are executed just like a "regular" simple command. When the name of a shell function is used as a simple command name, the shell executes the list of commands associated with that function name. Shell functions are e... |
Basic Shell Features | Shell Parameters | 677 | 4,121 | A parameter is an entity that stores values. It can be a name, a number, or one of the special characters listed below. A variable is a parameter denoted by a name. A variable has a value and zero or more attributes. Attributes are assigned using the declare builtin command (see the description of the declare builtin i... |
Basic Shell Features | Positional Parameters | 135 | 807 | A positional parameter is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell’s arguments when it is invoked, and may be reassigned using the set builtin command. Positional parameter N may be referenced as ${N}, or as $N when N consists of a singl... |
Basic Shell Features | Special Parameters | 486 | 2,844 | The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed. Special parameters are denoted by one of the following characters.
*
($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional ... |
Basic Shell Features | Shell Expansions | 178 | 1,187 | Expansion is performed on the command line after it has been split into tokens. Bash performs these expansions:
• brace expansion
• tilde expansion
• parameter and variable expansion
• command substitution
• arithmetic expansion
• word splitting
• filename expansion
• quote removal
The order of expansions is: brace ex... |
Basic Shell Features | Brace Expansion | 480 | 2,990 | Brace expansion is a mechanism to generate arbitrary strings sharing a common prefix and suffix, either of which can be empty. This mechanism is similar to filename expansion , but the filenames generated need not exist. Patterns to be brace expanded are formed from an optional preamble, followed by either a series of ... |
Basic Shell Features | Tilde Expansion | 405 | 2,460 | If a word begins with an unquoted tilde character (‘~’), all of the characters up to the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as ... |
Basic Shell Features | Shell Parameter Expansion | 2,859 | 17,201 | The ‘$’ character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the n... |
Basic Shell Features | Command Substitution | 493 | 3,169 | Command substitution allows the output of a command to replace the command itself. The standard form of command substitution occurs when a command is enclosed as follows: $(command) or (deprecated) ‘command‘. Bash performs command substitution by executing command in a subshell environment and replacing the command sub... |
Basic Shell Features | Arithmetic Expansion | 140 | 943 | Arithmetic expansion evaluates an arithmetic expression and substitutes the result. The format for arithmetic expansion is: $(( expression )) The expression undergoes the same expansions as if it were within double quotes, but unescaped double quote characters in expression are not treated specially and are removed. Al... |
Basic Shell Features | Process Substitution | 143 | 873 | Process substitution allows a process’s input or output to be referred to using a filename. It takes the form of <(list)
or >(list) The process list is run asynchronously, and its input or output appears as a filename. This filename is passed as an argument to the current command as the result of the expansion. If the... |
Basic Shell Features | Word Splitting | 342 | 2,134 | The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes for word splitting. Words that were not expanded are not split. The shell treats each character of $IFS as a delimiter, and splits the results of the other expansions into fields us... |
Basic Shell Features | Filename Expansion | 437 | 2,584 | After word splitting, unless the -f option has been set, Bash scans each word for the characters ‘*’, ‘?’, and ‘[’. If one of these characters appears, and is not quoted, then the word is regarded as a pattern, and replaced with a sorted list of filenames matching the pattern, subject to the value of the GLOBSORT shell... |
Basic Shell Features | Pattern Matching | 774 | 4,939 | Any character that appears in a pattern, other than the special pattern characters described below, matches itself. The nul character may not occur in a pattern. A backslash escapes the following character; the escaping backslash is discarded when matching. The special pattern characters must be quoted if they are to b... |
Basic Shell Features | Quote Removal | 26 | 158 | After the preceding expansions, all unquoted occurrences of the characters ‘\’, ‘’’, and ‘"’ that did not result from one of the above expansions are removed. |
Basic Shell Features | Redirections | 529 | 3,334 | Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection allows commands’ file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to. When used with the exec bui... |
Basic Shell Features | Redirecting Input | 39 | 231 | Redirecting input opens the file whose name results from the expansion of word for reading on file descriptor n, or the standard input (file descriptor 0) if n is not specified. The general format for redirecting input is: [n]<word |
Basic Shell Features | Redirecting Output | 131 | 743 | Redirecting output opens the file whose name results from the expansion of word for writing on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created; if it does exist it is truncated to zero size. The general format for redirecting output is: [n]>[... |
Basic Shell Features | Appending Redirected Output | 51 | 293 | Redirecting output in this fashion opens the file whose name results from the expansion of word for appending on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created. The general format for appending output is: [n]>>word |
Basic Shell Features | Redirecting Standard Output and Standard Error | 86 | 530 | This construct redirects both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to the file whose name is the expansion of word. There are two formats for redirecting standard output and standard error: &>word and >&word Of the two forms, the first is preferred. This is semantica... |
Basic Shell Features | Appending Standard Output and Standard Error | 51 | 327 | This construct appends both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to the file whose name is the expansion of word. The format for appending standard output and standard error is: &>>word This is semantically equivalent to >>word 2>&1 (see Duplicating File Descriptors ... |
Basic Shell Features | Here Documents | 246 | 1,557 | This type of redirection instructs the shell to read input from the current source until it reads a line containing only delimiter (with no trailing blanks). All of the lines read up to that point then become the standard input (or file descriptor n if n is specified) for a command. The format of here-documents is: [n]... |
Basic Shell Features | Here Strings | 61 | 392 | A variant of here documents, the format is: [n]<<< word The word undergoes tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal. Filename expansion and word splitting are not performed. The result is supplied as a single string, with a newline appended, to the... |
Basic Shell Features | Duplicating File Descriptors | 158 | 884 | The redirection operator [n]<&word is used to duplicate input file descriptors. If word expands to one or more digits, file descriptor n is made to be a copy of that file descriptor. It is a redirection error if the digits in word do not specify a file descriptor open for input. If word evaluates to ‘-’, file descripto... |
Basic Shell Features | Moving File Descriptors | 57 | 364 | The redirection operator [n]<&digitmoves the file descriptor digit to file descriptor n, or the standard input (file descriptor 0)
if n is not specified. digit is closed after being duplicated to n.
Similarly, the redirection operator [n]>&digitmoves the file descriptor digit to file descriptor n, or the standard outpu... |
Basic Shell Features | Opening File Descriptors for Reading and Writing | 42 | 226 | The redirection operator [n]<>word opens the file whose name is the expansion of word for both reading and writing on file descriptor n, or on file descriptor 0 if n is not specified. If the file does not exist, it is created. |
Basic Shell Features | Simple Command Expansion | 282 | 1,805 | When the shell executes a simple command, it performs the following expansions, assignments, and redirections, from left to right, in the following order.
1. The words that the parser has marked as variable assignments (those preceding the
command name) and redirections are saved for later processing.
2. The words that... |
Basic Shell Features | Command Search and Execution | 348 | 1,982 | After a command has been split into words, if it results in a simple command and an optional list of arguments, the shell performs the following actions.
1. 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.
2. If the name d... |
Basic Shell Features | Command Execution Environment | 466 | 2,808 | 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 se... |
Basic Shell Features | Environment | 256 | 1,587 | 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.
Bash 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 i... |
Basic Shell Features | Exit Status | 311 | 1,808 | 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 ce... |
Basic Shell Features | Signals | 602 | 3,514 | When Bash is interactive, in the absence of any traps, it ignores SIGTERM (so that ‘kill 0’ does not kill an interactive shell), and catches and handles SIGINT (so that the wait builtin is interruptible). When Bash receives a SIGINT, it breaks out of any executing loops. In all cases, Bash ignores SIGQUIT. If job contr... |
Basic Shell Features | Shell Scripts | 730 | 4,357 | A shell script is a text file containing shell commands. When such a file is used as the first non-option argument when invoking Bash, and neither the -c nor -s option is supplied, Bash reads and executes commands from the file,
then exits. This mode of operation creates a non-interactive shell. If the filename does no... |
Basic Shell Features | Bourne Shell Builtins | 3,821 | 21,987 | The following shell builtin commands are inherited from the Bourne Shell. These commands are implemented as specified by the posix standard. : (a colon) : [arguments] Do nothing beyond expanding arguments and performing redirections. The return status is zero. . (a period) . [-p path] filename [arguments] The. command ... |
Basic Shell Features | Bash Builtin Commands | 4,958 | 29,771 | This section describes builtin commands which are unique to or have been extended in Bash. Some of these commands are specified in the posix standard. alias alias [-p] [name[=value]...] Without arguments or with the -p option, alias prints the list of aliases on the standard output in a form that allows them to be reus... |
Basic Shell Features | The Set Builtin | 1,408 | 8,401 | This builtin is so complicated that it deserves its own section. set allows you to change the values of shell options and set the positional parameters, or to display the names and values of shell variables. set set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [argument...] set [+abefhkmnptuvxBCEHPT] [+o option-nam... |
Basic Shell Features | The Shopt Builtin | 1,964 | 12,324 | This builtin allows you to change additional optional shell behavior. shopt shopt [-pqsu] [-o] [optname...] Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the -o option is used, those available with the -o option to the set builtin command. With ... |
Basic Shell Features | Special Builtins | 113 | 729 | For historical reasons, the posix standard has classified several builtin commands as special. When Bash is executing in posix mode, the special builtins differ from other builtin commands in three respects:
1. Special builtins are found before shell functions during command lookup.
2. If a special builtin returns an e... |
Shell Variables | Shell Variables | 19 | 126 | This chapter describes the shell variables that Bash uses. Bash automatically assigns default values to a number of variables. |
Shell Variables | Bourne Shell Variables | 340 | 2,026 | Bash uses certain shell variables in the same way as the Bourne shell. In some cases, Bash assigns a default value to the variable. CDPATH
A colon-separated list of directories used as a search path for the cd builtin command.
HOME
The current user’s home directory; the default for the cd builtin command. The value ... |
Shell Variables | Bash Variables | 5,328 | 32,590 | These variables are set or used by Bash, but other shells do not normally treat them specially. A few variables used by Bash are described in different chapters: variables for controlling the job control facilities. _
($, an underscore.) This has a number of meanings depending on context. At shell startup, $ set to th... |
Bash Features | Bash Features | 7 | 47 | This chapter describes features unique to Bash. |
Bash Features | Invoking Bash | 852 | 5,197 | bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o option] [-O shopt_option] [argument...] bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o option] [-O shopt_option] -c string [argument...] bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o option] [-O shopt_option] [argument...] All of the single-character options used with the se... |
Bash Features | Bash Startup Files | 737 | 4,392 | This section describes how Bash executes its startup files. If any of the files exist but cannot be read, Bash reports an error. Tildes are expanded in filenames as described above under Tilde Expansion.
Invoked as an interactive login shell, or with --login When Bash is invoked as an interactive login shell, or as a ... |
Bash Features | What is an Interactive Shell? | 69 | 432 | An interactive shell is one started without non-option arguments (unless -s is specified) and without specifying the -c option, whose input and error output are both connected to terminals (as determined by isatty(3)), or one started with the -i option. An interactive shell generally reads from and writes to a user’s t... |
Bash Features | Is this Shell Interactive? | 87 | 515 | To determine within a startup script whether or not Bash is running interactively, test the value of the ‘-’ special parameter. It contains i when the shell is interactive. For example:
case "$-" in
*i*) echo This shell is interactive;; *) echo This shell is not interactive;;
esac
Alternatively, startup scripts may exa... |
Bash Features | Interactive Shell Behavior | 446 | 2,620 | When the shell is running interactively, it changes its behavior in several ways.
1. Bash reads and executes startup files.
2. Job Control is enabled by default. When job
control is in effect, Bash ignores the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.
3. Bash executes the values of the set e... |
Bash Features | Bash Conditional Expressions | 781 | 4,396 | Conditional expressions are used by the [[ compound command and the test and [ builtin commands. The test and [ commands determine their behavior based on the number of arguments; see the descriptions of those commands for any other commandspecific actions. Expressions may be unary or binary, and are formed from the pr... |
Bash Features | Shell Arithmetic | 463 | 2,849 | The shell allows arithmetic expressions to be evaluated, as one of the shell expansions or by using the (( compound command, the let and declare builtins, the arithmetic for command, the [[ conditional command, or the -i option to the declare builtin.
Evaluation is done in the largest fixed-width integers available, w... |
Bash Features | Aliases | 486 | 2,791 | Aliases allow a string to be substituted for a word that is in a position in the input where it can be the first word of a simple command. Aliases have names and corresponding values that are set and unset using the alias and unalias builtin commands. If the shell reads an unquoted word in the right position, it checks... |
Bash Features | Arrays | 1,141 | 7,034 | Bash provides one-dimensional indexed and associative array variables. Any variable may be used as an indexed array; the declare builtin explicitly declares an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously. Indexed arrays are referenced us... |
Bash Features | The Directory Stack | 80 | 500 | The directory stack is a list of recently-visited directories. The pushd builtin adds directories to the stack as it changes the current directory, and the popd builtin removes specified directories from the stack and changes the current directory to the directory removed. The dirs builtin displays the contents of the ... |
Bash Features | Directory Stack Builtins | 607 | 3,498 | dirs dirs [-clpv] [+N | -N] Without options, display the list of currently remembered directories. Directories are added to the list with the pushd command; the popd command removes directories from the list. The current directory is always the first directory in the stack. Options, if supplied, have the following mean... |
Bash Features | Controlling the Prompt | 370 | 2,263 | In addition, the following table describes the special characters which can appear in the prompt variables PS0, PS1, PS2, and PS4:
\a
A bell character.
\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; ... |
Bash Features | The Restricted Shell | 375 | 2,305 | If Bash is started with the name rbash, or the --restricted or -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. A restricted shell behaves identically to bash with the exception that the following are disallow... |
Bash Features | What is POSIX? | 58 | 352 | posix is the name for a family of standards based on Unix. A number of Unix services, tools, and functions are part of the standard, ranging from the basic system calls and C library functions to common applications and tools to system administration and management. The posix Shell and Utilities standard was originally... |
Bash Features | (POSIX.2). The first edition of the 1003.2 standard was published in 1992. It | 242 | 1,572 | was merged with the original IEEE 1003.1 Working Group and is currently maintained by the Austin Group (a joint working group of the IEEE, The Open Group and ISO/IEC SC22/WG15). Today the Shell and Utilities are a volume within the set of documents that make up IEEE Std 1003.1-2024, and thus the former POSIX.2 (from 19... |
Bash Features | Bash POSIX Mode | 2,385 | 14,321 | Although Bash is an implementation of the posix shell specification, there are areas where the Bash default behavior differs from the specification. The Bash posix mode changes the Bash behavior in these areas so that it conforms more strictly to the standard.
Starting Bash with the --posix command-line option or exec... |
Bash Features | Shell Compatibility Mode | 1,200 | 7,516 | Bash-4.0 introduced the concept of a shell compatibility level, specified as a set of options to the shopt builtin (compat31, compat32, compat40, compat41, and so on). There is only one current compatibility level – each option is mutually exclusive. The compatibility level is intended to allow users to select behavior... |
Job Control | Job Control | 19 | 107 | This chapter discusses what job control is, how it works, and how Bash allows you to access its facilities. |
Job Control | Job Control Basics | 1,015 | 5,838 | 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 wi... |
Job Control | Job Control Builtins | 992 | 5,519 | bg bg [jobspec...] Resume each suspended job jobspec in the background, as if it had been started with ‘&’. If jobspec is not supplied, the shell uses its notion of the current job. bg returns zero unless it is run when job control is not enabled, or, when run with job control enabled, any jobspec was not found or spec... |
Job Control | Job Control Variables | 163 | 934 | auto_resume This variable controls how the shell interacts with the user and job control. If this variable exists then simple commands consisting of only a single word, without redirections, are treated as candidates for resumption of an existing job. There is no ambiguity allowed; if there is more than one job beginni... |
Command Line Editing | Command Line Editing | 120 | 704 | This chapter describes the basic features of the gnu command line editing interface. Command line editing is provided by the Readline library, which is used by several different programs, including Bash. Command line editing is enabled by default when using an interactive shell, unless the --noediting option is supplie... |
Command Line Editing | Introduction to Line Editing | 353 | 1,969 | The following paragraphs use Emacs style to describe the notation used to represent keystrokes. The text C-k is read as ‘Control-K’ and describes the character produced when the k key is pressed while the Control key is depressed. The text M-k is read as ‘Meta-K’ and describes the character produced when the Meta key (... |
Command Line Editing | Readline Interaction | 126 | 664 | Often during an interactive session you type in a long line of text, only to notice that the first word on the line is misspelled. The Readline library gives you a set of commands for
manipulating the text as you type it in, allowing you to just fix your typo, and not forcing you to retype the majority of the line. Us... |
Command Line Editing | Readline Bare Essentials | 278 | 1,528 | In order to enter characters into the line, simply type them. The typed character appears where the cursor was, and then the cursor moves one space to the right. If you mistype a character, you can use your erase character to back up and delete the mistyped character. Sometimes you may mistype a character, and not noti... |
Command Line Editing | Readline Movement Commands | 128 | 723 | The above table describes the most basic keystrokes that you need in order to do editing of the input line. For your convenience, many other commands are available in addition to C-b, C-f, C-d, and DEL. Here are some commands for moving more rapidly within the line. C-a
Move to the start of the line.
C-e
Move to the... |
Command Line Editing | Readline Killing Commands | 310 | 1,630 | Killing text means to delete the text from the line, but to save it away for later use, usually by yanking (re-inserting) it back into the line. (‘Cut’ and ‘paste’ are more recent jargon for ‘kill’ and ‘yank’.) If the description for a command says that it ‘kills’ text, then you can be sure that you can get the text ba... |
Command Line Editing | Readline Arguments | 158 | 851 | You can pass numeric arguments to Readline commands. Sometimes the argument acts as a repeat count, other times it is the sign of the argument that is significant. If you pass a negative argument to a command which normally acts in a forward direction, that command will act in a backward direction. For example, to kill... |
Command Line Editing | Searching for Commands in the History | 307 | 1,933 | Readline provides commands for searching through the command history 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 ... |
Command Line Editing | Readline Init File | 141 | 834 | Although the Readline library comes with a set of Emacs-like keybindings installed by default, it is possible to use a different set of keybindings. Any user can customize programs that use Readline by putting commands in an inputrc file, conventionally in their home directory. The name of this file is taken from the v... |
Command Line Editing | Readline Init File Syntax | 3,376 | 21,167 | There are only a few basic constructs allowed in the Readline init file. Blank lines are ignored. Lines beginning with a ‘#’ are comments. Lines beginning with a ‘$’ indicate conditional constructs. Other lines denote variable settings and key bindings.
Variable Settings You can modify the run-time behavior of Readlin... |
Command Line Editing | Conditional Init Constructs | 534 | 3,298 | 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 available. $if
The $if construct allows bindings to be made based on the editing mode, ... |
Command Line Editing | Sample Init File | 374 | 2,463 | Here is an example of an inputrc file. This illustrates key binding, variable assignment, and conditional syntax.
# This file controls the behavior of line input editing for
# programs that use the GNU Readline library. Existing
# programs include FTP, Bash, and GDB.
#
# You can re-read the inputrc file with C-x C-r.
... |
Command Line Editing | Bindable Readline Commands | 126 | 776 | This section describes Readline commands that may be bound to key sequences. You can list your key bindings by executing bind -P or, for a more terse format, suitable for an inputrc file, bind -p. Command names without an accompanying key sequence are unbound by default. In the following descriptions, point refers to t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.