DistributedNetworks DistributedNetworks


Shell Variables   «Prev 

Using Variable Substitution

Variable Substitution returns the value of the variable enclosed in braces
Variable Substitution returns the value of the variable enclosed in braces

  1. $ {FLIGHT}: Basic substitution returns the value of the variable enclosed in braces.
  2. $ {PHONE:-1-800-555-1212}: Returns the value of 1-800-555-1212 if the variable PHONE has no value (is not set).
  3. $ {PHONE:-1-800-555-1212}: If the variable PHONE has no value (is not set), this statement returns the value of 1-800-555-1212 and sets the value of PHONE to 1-800-555-1212.
  4. $ {CREDIT_OK:+Approved}: Returns the string “Approved” if the variable CREDIT_OK is set; otherwise a blank string is returned.
  5. $ {#NAME}: Returns the length of the string contained in the variable NAME.
  6. $ {#NAME:?A name is not assigned}: Returns the error message text “A name is not assigned” if the variable NAME has no value (compare to using the :- notation).