en:cs:bash:variable
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:cs:bash:variable [2025/04/26 12:38] – created ulascemh | en:cs:bash:variable [2025/04/26 12:40] (current) – ulascemh | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Local Variables ===== | ===== Local Variables ===== | ||
- | ```bash | + | < |
foo=one | foo=one | ||
Line 21: | Line 21: | ||
# This will print '' | # This will print '' | ||
echo $foo | echo $foo | ||
- | ``` | + | </ |
===== Environment Variables ===== | ===== Environment Variables ===== | ||
Line 27: | Line 27: | ||
One feature we will use for Scope is the system that exists in all Unix systems. For example, when we call a program in a script, all environment variables are copied into the scope of that program. In short, the variables we define in the called script can only be accessed if they are environment variables. | One feature we will use for Scope is the system that exists in all Unix systems. For example, when we call a program in a script, all environment variables are copied into the scope of that program. In short, the variables we define in the called script can only be accessed if they are environment variables. | ||
- | ```bash | + | < |
# create a new variable and set it: | # create a new variable and set it: | ||
# -> This is a normal variable, not an environment variable! | # -> This is a normal variable, not an environment variable! | ||
Line 34: | Line 34: | ||
# Let's make it visible to all sub-processes by converting it to an environment variable: | # Let's make it visible to all sub-processes by converting it to an environment variable: | ||
export test_variable | export test_variable | ||
- | ``` | + | </ |
<wrap onlyprint> | <wrap onlyprint> |
en/cs/bash/variable.txt · Last modified: 2025/04/26 12:40 by ulascemh