Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
The following shell builtin commands are inherited from the Bourne Shell. These commands are implemented as specified by the POSIX 1003.2 standard.
: (a colon)
. (a period)
. filename [arguments]
PATHvariable is used to find filename. When Bash is not in POSIX mode, the current directory is searched if filename is not found in
$PATH. If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. The return status is the exit status of the last command executed, or zero if no commands are executed. If filename is not found, or cannot be read, the return status is non-zero. This builtin is equivalent to
selectloop. If n is supplied, the nth enclosing loop is exited. n must be greater than or equal to 1. The return status is zero unless n is not greater than or equal to 1.
cd [-L|-P] [directory]
HOMEshell variable is used. If the shell variable
CDPATHexists, it is used as a search path. If directory begins with a slash,
CDPATHis not used. The `-P' option means to not follow symbolic links; symbolic links are followed by default or with the `-L' option. If directory is `-', it is equivalent to
$OLDPWD. The return status is zero if the directory is successfully changed, non-zero otherwise.
selectloop. If n is supplied, the execution of the nth enclosing loop is resumed. n must be greater than or equal to 1. The return status is zero unless n is not greater than or equal to 1.
eval. If there are no arguments or only empty arguments, the return status is zero.
exec [-cl] [-a name] [command [arguments]]
loginprogram does. The `-c' option causes command to be executed with an empty environment. If `-a' is supplied, the shell passes name as the zeroth argument to command. If no command is specified, redirections may be used to affect the current shell environment. If there are no redirection errors, the return status is zero; otherwise the return status is non-zero.
EXITis executed before the shell terminates.
export [-fn] [-p] [name[=value]]
getopts optstring name [args]
getoptsis used by shell scripts to parse positional parameters. optstring contains the option characters to be recognized; if a character is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. The colon (`:') and question mark (`?') may not be used as option characters. Each time it is invoked,
getoptsplaces the next option in the shell variable name, initializing name if it does not exist, and the index of the next argument to be processed into the variable
OPTINDis initialized to 1 each time the shell or a shell script is invoked. When an option requires an argument,
getoptsplaces that argument into the variable
OPTARG. The shell does not reset
OPTINDautomatically; it must be manually reset between multiple calls to
getoptswithin the same shell invocation if a new set of parameters is to be used.
When the end of options is encountered,
getopts exits with a
return value greater than zero.
OPTIND is set to the index of the first non-option argument,
name is set to `?'.
normally parses the positional parameters, but if more arguments are
given in args,
getopts parses those instead.
getopts can report errors in two ways. If the first character of
optstring is a colon, silent
error reporting is used. In normal operation diagnostic messages
are printed when invalid options or missing option arguments are
If the variable
is set to 0, no error messages will be displayed, even if the first
optstring is not a colon.
If an invalid option is seen,
getopts places `?' into name and, if not silent,
prints an error message and unsets
getopts is silent, the option character found is placed in
OPTARG and no diagnostic message is printed.
If a required argument is not found, and
is not silent, a question mark (`?') is placed in name,
OPTARG is unset, and a diagnostic message is printed.
getopts is silent, then a colon (`:') is placed in
OPTARG is set to the option character found.
hash [-'r] [-p filename] [-dt] [name]
$PATH. The `-p' option inhibits the path search, and filename is used as the location of name. The `-r' option causes the shell to forget all remembered locations. The `-d' option causes the shell to forget the remembered location of each name. If the `-t' option is supplied, the full pathname to which each name corresponds is printed. If multiple name arguments are supplied with `-t' the name is printed before the hashed full pathname. The `-l' option causes output to be displayed in a format that may be reused as input. If no arguments are given, or if only `-l' is supplied, information about remembered commands is printed. The return status is zero unless a name is not found or an invalid option is supplied.
readonly [-apf] [name] ...
source) builtin, returning either n or the exit status of the last command executed within the script as the exit status of the script. The return status is non-zero if
returnis used outside a function and not during the execution of a script by
$#are renamed to
$#-n+1. Parameters represented by the numbers
$#to n+1 are unset. n must be a non-negative number less than or equal to
$#. If n is zero or greater than
$#, the positional parameters are not changed. If n is not supplied, it is assumed to be 1. The return status is zero unless n is greater than
$#or less than zero, non-zero otherwise.
[ form is used, the last argument to the command must
Expressions may be combined using the following operators, listed in decreasing order of precedence.
( expr )
expr1 -a expr2
expr1 -o expr2
[ builtins evaluate conditional
expressions using a set of rules based on the number of arguments.
trap [-lp] [arg] [sigspec ...]
trapprints the list of commands associated with each signal number in a form that may be reused as shell input. Each sigspec is either a signal name such as
SIGINT(with or without the
SIGprefix) or a signal number. If a sigspec is
EXIT, arg is executed when the shell exits. If a sigspec is
DEBUG, the command arg is executed after every simple command. If a sigspec is
ERR, the command arg is executed whenever a simple command has a non-zero exit status. The
ERRtrap is not executed if the failed command is part of an
whileloop, part of an
ifstatement, part of a
||list, or if the command's return status is being inverted using
!. The `-l' option causes the shell to print a list of signal names and their corresponding numbers.
Signals ignored upon entry to the shell cannot be trapped or reset. Trapped signals are reset to their original values in a child process when it is created.
The return status is zero unless a sigspec does not specify a valid signal.
umask [-p] [-S] [mode]
chmodcommand. If mode is omitted, the current value of the mask is printed. If the `-S' option is supplied without a mode argument, the mask is printed in a symbolic format. If the `-p' option is supplied, and mode is omitted, the output is in a form that may be reused as input. The return status is zero if the mode is successfully changed or if no mode argument is supplied, and non-zero otherwise.
Note that when the mode is interpreted as an octal number, each number
of the umask is subtracted from
7. Thus, a umask of
results in permissions of
unset [-fv] [name]
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|