...

/

Scope: Local Variables

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:

  1. Add the export command to the variable declaration.
  2. 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 ...