BASH(1) USER COMMANDS BASH(1)
NAME
bash - GNU Bourne-Again SHell
SYNOPSIS
bash [options] [file]
COPYRIGHT
Bash is Copyright (C) 1989, 1991 by the Free Software Foun-
dation, Inc.
DESCRIPTION
Bash is an sh-compatible command language interpreter that
executes commands read from the standard input or from a
file. Bash also incorporates useful features from the _K_o_r_n
and _C shells (ksh and csh).
Bash is ultimately intended to be a conformant implementa-
tion of the IEEE Posix Shell and Tools specification (IEEE
Working Group 1003.2).
OPTIONS
In addition to the single-character shell options documented
in the description of the set builtin command, bash inter-
prets the following flags when it is invoked:
-c _s_t_r_i_n_g If the -c flag is present, then commands are read
from _s_t_r_i_n_g. If there are arguments after the
_s_t_r_i_n_g, they are assigned to the positional param-
eters, starting with $0.
-i If the -i flag is present, the shell is _i_n_t_e_r_a_c_-
_t_i_v_e.
-s If the -s flag is present, or if no arguments
remain after option processing, then commands are
read from the standard input. This option allows
the positional parameters to be set when invoking
an interactive shell.
- A single - signals the end of options and disables
further option processing. Any arguments after
the - are treated as filenames and arguments. An
argument of -- is equivalent to an argument of -.
Bash also interprets a number of multi-character options.
These options must appear on the command line before the
single-character options to be recognized.
-norc Do not read and execute the personal initializa-
tion file ~/._b_a_s_h_r_c if the shell is interactive.
This option is on by default if the shell is
invoked as sh.
-noprofile
Do not read either the system-wide startup file
/_e_t_c/_p_r_o_f_i_l_e or any of the personal initialization
GNU Last change: 1995 May 5 1
BASH(1) USER COMMANDS BASH(1)
files ~/._b_a_s_h__p_r_o_f_i_l_e, ~/._b_a_s_h__l_o_g_i_n, or ~/._p_r_o_-
_f_i_l_e. By default, bash normally reads these files
when it is invoked as a login shell (see INVOCA-
TION below).
-rcfile _f_i_l_e
Execute commands from _f_i_l_e instead of the standard
personal initialization file ~/._b_a_s_h_r_c, if the
shell is interactive (see INVOCATION below).
-version Show the version number of this instance of bash
when starting.
-quiet Do not be verbose when starting up (do not show
the shell version or any other information). This
is the default.
-login Make bash act as if it had been invoked as a login
shell.
-nobraceexpansion
Do not perform curly brace expansion (see Brace
Expansion below).
-nolineediting
Do not use the GNU _r_e_a_d_l_i_n_e library to read com-
mand lines if interactive.
-posix Change the behavior of bash where the default
operation differs from the Posix 1003.2 standard
to match the standard
ARGUMENTS
If arguments remain after option processing, and neither the
-c nor the -s option has been supplied, the first argument
is assumed to be the name of a file containing shell com-
mands. If bash is invoked in this fashion, $0 is set to the
name of the file, and the positional parameters are set to
the remaining arguments. Bash reads and executes commands
from this file, then exits. Bash's exit status is the exit
status of the last command executed in the script.
DEFINITIONS
blank
A space or tab.
word A sequence of characters considered as a single unit by
the shell. Also known as a token.
name A _w_o_r_d consisting only of alphanumeric characters and
underscores, and beginning with an alphabetic character
or an underscore. Also referred to as an identifier.
metacharacter
A character that, when unquoted, separates words. One
of the following:
| & ; ( ) < > space tab
control operator
A _t_o_k_e_n that performs a control function. It is one of
the following symbols:
|| & && ; ;; ( ) | <newline>
GNU Last change: 1995 May 5 2
BASH(1) USER COMMANDS BASH(1)
RESERVED WORDS
_R_e_s_e_r_v_e_d _w_o_r_d_s are words that have a special meaning to the
shell. The following words are recognized as reserved when
unquoted and either the first word of a simple command (see
SHELL GRAMMAR below) or the third word of a case or for com-
mand:
! case do done elif else esac fi for function if in select
then until while { }
SHELL GRAMMAR
Simple Commands
A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assign-
ments followed by _b_l_a_n_k-separated words and redirections,
and terminated by a _c_o_n_t_r_o_l _o_p_e_r_a_t_o_r. The first word speci-
fies the command to be executed. The remaining words are
passed as arguments to the invoked command.
The return value of a _s_i_m_p_l_e _c_o_m_m_a_n_d is its exit status, or
128+_n if the command is terminated by signal _n.
Pipelines
A _p_i_p_e_l_i_n_e is a sequence of one or more commands separated
by the character |. The format for a pipeline is:
[ ! ] _c_o_m_m_a_n_d [ | _c_o_m_m_a_n_d_2 ... ]
The standard output of _c_o_m_m_a_n_d is connected to the standard
input of _c_o_m_m_a_n_d_2. This connection is performed before any
redirections specified by the command (see REDIRECTION
below).
If the reserved word ! precedes a pipeline, the exit status
of that pipeline is the logical NOT of the exit status of
the last command. Otherwise, the status of the pipeline is
the exit status of the last command. The shell waits for
all commands in the pipeline to terminate before returning a
value.
Each command in a pipeline is executed as a separate process
(i.e., in a subshell).
Lists
A _l_i_s_t is a sequence of one or more pipelines separated by
one of the operators ;, &, &&, or ||, and terminated by one
of ;, &, or <newline>.
Of these list operators, && and || have equal precedence,
followed by ; and &, which have equal precedence.
If a command is terminated by the control operator &, the
shell executes the command in the _b_a_c_k_g_r_o_u_n_d in a subshell.
GNU Last change: 1995 May 5 3
BASH(1) USER COMMANDS BASH(1)
The shell does not wait for the command to finish, and the
return status is 0. Commands separated by a ; are executed
sequentially; the shell waits for each command to terminate
in turn. The return status is the exit status of the last
command executed.
The control operators && and || denote A