Scope: Local Variables
Learn about local variables in detail.
We'll cover the following...
Local variables
We considered user-defined variables. We can declare them in several ways. Depending on our choice, the new variable comes to the local scope or global scope (environment).
There are two ways to declare the global scope variable:
- Add the
export
command to the variable declaration. - Pass the variable to the program when launching it. We can do it with the
env
utility when using a shell other than Bash.
If we do not apply any of these ways, our variable comes to the local scope. A variable of this kind is called a local variable and ...