79 / 102
Local and Environment Variables
Variables are prefixed by a dollar sign ($
).
A value is assigned to a variable through an equals sign (=
)
(no whitespace on either side of it).
MY_VARIABLE='my value' echo $MY_VARIABLE
By default, variables are seen only within the shell itself. To pass variables to other programs invoked within the shell, they have to be exported to the environment.
set
- Display ot set shell variables.
printenv
- Display environment variables.
env
- Run a program in a modified environment.
export
- Export a local variable to the environment.