All right, let's talk about variables.
Variables are an important component
of the batch environment.
In scripting, variables are used to separate site-specific data
from generic code.
And the shell comes with standard system variables
in the environment.
You can type n to show the current value
of the environment.
And users can define variables using
export key is value.
Where export is optional, I'm trying
to indicate the fact that it's optional by putting it
between square brackets.
That's how you normally indicate an optional item.
Export means that it is valid in this shell
and also in subshells.
Defining your own variables is mainly useful in scripting.
You'll learn about that later.
And to make variables persistent,
they should be stored in batch startup files.
Let's have a quick look at the environment variables.
So when I type n, I have all my environment variables.
These are variables that I set on the system automatically
while starting up.
One convenient variable is the path variable.
So I'm using echo $PATH to see the value of this variable.
Now, what exactly is the path?
The path is a search path.
Whenever you type a command, Linux
is going to check if this command exists anywhere
in any directory in the search path.
If it does, it will run.
If it does not, then it won't run.
You can also type your own variables.
Color is blue, for instance.
And then refer to it using echo followed
by the name of the variable.
And as you can see, that works.
But if next I'm opening a subshell by typing batch
and I'm doing echo $COLOR, it doesn't work anymore.
Let me exit the subshell and now use export.
Color is blue.
Now, what is the difference?
Well, this time, even if I go into a subshell,
I type echo $COLOR, it still works.
And that's how you can work with variables.
More about variables when we talk about scripting later.