shell variable
A named value stored in the current shell, set with name=value and read back with $name.
In more detail
There must be no spaces around the equals sign, or bash treats the name as a command. A shell variable belongs to the shell process that set it and is not passed to programs it runs unless exported. All values are strings; arithmetic contexts read them as numbers.
Examples
city=Londonecho "$city"Related terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- export builtin — The builtin that marks a shell variable so child processes receive a copy of it in their environment.
- parameter expansion — Replacing a dollar sign and a variable name with the variable's value, optionally transformed by an operator inside curly braces.
Taught in
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Single Quotes, Double Quotes, Backslash — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Parameter Expansion: Defaults, Length, Slices — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation