reserved word
A word such as if, then, for, do, done, case or function that the shell treats as grammar rather than as a command name.
In more detail
Reserved words are recognised only where a command could start, which is why if and then need a semicolon or a newline between them. The double bracket [[ is a reserved word too, which is how it can see your quotes and skip word splitting. Running type if prints if is a shell keyword.
Related terms
- builtin — A command implemented inside the shell itself rather than as a separate program on disk, such as cd, read or export.
- if statement — A statement that runs a block of code only when a condition holds, optionally with an else block for when it does not.
- double brackets — Bash's double-bracket test, [[ and ]], a keyword that does not split words or expand globs and adds pattern and regular expression matching.
Taught in
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation