en:cs:bash:variable
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:cs:bash:variable [2024/07/09 20:56] – created - external edit 127.0.0.1 | 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> | ||
<wrap hide> | <wrap hide> | ||
- | ===== NOTLAR | + | ===== EDITOR NOTES ===== |
</ | </ |
en/cs/bash/variable.1720558598.txt.gz · Last modified: 2024/07/09 20:56 by 127.0.0.1