Difference between revisions of "CLI Variables"
Jump to navigation
Jump to search
(→Quiz) |
|||
Line 1: | Line 1: | ||
− | === Assignment | + | == Commands == |
+ | env = Shows you the environment variables that are currently defined. | ||
+ | echo = Displays a line of text. | ||
+ | |||
+ | == Examples == | ||
+ | === Example #1 - Assignment === | ||
To assign a value to an environment variable you simply type the variable name, '=', then the value. For example, | To assign a value to an environment variable you simply type the variable name, '=', then the value. For example, | ||
FOO=Rob | FOO=Rob | ||
BAR=Love | BAR=Love | ||
+ | === Example #2 - Derefrencing === | ||
To get the value of the variable (i.e. dereference) you place a '$' before the variable name. | To get the value of the variable (i.e. dereference) you place a '$' before the variable name. | ||
Line 11: | Line 17: | ||
#Love | #Love | ||
− | + | == Quiz == | |
− | |||
− | |||
− | |||
− | |||
# What is the value of the "USER" environment variable? | # What is the value of the "USER" environment variable? | ||
# What is the value of the "HOSTNAME" environment variable? | # What is the value of the "HOSTNAME" environment variable? | ||
Line 23: | Line 25: | ||
# Using the GEEK environment variable, how would you echo the statement, "I think that FREE GEEK is the best!"? | # Using the GEEK environment variable, how would you echo the statement, "I think that FREE GEEK is the best!"? | ||
# Can you tab-complete environment variables? | # Can you tab-complete environment variables? | ||
+ | |||
+ | == Instructor Notes == | ||
+ | There needs to be a little into paragraph and the examples could be flushed out more. | ||
[[Category:CLI Quizes]] | [[Category:CLI Quizes]] | ||
[[Category:Classes]] | [[Category:Classes]] |
Revision as of 11:58, 19 April 2008
Commands
env = Shows you the environment variables that are currently defined. echo = Displays a line of text.
Examples
Example #1 - Assignment
To assign a value to an environment variable you simply type the variable name, '=', then the value. For example,
FOO=Rob BAR=Love
Example #2 - Derefrencing
To get the value of the variable (i.e. dereference) you place a '$' before the variable name.
#echo $FOO #Rob #echo $BAR #Love
Quiz
- What is the value of the "USER" environment variable?
- What is the value of the "HOSTNAME" environment variable?
- What is the value of the "PWD" environment variable?
- What is the value of the "HOME" environment variable?
- How would you create an environment variable named GEEK that has the contents- "FREE GEEK is the best!"?
- Using the GEEK environment variable, how would you echo the statement, "I think that FREE GEEK is the best!"?
- Can you tab-complete environment variables?
Instructor Notes
There needs to be a little into paragraph and the examples could be flushed out more.