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 ...
Get Linux and Unix Shell Programming 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.