Environment and Shell Variables

When the shell starts a program, it passes that program a set of variables called the environment. The environment is usually a small subset of the variables defined in the shell. Each variable in the environment is called an environment variable.

The variables we have examined thus far have been local variables. Local variables are variables whose value is restricted to a single shell. Local variables are not passed to programs started by the shell.

In addition to local variables and environment variables, there is a third category of variables called shell variables. These are special variables set by the shell that are required for proper operation of the shell. Some shell variables are environment variables, ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.