- Shell builtin
In computing, a
shell builtin is a command or a function, called from a shell, that is executed directly in the shell itself, instead of an external executable program which the shell would load and execute.Shell builtins work significantly faster than external programs, because there is no program loading overhead. However, their code is inherently present in the shell, and thus modifying or updating them requires modifications to the shell. Therefore shell builtins are usually used for simple, almost trivial, functions, such as text output.Because of the nature of
operating system s, some functions of the systems have to be implemented as shell builtins. The most notable example is thecd
command, which changes theworking directory of the shell. Because each executable program runs in a separate process, and working directories are specific to each process, loadingcd
as an external program would not affect the working directory of the shell that loaded it.Examples
A widely used shell-builtin is the
logout
function, which terminates the session. This function has different names depending on the shell.Some examples from bash include $ cd .. Loops (if, while, for and such) $ echo
The
help
bash-builtin command will list all builtins.Table of Built In Commands
Command Bourne Almquist Sash
: Yes Yes . Yes Yes ! No Yes ( Yes ) Yes { Yes Yes } Yes Yes alias No Yes bg No Yes break Yes Yes case Yes Yes cd Yes Yes command No Yes continue Yes Yes do Yes Yes done Yes Yes echo Yes No [1] elif Yes Yes else Yes Yes esac Yes Yes eval Yes Yes exec Yes Yes exit Yes Yes export Yes Yes fc No Yes fg No Yes fi Yes Yes for Yes Yes getopts No Yes hash Yes Yes if Yes Yes jobs No Yeskill No Yes pwd Yes Yes read Yes Yes readonly Yes Yes return Yes No printf No Yes set Yes Yes shift Yes Yes test Yes Yes then Yes Yes times Yes Yes trap Yes Yes type Yes No ulimit Yes Yes umask Yes Yes unalias No Yes unset Yes Yes until Yes Yes wait Yes Yes while Yes Yes
Wikimedia Foundation. 2010.