Learning shell interpretation of commands
When we log in, the $
sign will be visible in the shell Terminal (#
prompt if you are logged in as the root or administrator). The Bash shell runs scripts as the interpreter. Whenever we type a command, the Bash shell will read them as a series of words (tokens). Each word is separated by a space ( ), semicolon (;
), or any other command delimiter. We terminate the command by pressing the Enter key. This will insert a newline character at the end of the command. The first word is taken as a command, then consecutive words are treated as options or parameters.
The shell processes the command line as follows:
- If applicable, the substitution of history commands
- Converting the command line into tokens and words
- Updating the history
- Processing quotes
- Defining functions and substitution of aliases
- Setting up of pipes, redirection, and background
- Substitution of variables (such as
$name
and$user
) is performed - Command substitution (
echo
cal
andecho
date
) is performed...