CHAPTER 7Indirect Reference Variables

It is possible to set a normal (direct) variable in three ways:

  • Directly, by assigning it a value
  • By storing the output of a command
  • By storing the results of some type of calculation

In all of these cases, although you might not know a variable's value in advance of any given point, you do know the name of the variable that is to receive the value.

For example, AGE=36 is a direct variable assignment. The value of 36 might change at a later stage and it may also have some calculation applied to it, but the variable name AGE will not change.

In some cases, however, you may need the ability to generate variable names on the fly. You may not know the number or names of variables you are going to need at the ...

Get Expert Shell Scripting 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.