This section describes builtin commands which are unique to or have been extended in Bash.
bind
bind [-m keymap] [-lpsvPSV] bind [-m keymap] [-q function] [-u function] [-r keyseq] bind [-m keymap] -f filename bind [-m keymap] keyseq:function-nameDisplay current Readline (see section Command Line Editing) key and function bindings, or bind a key sequence to a Readline function or macro. The binding syntax accepted is identical to that of `.inputrc' (@xref{Readline Init File}), but each binding must be passed as a separate argument: e.g., `"\C-x\C-r":re-read-init-file'. Options, if supplied, have the following meanings:
-m keymap
emacs
,
emacs-standard
,
emacs-meta
,
emacs-ctlx
,
vi
,
vi-command
, and
vi-insert
.
vi
is equivalent to vi-command
;
emacs
is equivalent to emacs-standard
.
-l
-p
-P
-v
-V
-s
-S
-f filename
-q function
-u function
-r keyseq
builtin
builtin [shell-builtin [args]]Run a shell builtin, passing it args, and return its exit status. This is useful when defining a shell function with the same name as a shell builtin, retaining the functionality of the builtin within the function. The return status is non-zero if shell-builtin is not a shell builtin command.
command
command [-pVv] command [arguments ...]Runs command with arguments ignoring any shell function named command. Only shell builtin commands or commands found by searching the
PATH
are executed.
If there is a shell function named ls
, running `command ls'
within the function will execute the external command ls
instead of calling the function recursively.
The `-p' option means to use a default value for $PATH
that is guaranteed to find all of the standard utilities.
The return status in this case is 127 if command cannot be
found or an error occurred, and the exit status of command
otherwise.
If either the `-V' or `-v' option is supplied, a
description of command is printed. The `-v' option
causes a single word indicating the command or file name used to
invoke command to be displayed; the `-V' option produces
a more verbose description. In this case, the return status is
zero if command is found, and non-zero if not.
declare
declare [-afFrxi] [-p] [name[=value]]Declare variables and give them attributes. If no names are given, then display the values of variables instead. The `-p' option will display the attributes and values of each name. When `-p' is used, additional options are ignored. The `-F' option inhibits the display of function definitions; only the function name and attributes are printed. `-F' implies `-f'. The following options can be used to restrict output to variables with the specified attributes or to give variables attributes:
-a
-f
-i
-r
-x
declare
makes each name local,
as with the local
command.
The return status is zero unless an invalid option is encountered,
an attempt is made to define a function using -f foo=bar
,
an attempt is made to assign a value to a readonly variable,
an attempt is made to assign a value to an array variable without
using the compound assignment syntax (see section Arrays),
one of the names is not a valid shell variable name,
an attempt is made to turn off readonly status for a readonly variable,
an attempt is made to turn off array status for an array variable,
or an attempt is made to display a non-existent function with `-f'.
echo
echo [-neE] [arg ...]Output the args, separated by spaces, terminated with a newline. The return status is always 0. If `-n' is specified, the trailing newline is suppressed. If the `-e' option is given, interpretation of the following backslash-escaped characters is enabled. The `-E' option disables the interpretation of these escape characters, even on systems where they are interpreted by default.
echo
interprets the following escape sequences:
\a
\b
\c
\e
\f
\n
\r
\t
\v
\\
\nnn
ASCII
code is the octal value nnn
(one to three digits)
\xnnn
ASCII
code is the hexadecimal value nnn
(one to three digits)
enable
enable [-n] [-p] [-f filename] [-ads] [name ...]Enable and disable builtin shell commands. Disabling a builtin allows a disk command which has the same name as a shell builtin to be executed with specifying a full pathname, even though the shell normally searches for builtins before disk commands. If `-n' is used, the names become disabled. Otherwise names are enabled. For example, to use the
test
binary
found via $PATH
instead of the shell builtin version, type
`enable -n test'.
If the `-p' option is supplied, or no name arguments appear,
a list of shell builtins is printed. With no other arguments, the list
consists of all enabled shell builtins.
The `-a' option means to list
each builtin with an indication of whether or not it is enabled.
The `-f' option means to load the new builtin command name
from shared object filename, on systems that support dynamic loading.
The `-d' option will delete a builtin loaded with `-f'.
If there are no options, a list of the shell builtins is displayed.
The `-s' option restricts enable
to the POSIX special
builtins. If `-s' is used with `-f', the new builtin becomes
a special builtin.
The return status is zero unless a name is not a shell builtin
or there is an error loading a new builtin from a shared object.
help
help [pattern]Display helpful information about builtin commands. If pattern is specified,
help
gives detailed help
on all commands matching pattern, otherwise a list of
the builtins is printed. The return status is zero unless no
command matches pattern.
let
let expression [expression]The
let
builtin allows arithmetic to be performed on shell
variables. Each expression is evaluated according to the
rules given below in section Shell Arithmetic. If the
last expression evaluates to 0, let
returns 1;
otherwise 0 is returned.
local
local name[=value]For each argument, a local variable named name is created, and assigned value.
local
can only be used within a function; it makes the variable
name have a visible scope restricted to that function and its
children. The return status is zero unless local
is used outside
a function or an invalid name is supplied.
logout
logout [n]Exit a login shell, returning a status of n to the shell's parent.
printf
printf
format [arguments]
Write the formatted arguments to the standard output under the
control of the format.
The format is a character string which contains three types of objects:
plain characters, which are simply copied to standard output, character
escape sequences, which are converted and copied to the standard output, and
format specifications, each of which causes printing of the next successive
argument.
In addition to the standard printf(1)
formats, `%b' causes
printf
to expand backslash escape sequences in the corresponding
argument, and `%q' causes printf
to output the
corresponding argument in a format that can be reused as shell input.
The format is reused as necessary to consume all of the arguments.
If the format requires more arguments than are supplied, the
extra format specifications behave as if a zero value or null string, as
appropriate, had been supplied.
read
read [-a aname] [-p prompt] [-er] [name ...]One line is read from the standard input, and the first word is assigned to the first name, the second word to the second name, and so on, with leftover words and their intervening separators assigned to the last name. If there are fewer words read from the standard input than names, the remaining names are assigned empty values. The characters in the value of the
IFS
variable
are used to split the line into words.
If no names are supplied, the line read is assigned to the
variable REPLY
.
The return code is zero, unless end-of-file is encountered.
Options, if supplied, have the following meanings:
-r
-p prompt
-a aname
-e
shopt
shopt [-pqsu] [-o] [optname ...]Toggle the values of variables controlling optional shell behavior. With no options, or with the `-p' option, a list of all settable options is displayed, with an indication of whether or not each is set. The `-p' option causes output to be displayed in a form that may be reused as input. Other options have the following meanings:
-s
-u
-q
-o
set
builtin (see section The Set Builtin).
shopt
options are disabled (off)
by default.
The return status when listing options is zero if all optnames
are enabled, non-zero otherwise. When setting or unsetting options,
the return status is zero unless an optname is not a valid shell
option.
The list of shopt
options is:
cdable_vars
cd
builtin command that
is not a directory is assumed to be the name of a variable whose
value is the directory to change to.
cdspell
cd
command will be corrected.
The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is only used by interactive shells.
checkhash
checkwinsize
LINES
and COLUMNS
.
cmdhist
dotglob
execfail
exec
builtin command. An interactive shell does not exit if exec
fails.
expand_aliases
extglob
histappend
HISTFILE
variable when the shell exits, rather than overwriting the file.
histreedit
histverify
hostcomplete
huponexit
SIGHUP
to all jobs when an interactive
login shell exits (see section Signals).
interactive_comments
lithist
cmdhist
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
mailwarn
"The mail in mailfile has been read"
is displayed.
nocaseglob
nullglob
promptvars
shift_verbose
shift
builtin prints an error message when the shift count exceeds the
number of positional parameters.
sourcepath
source
builtin uses the value of PATH
to find the directory containing the file supplied as an argument.
This option is enabled by default.
source
source filenameA synonym for
.
(see section Bourne Shell Builtins).
type
type [-atp] [name ...]For each name, indicate how it would be interpreted if used as a command name. If the `-t' option is used,
type
prints a single word
which is one of `alias', `function', `builtin',
`file' or `keyword',
if name is an alias, shell function, shell builtin,
disk file, or shell reserved word, respectively.
If the name is not found, then nothing is printed, and
type
returns a failure status.
If the `-p' option is used, type
either returns the name
of the disk file that would be executed, or nothing if `-t'
would not return `file'.
If the `-a' option is used, type
returns all of the places
that contain an executable named file.
This includes aliases and functions, if and only if the `-p' option
is not also used.
The return status is zero if any of the names are found, non-zero
if none are found.
typeset
typeset [-afFrxi] [-p] [name[=value]]The
typeset
command is supplied for compatibility with the Korn
shell; however, it has been deprecated in favor of the declare
builtin command.
ulimit
ulimit [-acdflmnpstuvSH] [limit]
ulimit
provides control over the resources available to processes
started by the shell, on systems that allow such control. If an
option is given, it is interpreted as follows:
-S
-H
-a
-c
-d
-f
-l
-m
-n
-p
-s
-t
-u
-v
unlimited
is supplied as a
limit, or an error occurs while setting a new limit.
Go to the first, previous, next, last section, table of contents.