Difference between revisions of "CLI Variables"

From FreekiWiki
Jump to navigation Jump to search
Line 16: Line 16:
  
 
=== Quiz ===
 
=== 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?
 
# 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!"?
 
# 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!"?
 
# 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?
  
 
[[Category:CLI Quizes]]
 
[[Category:CLI Quizes]]
 
[[Category:Classes]]
 
[[Category:Classes]]

Revision as of 11:51, 19 April 2008

Assignment and Dereferencing

To assign a value to an environment variable you simply type the variable name, '=', then the value. For example,

FOO=Rob
BAR=Love

To get the value of the variable (i.e. dereference) you place a '$' before the variable name.

#echo $FOO
#Rob
#echo $BAR
#Love

Commands

env  = Shows you the environment variables that are currently defined.
echo = Displays a line of text.

Quiz

  1. What is the value of the "USER" environment variable?
  2. What is the value of the "HOSTNAME" environment variable?
  3. What is the value of the "PWD" environment variable?
  4. What is the value of the "HOME" environment variable?
  5. How would you create an environment variable named GEEK that has the contents- "FREE GEEK is the best!"?
  6. Using the GEEK environment variable, how would you echo the statement, "I think that FREE GEEK is the best!"?
  7. Can you tab-complete environment variables?