Beruflich Dokumente
Kultur Dokumente
15 Royal Park
Bristol
BS8 3AL
United Kingdom
Email: info@network-theory.co.uk
ISBN 0-9541617-7-7
This book has an unconditional guarantee. If you are not fully satisfied
with your purchase for any reason, please contact the publisher at the
address above.
Copyright
c 1988-2005 Free Software Foundation, Inc.
Modifications copyright
c 2006 Network Theory Ltd.
Permission is granted to make and distribute verbatim copies of this manual
provided the copyright notice and this permission notice are preserved on all
copies.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.2 or any later
version published by the Free Software Foundation; with no Invariant Sections,
with the Front-Cover texts being “A GNU Manual,” and with the Back-Cover
Texts as in (a) below. A copy of the license is included in the section entitled
“GNU Free Documentation License.”
(a) The FSF’s Back-Cover Text is: “You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free Software
Foundation raise funds for GNU development.”
The texinfo source files for this manual are available from
http://www.network-theory.co.uk/bash/manual/src/
i
Table of Contents
Publisher’s Preface . . . . . . . . . . . . . . . . . . . . . . 1
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 What is Bash? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 What is a shell? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5 Shell Variables . . . . . . . . . . . . . . . . . . . . . . 73
5.1 Bourne Shell Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2 Bash Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
iii
6 Bash Features . . . . . . . . . . . . . . . . . . . . . . 85
6.1 Invoking Bash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2 Bash Startup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.3 Interactive Shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.3.1 What is an Interactive Shell? . . . . . . . . . . . . . . . 90
6.3.2 Is this Shell Interactive? . . . . . . . . . . . . . . . . . . . . 90
6.3.3 Interactive Shell Behavior . . . . . . . . . . . . . . . . . . 90
6.4 Bash Conditional Expressions . . . . . . . . . . . . . . . . . . . . . . . . 92
6.5 Shell Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6.6 Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.7 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6.8 The Directory Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.8.1 Directory Stack Builtins . . . . . . . . . . . . . . . . . . . . 98
6.9 Controlling the Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.10 The Restricted Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.11 Bash POSIX Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Publisher’s Preface
This manual documents the use of GNU Bash, a command-line inter-
preter for the GNU operating system.
GNU Bash is free software. The term “free software” is sometimes
misunderstood—it has nothing to do with price. It is about freedom. It
refers to your freedom to run, copy, distribute, study, change and improve
the software. With GNU Bash you have all these freedoms.
GNU Bash is part of the GNU Project. The GNU Project was
launched in 1984 to develop a complete Unix-like operating system which
is free software: the GNU system. It was conceived as a way of bringing
back the cooperative spirit that prevailed in the computing community
in earlier days, by removing the obstacles to cooperation imposed by the
owners of proprietary software.
The Free Software Foundation is a tax-exempt charity that raises funds
for work on the GNU Project and is dedicated to promoting the freedom
to modify and redistribute computer programs. You can support the
GNU Project by becoming an associate member of the Free Software
Foundation and paying regular membership dues. For more information,
visit the website www.fsf.org.
Brian Gough
Publisher
October 2006
2 GNU Bash Reference Manual
Chapter 1: Introduction 3
1 Introduction
2 Definitions
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.
builtin A command that is implemented internally by the shell itself,
rather than by an executable program somewhere in the file
system.
control operator
A word that performs a control function. It is a newline or
one of the following: ‘||’, ‘&&’, ‘&’, ‘;’, ‘;;’, ‘|’, ‘(’, or ‘)’.
exit status
The value returned by a command to its caller. The value is
restricted to eight bits, so the maximum value is 255.
field A unit of text that is the result of one of the shell expansions.
After expansion, when executing a command, the resulting
fields are used as the command name and arguments.
filename A string of characters used to identify a file.
job A set of processes comprising a pipeline, and any processes
descended from it, that are all in the same process group.
job control
A mechanism by which users can selectively stop (suspend)
and restart (resume) execution of processes.
metacharacter
A character that, when unquoted, separates words. A
metacharacter is a blank or one of the following characters:
‘|’, ‘&’, ‘;’, ‘(’, ‘)’, ‘<’, or ‘>’.
name A word consisting solely of letters, numbers, and under-
scores, and beginning with a letter or underscore. Names
are used as shell variable and function names. Also referred
to as an identifier.
operator A control operator or a redirection operator. See Sec-
tion 3.6 [Redirections], page 32, for a list of redirection op-
erators.
6 GNU Bash Reference Manual
process group
A collection of related processes each having the same pro-
cess group id.
process group ID
A unique identifier that represents a process group during
its lifetime.
reserved word
A word that has a special meaning to the shell. Most re-
served words introduce shell flow control constructs, such as
for and while.
return status
A synonym for exit status.
signal A mechanism by which a process may be notified by the
kernel of an event occurring in the system.
special builtin
A shell builtin command that has been classified as special
by the posix standard.
token A sequence of characters considered a single unit by the shell.
It is either a word or an operator.
word A token that is not an operator.
Chapter 3: Basic Shell Features 7
4. Performs the various shell expansions (see Section 3.5 [Shell Expan-
sions], page 22), breaking the expanded tokens into lists of filenames
(see Section 3.5.8 [Filename Expansion], page 30) and commands and
arguments.
5. Performs any necessary redirections (see Section 3.6 [Redirections],
page 32) and removes the redirection operators and their operands
from the argument list.
6. Executes the command (see Section 3.7 [Executing Commands],
page 36).
7. Optionally waits for the command to complete and collects its exit
status (see Section 3.7.5 [Exit Status], page 40).
3.1.2 Quoting
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 (see Chapter 2 [Definitions], page 5)
has special meaning to the shell and must be quoted if it is to represent
itself. When the command history expansion facilities are being used
(see Section 9.3 [History Interaction], page 147), the history expansion
character, usually ‘!’, must be quoted to prevent history expansion. See
Section 9.1 [Bash History Facilities], page 145, for more details concerning
history expansion.
There are three quoting mechanisms: the escape character, single
quotes, and double quotes.
3.1.3 Comments
In a non-interactive shell, or an interactive shell in which the
interactive_comments option to the shopt builtin is enabled (see
Section 4.2 [Bash Builtins], page 51), a word beginning with ‘#’ causes
that word and all remaining characters on that line to be ignored. An
interactive shell without the interactive_comments option enabled
does not allow comments. The interactive_comments option is on by
default in interactive shells. See Section 6.3 [Interactive Shells], page 90,
for a description of what makes a shell interactive.
the shell’s control operators (see Chapter 2 [Definitions], page 5). The
first word generally specifies a command to be executed, with the rest of
the words being that command’s arguments.
The return status (see Section 3.7.5 [Exit Status], page 40) of a sim-
ple command is its exit status as provided by the posix 1003.1 waitpid
function, or 128+n if the command was terminated by signal n.
3.2.2 Pipelines
select
The select construct allows the easy generation of menus.
It has almost the same syntax as the for command:
select name [in words ...]; do
commands;
done
The list of words following in is expanded, generating a list
of items. The set of expanded words is printed on the stan-
dard error output stream, each preceded by a number. If the
‘in words’ is omitted, the positional parameters are printed,
as if ‘in "$@"’ had been specified. The PS3 prompt is then
displayed and a line is read from the standard input. If the
line consists of a number corresponding to one of the dis-
played words, then the value of name is set to that word. If
the line is empty, the words and prompt are displayed again.
If EOF is read, the select command completes. Any other
16 GNU Bash Reference Manual
( expression )
Returns the value of expression. This may be
used to override the normal precedence of op-
erators.
! expression
True if expression is false.
expression1 || expression2
True if either expression1 or expression2 is
true.
. E
.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 echo . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
enable . . . . . . . . . . . . . . . . . . . . . . . . . 56
eval . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
: exec . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
exit . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
export . . . . . . . . . . . . . . . . . . . . . . . . . 45
[
F
[. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
fc . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
fg . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
A
alias . . . . . . . . . . . . . . . . . . . . . . . . . . 51 G
getopts . . . . . . . . . . . . . . . . . . . . . . . . 45
B
bg . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 H
bind . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
break . . . . . . . . . . . . . . . . . . . . . . . . . . 44 hash . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
builtin . . . . . . . . . . . . . . . . . . . . . . . . 53 help . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
history . . . . . . . . . . . . . . . . . . . . . . . 146
C
J
caller . . . . . . . . . . . . . . . . . . . . . . . . . 53
cd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 jobs . . . . . . . . . . . . . . . . . . . . . . . . . . 109
command . . . . . . . . . . . . . . . . . . . . . . . . 53
compgen . . . . . . . . . . . . . . . . . . . . . . . 141
complete . . . . . . . . . . . . . . . . . . . . . . 141 K
continue . . . . . . . . . . . . . . . . . . . . . . . 44 kill . . . . . . . . . . . . . . . . . . . . . . . . . . 109
D L
declare . . . . . . . . . . . . . . . . . . . . . . . . 54 let . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
dirs . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 local . . . . . . . . . . . . . . . . . . . . . . . . . . 57
disown . . . . . . . . . . . . . . . . . . . . . . . . 110 logout . . . . . . . . . . . . . . . . . . . . . . . . . 57
184 GNU Bash Reference Manual
P T
popd . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 test . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
printf . . . . . . . . . . . . . . . . . . . . . . . . . 57 times . . . . . . . . . . . . . . . . . . . . . . . . . . 49
pushd . . . . . . . . . . . . . . . . . . . . . . . . . . 99 trap . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
pwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
type . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
typeset . . . . . . . . . . . . . . . . . . . . . . . . 64
R
read . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
readonly . . . . . . . . . . . . . . . . . . . . . . . 47 U
return . . . . . . . . . . . . . . . . . . . . . . . . . 47 ulimit . . . . . . . . . . . . . . . . . . . . . . . . . 64
umask . . . . . . . . . . . . . . . . . . . . . . . . . . 50
S unalias . . . . . . . . . . . . . . . . . . . . . . . . 66
unset . . . . . . . . . . . . . . . . . . . . . . . . . . 51
set . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
shift . . . . . . . . . . . . . . . . . . . . . . . . . . 48
shopt . . . . . . . . . . . . . . . . . . . . . . . . . . 59
source . . . . . . . . . . . . . . . . . . . . . . . . . 64
W
suspend . . . . . . . . . . . . . . . . . . . . . . . 110 wait . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Index of Shell Reserved Words 185
! E
!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 elif . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
else . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
esac . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
[
[[ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 F
fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
for . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
] function . . . . . . . . . . . . . . . . . . . . . . . 18
]] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
I
if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
{ in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
{. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
S
select . . . . . . . . . . . . . . . . . . . . . . . . . 15
}
}. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 T
then . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
time . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
C
case . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
U
until . . . . . . . . . . . . . . . . . . . . . . . . . . 13
D
do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 W
done . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 while . . . . . . . . . . . . . . . . . . . . . . . . . . 13
186 GNU Bash Reference Manual
Parameter and Variable Index 187
! B
!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 BASH . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
BASH_ARGC . . . . . . . . . . . . . . . . . . . . . . 74
BASH_ARGV . . . . . . . . . . . . . . . . . . . . . . 74
# BASH_COMMAND . . . . . . . . . . . . . . . . . . . 74
BASH_ENV . . . . . . . . . . . . . . . . . . . . . . . 74
#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
BASH_EXECUTION_STRING . . . . . . . . . 75
BASH_LINENO . . . . . . . . . . . . . . . . . . . . 75
BASH_REMATCH . . . . . . . . . . . . . . . . . . . 75
$ BASH_SOURCE . . . . . . . . . . . . . . . . . . . . 75
$. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 BASH_SUBSHELL. . . . . . . . . . . . . . . . . . 75
BASH_VERSINFO. . . . . . . . . . . . . . . . . . 75
BASH_VERSION . . . . . . . . . . . . . . . . . . . 76
* bell-style . . . . . . . . . . . . . . . . . . . . 118
bind-tty-special-chars . . . . . . . 118
*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
C
- CDPATH . . . . . . . . . . . . . . . . . . . . . . . . . 73
-. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 COLUMNS . . . . . . . . . . . . . . . . . . . . . . . . 76
comment-begin . . . . . . . . . . . . . . . . 118
COMP_CWORD . . . . . . . . . . . . . . . . . . . . . 76
? COMP_LINE . . . . . . . . . . . . . . . . . . . . . . 76
?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 COMP_POINT . . . . . . . . . . . . . . . . . . . . . 76
COMP_WORDBREAKS . . . . . . . . . . . . . . . 76
COMP_WORDS . . . . . . . . . . . . . . . . . . . . . 76
@ completion-query-items . . . . . . . 118
COMPREPLY . . . . . . . . . . . . . . . . . . . . . . 77
@. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 convert-meta. . . . . . . . . . . . . . . . . . 118
D
_. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 DIRSTACK . . . . . . . . . . . . . . . . . . . . . . . 77
disable-completion . . . . . . . . . . . 119
0 E
0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
editing-mode. . . . . . . . . . . . . . . . . . 119
EMACS . . . . . . . . . . . . . . . . . . . . . . . . . . 77
enable-keypad . . . . . . . . . . . . . . . . 119
A EUID . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
auto_resume . . . . . . . . . . . . . . . . . . . 110 expand-tilde. . . . . . . . . . . . . . . . . . 119
188 GNU Bash Reference Manual
F LINENO . . . . . . . . . . . . . . . . . . . . . . . . . 81
FCEDIT . . . . . . . . . . . . . . . . . . . . . . . . . 77 LINES . . . . . . . . . . . . . . . . . . . . . . . . . . 81
FIGNORE . . . . . . . . . . . . . . . . . . . . . . . . 77
FUNCNAME . . . . . . . . . . . . . . . . . . . . . . . 77
M
G MACHTYPE . . . . . . . . . . . . . . . . . . . . . . . 81
GLOBIGNORE . . . . . . . . . . . . . . . . . . . . . 77 MAIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
GROUPS . . . . . . . . . . . . . . . . . . . . . . . . . 78 MAILCHECK . . . . . . . . . . . . . . . . . . . . . . 81
MAILPATH . . . . . . . . . . . . . . . . . . . . . . . 73
mark-modified-lines . . . . . . . . . . 120
H mark-symlinked-directories . . 120
histchars . . . . . . . . . . . . . . . . . . . . . . 78 match-hidden-files . . . . . . . . . . . 120
HISTCMD . . . . . . . . . . . . . . . . . . . . . . . . 78
meta-flag . . . . . . . . . . . . . . . . . . . . . 119
HISTCONTROL . . . . . . . . . . . . . . . . . . . . 78
HISTFILE . . . . . . . . . . . . . . . . . . . . . . . 78
HISTFILESIZE . . . . . . . . . . . . . . . . . . . 79
HISTIGNORE . . . . . . . . . . . . . . . . . . . . . 79 O
history-preserve-point . . . . . . . 119
OLDPWD . . . . . . . . . . . . . . . . . . . . . . . . . 81
HISTSIZE . . . . . . . . . . . . . . . . . . . . . . . 79
OPTARG . . . . . . . . . . . . . . . . . . . . . . . . . 73
HISTTIMEFORMAT . . . . . . . . . . . . . . . . 79
HOME . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 OPTERR . . . . . . . . . . . . . . . . . . . . . . . . . 81
horizontal-scroll-mode . . . . . . . 119 OPTIND . . . . . . . . . . . . . . . . . . . . . . . . . 73
HOSTFILE . . . . . . . . . . . . . . . . . . . . . . . 79 OSTYPE . . . . . . . . . . . . . . . . . . . . . . . . . 81
HOSTNAME . . . . . . . . . . . . . . . . . . . . . . . 80 output-meta . . . . . . . . . . . . . . . . . . . 121
HOSTTYPE . . . . . . . . . . . . . . . . . . . . . . . 80
I P
IFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 page-completions . . . . . . . . . . . . . 121
IGNOREEOF . . . . . . . . . . . . . . . . . . . . . . 80 PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
input-meta . . . . . . . . . . . . . . . . . . . . 119 PIPESTATUS . . . . . . . . . . . . . . . . . . . . . 81
INPUTRC . . . . . . . . . . . . . . . . . . . . . . . . 80 POSIXLY_CORRECT . . . . . . . . . . . . . . . 81
isearch-terminators . . . . . . . . . . 120
PPID . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
PROMPT_COMMAND . . . . . . . . . . . . . . . . 81
K PS1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
keymap . . . . . . . . . . . . . . . . . . . . . . . . 120 PS2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
PS3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
PS4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
L PWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
LANG . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
LC_ALL . . . . . . . . . . . . . . . . . . . . . . . . . 80
LC_COLLATE . . . . . . . . . . . . . . . . . . . . . 80 R
LC_CTYPE . . . . . . . . . . . . . . . . . . . . . . . 80
LC_MESSAGES . . . . . . . . . . . . . . . . 10, 80 RANDOM . . . . . . . . . . . . . . . . . . . . . . . . . 82
LC_NUMERIC . . . . . . . . . . . . . . . . . . . . . 80 REPLY . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Parameter and Variable Index 189
S TEXTDOMAINDIR. . . . . . . . . . . . . . . . . . 10
TIMEFORMAT . . . . . . . . . . . . . . . . . . . . . 82
SECONDS . . . . . . . . . . . . . . . . . . . . . . . . 82
TMOUT . . . . . . . . . . . . . . . . . . . . . . . . . . 83
SHELL . . . . . . . . . . . . . . . . . . . . . . . . . . 82
TMPDIR . . . . . . . . . . . . . . . . . . . . . . . . . 83
SHELLOPTS . . . . . . . . . . . . . . . . . . . . . . 82
SHLVL . . . . . . . . . . . . . . . . . . . . . . . . . . 82
show-all-if-ambiguous . . . . . . . . 121 U
show-all-if-unmodified . . . . . . . 121 UID . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
T V
TEXTDOMAIN . . . . . . . . . . . . . . . . . . . . . 10 visible-stats . . . . . . . . . . . . . . . . 121
190 GNU Bash Reference Manual
Function Index 191
Function Index
A delete-horizontal-space () . . . 132
abort (C-g) . . . . . . . . . . . . . . . . . . . 135 digit-argument (M-0, M-1, ...
accept-line (Newline or Return) M--) . . . . . . . . . . . . . . . . . . . . . . 133
. . . . . . . . . . . . . . . . . . . . . . . . . . 128 display-shell-version (C-x C-v)
alias-expand-line () . . . . . . . . . 138 . . . . . . . . . . . . . . . . . . . . . . . . . . 137
do-uppercase-version (M-a, M-b,
M-x, ...) . . . . . . . . . . . . . . . . . 135
B downcase-word (M-l) . . . . . . . . . . 131
backward-char (C-b) . . . . . . . . . . 128 dump-functions (). . . . . . . . . . . . . 136
backward-delete-char (Rubout) dump-macros () . . . . . . . . . . . . . . . . 137
. . . . . . . . . . . . . . . . . . . . . . . . . . 130 dump-variables (). . . . . . . . . . . . . 137
backward-kill-line (C-x Rubout) dynamic-complete-history
. . . . . . . . . . . . . . . . . . . . . . . . . . 131 (M- TAB ) . . . . . . . . . . . . . . . . . 135
backward-kill-word (M- DEL )
. . . . . . . . . . . . . . . . . . . . . . . . . . 132
backward-word (M-b) . . . . . . . . . . 128
beginning-of-history (M-<) . . . 129 E
beginning-of-line (C-a) . . . . . . 128 edit-and-execute-command
(C-xC-e) . . . . . . . . . . . . . . . . . . 138
end-kbd-macro (C-x )) . . . . . . . . . 135
C end-of-history (M->) . . . . . . . . . 129
call-last-kbd-macro (C-x e) . . 135 end-of-line (C-e). . . . . . . . . . . . . 128
capitalize-word (M-c) . . . . . . . . 131 exchange-point-and-mark (C-x C-x)
character-search (C-]) . . . . . . . 136 . . . . . . . . . . . . . . . . . . . . . . . . . . 136
character-search-backward
(M-C-]) . . . . . . . . . . . . . . . . . . . 136
clear-screen (C-l) . . . . . . . . . . . 128
complete ( TAB ) . . . . . . . . . . . . . . 133
F
complete-command (M-!) . . . . . . . 134 forward-backward-delete-char ()
complete-filename (M-/) . . . . . . 134 . . . . . . . . . . . . . . . . . . . . . . . . . . 130
complete-hostname (M-@) . . . . . . 134 forward-char (C-f) . . . . . . . . . . . 128
complete-into-braces (M-{) . . . 135 forward-search-history (C-s)
complete-username (M-~) . . . . . . 134 . . . . . . . . . . . . . . . . . . . . . . . . . . 129
complete-variable (M-$) . . . . . . 134 forward-word (M-f) . . . . . . . . . . . 128
copy-backward-word () . . . . . . . . 132
copy-forward-word () . . . . . . . . . 132
copy-region-as-kill () . . . . . . . 132
G
glob-complete-word (M-g) . . . . . 137
D glob-expand-word (C-x *) . . . . . 137
delete-char (C-d). . . . . . . . . . . . . 130 glob-list-expansions (C-x g)
delete-char-or-list () . . . . . . . 134 . . . . . . . . . . . . . . . . . . . . . . . . . . 137
192 GNU Bash Reference Manual
H possible-hostname-completions
history-and-alias-expand-line () (C-x @) . . . . . . . . . . . . . . . . . . . 134
. . . . . . . . . . . . . . . . . . . . . . . . . . 138 possible-username-completions
history-expand-line (M-^) . . . . 137 (C-x ~) . . . . . . . . . . . . . . . . . . . 134
history-search-backward () . . . 129 possible-variable-completions
history-search-forward () . . . . 129 (C-x $) . . . . . . . . . . . . . . . . . . . 134
prefix-meta ( ESC ) . . . . . . . . . . . 135
previous-history (C-p) . . . . . . . 128
I
insert-comment (M-#) . . . . . . . . . 136
insert-completions (M-*) . . . . . 133 Q
insert-last-argument (M-. or M-_) quoted-insert (C-q or C-v). . . . 130
. . . . . . . . . . . . . . . . . . . . . . . . . . 138
K R
kill-line (C-k) . . . . . . . . . . . . . . . 131 re-read-init-file (C-x C-r) . . 135
kill-region () . . . . . . . . . . . . . . . . 132 redraw-current-line () . . . . . . . 128
kill-whole-line () . . . . . . . . . . . 131 reverse-search-history (C-r)
kill-word (M-d) . . . . . . . . . . . . . . . 132 .......................... 129
revert-line (M-r). . . . . . . . . . . . . 136
M
magic-space () . . . . . . . . . . . . . . . . 138 S
menu-complete () . . . . . . . . . . . . . . 133
self-insert (a, b, A, 1, !, ...)
. . . . . . . . . . . . . . . . . . . . . . . . . . 130
N set-mark (C-@) . . . . . . . . . . . . . . . . 136
shell-expand-line (M-C-e) . . . . 137
next-history (C-n) . . . . . . . . . . . 128
start-kbd-macro (C-x () . . . . . . 135
non-incremental-forward-search-
history (M-n) . . . . . . . . . . . . . 129
non-incremental-reverse-search-
history (M-p) . . . . . . . . . . . . . 129 T
tilde-expand (M-&) . . . . . . . . . . . 136
transpose-chars (C-t) . . . . . . . . 130
O transpose-words (M-t) . . . . . . . . 130
operate-and-get-next (C-o) . . . 138
overwrite-mode (). . . . . . . . . . . . . 131
U
P undo (C-_ or C-x C-u) . . . . . . . . . 136
possible-command-completions universal-argument () . . . . . . . . 133
(C-x !) . . . . . . . . . . . . . . . . . . . 135 unix-filename-rubout () . . . . . . 132
possible-completions (M-?) . . . 133 unix-line-discard (C-u) . . . . . . 131
possible-filename-completions unix-word-rubout (C-w) . . . . . . . 132
(C-x /) . . . . . . . . . . . . . . . . . . . 134 upcase-word (M-u). . . . . . . . . . . . . 131
Function Index 193
Concept Index
A D
alias expansion . . . . . . . . . . . . . . . . . . 95 directory stack . . . . . . . . . . . . . . . . . . 98
appending output . . . . . . . . . . . . . . . 34 double quotes . . . . . . . . . . . . . . . . . . . . 9
arithmetic evaluation . . . . . . . . . . . . 94 duplicating file descriptors . . . . . . . 35
arithmetic expansion . . . . . . . . . . . . 29
arithmetic, shell . . . . . . . . . . . . . . . . . 94
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 96 E
editing command lines . . . . . . . . . . 114
environment . . . . . . . . . . . . . . . . . . . . 39
B escape character . . . . . . . . . . . . . . . . . 8
background . . . . . . . . . . . . . . . . . . . . 107 evaluation, arithmetic . . . . . . . . . . . 94
backquotes . . . . . . . . . . . . . . . . . . . . . 28 event designators . . . . . . . . . . . . . . . 148
Bash configuration . . . . . . . . . . . . . 151 execution environment . . . . . . . . . . . 38
Bash installation . . . . . . . . . . . . . . . 151 exit status. . . . . . . . . . . . . . . . . . . . 5, 40
Bourne shell . . . . . . . . . . . . . . . . . . . . . 7 expansion . . . . . . . . . . . . . . . . . . . . . . 22
brace expansion . . . . . . . . . . . . . . . . . 23 expansion, arithmetic . . . . . . . . . . . . 29
builtin. . . . . . . . . . . . . . . . . . . . . . . . . . . 5 expansion, brace . . . . . . . . . . . . . . . . 23
expansion, filename. . . . . . . . . . . . . . 30
expansion, parameter . . . . . . . . . . . . 25
C expansion, pathname . . . . . . . . . . . . 30
command editing. . . . . . . . . . . . . . . 114 expansion, tilde . . . . . . . . . . . . . . . . . 24
command execution . . . . . . . . . . . . . 37 expressions, arithmetic . . . . . . . . . . 94
command expansion . . . . . . . . . . . . . 36 expressions, conditional . . . . . . . . . . 92
command history . . . . . . . . . . . . . . 145
command search . . . . . . . . . . . . . . . . 37
command substitution . . . . . . . . . . . 28
F
command timing . . . . . . . . . . . . . . . . 11 FDL, GNU Free Documentation
commands, compound . . . . . . . . . . . 12 License. . . . . . . . . . . . . . . . . . . . 171
commands, conditional . . . . . . . . . . 14 field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
commands, grouping . . . . . . . . . . . . 18 filename . . . . . . . . . . . . . . . . . . . . . . . . . 5
commands, lists . . . . . . . . . . . . . . . . . 12 filename expansion . . . . . . . . . . . . . . 30
commands, looping . . . . . . . . . . . . . . 13 foreground . . . . . . . . . . . . . . . . . . . . . 107
commands, pipelines . . . . . . . . . . . . 11 functions, shell . . . . . . . . . . . . . . . . . . 18
commands, shell . . . . . . . . . . . . . . . . 10
commands, simple . . . . . . . . . . . . . . . 10
comments, shell . . . . . . . . . . . . . . . . . 10 H
completion builtins . . . . . . . . . . . . . 141 here documents and strings . . . . . . 35
compound commands. . . . . . . . . . . . 12 history builtins . . . . . . . . . . . . . . . . 146
conditional expressions . . . . . . . . . . 92 history events . . . . . . . . . . . . . . . . . . 148
configuration . . . . . . . . . . . . . . . . . . 151 history expansion . . . . . . . . . . . . . . 147
control operator . . . . . . . . . . . . . . . . . . 5 history list. . . . . . . . . . . . . . . . . . . . . 145
196 GNU Bash Reference Manual
K
keyboard macros . . . . . . . . . . . . . . . 135
Q
kill ring . . . . . . . . . . . . . . . . . . . . . . . 115 quoting . . . . . . . . . . . . . . . . . . . . . . . . . . 8
killing text . . . . . . . . . . . . . . . . . . . . 115 quoting, ANSI . . . . . . . . . . . . . . . . . . . 9
L R
localization . . . . . . . . . . . . . . . . . . . . . 10 Readline, how to use . . . . . . . . . . . 111
login shell . . . . . . . . . . . . . . . . . . . . . . 87 redirection . . . . . . . . . . . . . . . . . . . . . . 32
looping commands . . . . . . . . . . . . . . 13 reserved word . . . . . . . . . . . . . . . . . . . . 6
restricted shell . . . . . . . . . . . . . . . . . 101
return status . . . . . . . . . . . . . . . . . . . . . 6
M
macros, keyboard . . . . . . . . . . . . . . 135 S
matching, pattern . . . . . . . . . . . . . . . 31
shell arithmetic . . . . . . . . . . . . . . . . . 94
metacharacter. . . . . . . . . . . . . . . . . . . . 5
shell function . . . . . . . . . . . . . . . . . . . 18
shell script. . . . . . . . . . . . . . . . . . . . . . 41
N shell variable. . . . . . . . . . . . . . . . . . . . 20
shell, interactive . . . . . . . . . . . . . . . . 90
name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 signal . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
native languages . . . . . . . . . . . . . . . . 10 signal handling . . . . . . . . . . . . . . . . . . 40
notation, readline . . . . . . . . . . . . . . 114 single quotes . . . . . . . . . . . . . . . . . . . . . 8
special builtin . . . . . . . . . . . . . . . . 6, 70
startup files . . . . . . . . . . . . . . . . . . . . . 87
O suspending jobs . . . . . . . . . . . . . . . . 107
operator, shell . . . . . . . . . . . . . . . . . . . 5 syntax of shell . . . . . . . . . . . . . . . . . . . 7
Concept Index 197
T W
tilde expansion . . . . . . . . . . . . . . . . . . 24 word . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
token . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
word designators . . . . . . . . . . . . . . . 149
translation, native languages . . . . . 10
word splitting . . . . . . . . . . . . . . . . . . . 29
V
variable, shell . . . . . . . . . . . . . . . . . . . 20 Y
variables, readline . . . . . . . . . . . . . . 118
vi mode . . . . . . . . . . . . . . . . . . . . . . . 138 yanking text . . . . . . . . . . . . . . . . . . . 115
GNU Bash Reference Manual
Ordering
Retail customers can order this title from most bookstores using the ISBN number. In case of ordering
difficulties, please email sales@network-theory.co.uk.
For trade orders, the book is available worldwide through the following wholesale suppliers:
If listed as out-of-stock this is only temporary—please place an order with the wholesaler as normal and
new copies will be printed on demand within 5 days. Titles ordered through wholesalers are sold on a “firm
sale” basis.
Copies can also be ordered directly from the publisher at the address below. The standard trade discount
for direct sales to resellers is 20%. The bulk order discount for direct sales of 10 or more copies is 35%.
Prepayment by VISA/Mastercard required for all discounted orders.
For more information contact: Network Theory Ltd, 15 Royal Park, Bristol, BS8 3AL, United Kingdom.
Telephone: +44 117 317 9309 Fax: +44 117 973 3323
http://www.network-theory.co.uk/