• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 18. Advanced Unix Shell Use: Con... > Customizing Your Shell Environment a...

Customizing Your Shell Environment and Storing Data

Variables are a way of addressing bits of the computer memory so that we can store random pieces of information in it. It would be difficult to do much productive work with a computer if all we could store in any location was one particular, predetermined piece of information. Variables give us the ability to name a region X, and store whatever value we want in X, and change the value whenever we want. Variables in the shell are used both to hold data to be used in commands and programs written in the shell, and to control the behavior of certain aspects of the shell. You've already been introduced peripherally to this second use by way of the path variable, which affects where the shell looks to find executable programs. We'll go into somewhat more detail on this use in the next section, and cover the former later in this chapter.

Environment and Shell Variables

Many shells make a distinction between environment variables and shell variables in one way or another. Both are variables that you can set and use in a shell. The difference is that environment variables are inherited by any programs (such as subshells) that are children of (Unixism for “run by”) that shell, whereas shell variables are not inherited. This might not seem a useful distinction, but there are significant uses for each type. Noninherited shell variables don't cost memory and startup time for subshells, and can be expected to be empty in any shell until they are used to store something. Inherited environment variables, on the other hand, must be copied into the memory space of child programs, taking room and time, and they can be used to pass information between a parent shell and programs that it executes.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint