> For the complete documentation index, see [llms.txt](https://woodrowpearson.gitbook.io/code-gists/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://woodrowpearson.gitbook.io/code-gists/bash/shell-operation-bash-reference-manual.md).

# Shell Operation (Bash Reference Manual)

## 3.1.1 Shell Operation

The following is a brief description of the shell’s operation when it reads and executes a command. Basically, the shell does the following:

1. &#x20;Reads its input from a file (see [Shell Scripts](/code-gists/bash/shell-scripts-bash-reference-manual.md#Shell-Scripts)), from a string supplied as an argument to the -c invocation option (see [Invoking Bash](/code-gists/bash/invoking-bash-bash-reference-manual.md#Invoking-Bash)), or from the user’s terminal.
2. &#x20;Breaks the input into words and operators, obeying the quoting rules described in [Quoting](/code-gists/bash/quoting-bash-reference-manual.md#Quoting). These tokens are separated by `metacharacters`. Alias expansion is performed by this step (see [Aliases](/code-gists/bash/aliases-bash-reference-manual.md#Aliases)).
3. &#x20;Parses the tokens into simple and compound commands (see [Shell Commands](/code-gists/bash/shell-commands-bash-reference-manual.md#Shell-Commands)).
4. &#x20;Performs the various shell expansions (see [Shell Expansions](/code-gists/bash/shell-expansions-bash-reference-manual.md#Shell-Expansions)), breaking the expanded tokens into lists of filenames (see [Filename Expansion](/code-gists/bash/filename-expansion-bash-reference-manual.md#Filename-Expansion)) and commands and arguments.
5. &#x20;Performs any necessary redirections (see [Redirections](/code-gists/bash/redirections-bash-reference-manual.md#Redirections)) and removes the redirection operators and their operands from the argument list.
6. &#x20;Executes the command (see [Executing Commands](/code-gists/bash/executing-commands-bash-reference-manual.md#Executing-Commands)).
7. &#x20;Optionally waits for the command to complete and collects its exit status (see [Exit Status](/code-gists/bash/exit-status-bash-reference-manual.md#Exit-Status)).
