14.2. Local variables
Local variables are what you would use in a script for your current shell lifetime, then discard. For instance, a local variable called file_name may have the value loops.doc. This value is important to you but only for the lifetime of your current shell; you do not keep that value if you start another process in your shell or log out. This is good news because you cannot make this type of variable available to other shells or processes.
Table 14.1 contains various variable modes of action.
When using variables some users like to enclose them in curly brackets, which stops the shell from misinterpreting the value of the variable. You do not have to, but this can be useful.
To assign a local variable the format is:
$variable_name=value ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access