Environmental variables
Another powerful feature of bash is the use of environmental variables. Environmental variables are values that are stored in memory and can be used to temporarily store information and settings. One example of this is the PATH
variable. The PATH
variable tells bash where to look for any programs if they aren't in the current directory.
All the current environmental variables set can be displayed using the printenv
command. They are loaded into memory automatically when your Raspberry Pi boots up.
You can define your own environmental variables easily in bash. By convention, in bash, all environmental variables are defined using capital letters.
To define an environmental variable, you can do as shown in the following screenshot:
Environmental variables can be used just as easily. To use an environmental variable, simply add $
before it.