Built-in Commands

The shell has a number of commands that are built-in. This means that the shell itself executes the command, instead of running an external program in a separate process. Furthermore, POSIX distinguishes between "special" built-ins and "regular" built-ins. The built-in commands are listed in Table 7-9. Special built-ins are marked with a †. Most of the regular built-ins listed here have to be built-in for the shell to function correctly (e.g., read). Others are typically built into the shell only for efficiency (e.g., true and false). The standard allows other commands to be built-in for efficiency as well, but all regular built-ins must be accessible as separate programs that can be executed directly by other binary programs. test is a primary example of a command that often is built into the shell for efficiency reasons.

Table 7-9. POSIX shell built-in commands

Command

Summary

: (colon)[6]

Do nothing (just do expansions of arguments).

. (dot)

Read file and execute its contents in current shell.

alias

Set up shorthand for command or command line (interactive use).

bg

Put job in background (interactive use).

breaka

Exit from surrounding for, while, or until loop.

cd

Change working directory.

command

Locate built-in and external commands; find a built-in command instead of an identically named function.

continuea

Skip to next iteration of for, while, or until loop.

evala

Process arguments as a command line.

execa

Replace shell with given program ...

Get Classic Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.