9.2. Reading User Input
9.2.1. Variables (Review)
In the last chapter we talked about declaring and unsetting variables. Variables are set local to the current shell or as environment variables. Unless your shell script will invoke another script, variables are normally set as local variables within a script. (See in Chapter 8, "Variables" on page 327.)
To extract the value from a variable, preceed the variable with a dollar sign. You can enclose the variable within double quotes and the dollar sign will be interpreted by the shell for variable expansion. Variable expansion is not performed if the variable is enclosed in single quotes.
Example 9.3.
1 name="John Doe" or declare name="John Doe" (local variable) 2 export NAME="John Doe" (global ... |
Get Linux Shells by Example 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.