9.13. Shell Built-In Commands

The shell has a number of commands that are built-in to its source code. Because the commands are built-in, the shell doesn't have to locate them on disk, making execution much faster. The help feature provided with bash give you online help for any built-in command. The built-in commands are listed in Table 9.12 on page 481.

Table 9.12. Built-In Commands
CommandWhat It Does
:Do-nothing command; returns exit status zero.
. fileThe dot command reads and executes command from file.
break [n]See the looping commands on page 443.
:Do-nothing command; returns 0 exit status.
.Executes program in context of current process; same as source.
aliasLists and creates "nicknames" for existing commands.
bgPuts a job in the background.
bind*Displays current key and function bindings, or binds keys to a readline function or macro.
breakBreaks out of the innermost loop.
builtin [ sh-builtin [args]]*Runs a shell built-in, passing it args, and returning 0 exit status. Useful if a function and built-in have the same name.
cd [arg]Changes the directory to home if no arg or to arg.
command command* [arg]Runs a command even if a function has the same name; i.e., bypasses function lookup.
continue [n]See the looping commands on page 444.
declare [var]*Displays all variables or declares variables with optional attributes.
dirsDisplays a list of currently remembered directories resulting from pushd.
disownRemoves an active job from the job table.
echo [args]Displays args terminated with a newline.
enable*Enables and disables shell built-in commands.
eval [args]Reads args as input to the shell and executes the resulting command(s).
exec commandRuns command in place of this shell.
exit [ n ]Exits the shell with status n.
export [ var ]Makes var known to subshells.
fcHistory's fix command for editing history commands.
fgPuts background job into foreground.
getoptsParses and processes command line options.
hashControls the internal hash table for quicker searches for commands.
help [command ]*Displays helpful info about built-in commands and, if command is specified, detailed help about that built-in command.
historyDisplays the history list with line numbers.
jobsLists jobs put in the background.
kill [-signal process ]Sends the signal to the pid number or job number of the process. Type kill -l for a list of signals.
getoptsUsed in shell scripts to parse command line and check for legal options.
letUsed for evaluating arithmetic expressions and assigning results of arithmetic calculations to variables.
localUsed in functions to restrict the scope of variables to the function.
logoutExits the login shell.
popdRemoves entries from the directory stack.
pushdAdds entries to the directory stack.
pwdPrints present working directory.
read [ var ]Reads line from standard input into variable var.
readonly [ var ]Makes variable var read-only. Cannot be reset.
return [ n ]Returns from a function where n is the exit value given to the return.
setSets options and positional parameters. See Table 9.2 on page 396.
shift [n]Shifts positional parameters to the left n times.
stop pidHalts execution of the process number pid.
suspendStops execution of the current shell (but not if a login shell).
testChecks file types and evaluates conditional expressions.
timesPrints accumulated user and system times for processes run from this shell.
trap [ arg ] [ n ]When shell receives signal n ( 0, 1, 2, or 15), executes arg.
type [ command ]Prints the type of command; e.g., pwd is a built-in shell command.
typesetSame as declare. Sets variables and gives them attributes.
ulimitDiplays and sets process resource limits.
umask [ octal digits ]Sets user file creation mode mask for owner, group, and others.
unaliasUnsets aliases.
unset [ name ]Unset value of variable or function.
wait [ pid#n ]Waits for background process with pid number n and reports termination status.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.245.233