Shell Expansion
The basic concept of shell expansion is that the shell substitutes certain expressions that have been typed on the command line with some expanded text. In earlier chapters, we learned to use shell expansion constructs such as wildcards and escape sequences. In this topic, we will learn about several more mechanisms for expansions that the shell provides.
Environment Variables and Variable Expansion
Environment variables in Bash are similar in function to variables in most programming languages; they are names to which values are associated. An environment variable is initialized with the following syntax:
VARNAME=VALUE
There is no space on either side of the equals symbol, and the value follows the same rules of the shell as those with respect to quoting, escape sequences, and wildcards (and other expansions). The value of an environment variable is expanded with the $
symbol, as shown here:
robin ~ $ ANSWER=42 robin ~ $ echo The answer is "...