Creating Shell Variables
Let’s start by setting up a shell variable for the active session. To accomplish this, all we need to do is provide a name and a value. We’ll stick to tradition and set the variable to a simple string while maintaining the variable name in all caps.
Now there is a shell variable. Despite being present in our current session, this variable won’t be shared with any child processes.
In the set output, we can observe this by grepping for our new variable:
By performing the identical thing with printenv, we can confirm that this is not an environmental variable:
There should be no output produced.
Batch Script – Environment Variables
Environment variables are a collection of dynamic named values that are saved on the system and utilized by programs that are running in shells or subshells on Linux and Unix-based systems. An environment variable is, to put it simply, a variable with a name and a corresponding value.
You can alter the system’s operation and the actions of its programs by using environment variables. For instance, the environment variable may keep track of the default text editor or browser, the location of executable files, or the keyboard layout and system locale.