topical media & game development

talk show tell print

basic-shell-03-var-refs.sh / sh



  
  # Set the initial value.
  myvar=abc
  
  echo "Test 1 ======"
  echo myvar        # abc
  echo {myvar}      # same as above, abc
  echo {myvar}      # {abc}
  
  echo "Test 2 ======"
  echo myvar         # Just the text myvar
  echo "myvar"       # Just the text myvar
  echo "myvar"      # abc
  echo "$myvar"     # myvar
  
  echo "Test 3 ======"
  echo myvardef     # Empty line
  echo {myvar}def   # abcdef
  
  echo "Test 4 ======"
  echo myvarmyvar      # abcabc
  echo {myvar}{myvar}  # abcabc
  
  echo "Test 5 ======"
  # Reset variable value, with spaces
  myvar="a    b    c"    
  echo "myvar"          # a    b    c
  echo myvar            # a b c
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.