Learning shell interpretation of commands
When we log in, the
$
sign will be visible in the shell terminal (#
prompt if logged in as root or administrator). The Bash shell runs scripts as interpreter. Whenever we type a command, the BASH shell will read them as series of words (tokens). Each word is separated by a space (
), semi colon (;
), or any other command delimiter. We terminate the command by pressing the Enter key. This will insert a new line 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, substitution of history commands
- Converting command line into tokens and words
- Updating history
- Processing of quotes
- Defining functions and substitution of alias
- 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 - Globing is performed...