Previous Topic | Table of Contents | Next Topic

Variable Substitution

Variable substitution is typically used to pass the value of a variable as an argument to a command. For example: echo $message

The ${...} variations are used to isolate the variable substitution from whatever text (including any colons) may follow.

Reference
Meaning
$var Value of variable var
${var} Same as $var except separated from anything following.
$var[expr] Value of var, indexed by an arbitrarily complex expression.
${var[expr]} Same as $var[expr] except separated from anything following.
$#var Number of words in var.
${#var} Same as $#var except isolated from anything following.
$?var 1 if var exists; 0 otherwise.
${?var} Same as $?var except isolated from anything following.
$procname( argument list ) Procedure reference, used as a variable substitution. The arguments are expressions, separated by commas. Any value returned by the procedure will be substituted in place.
$< Pseudo-variable result of reading one line from stdin each time it’s evaluated. Same as $getline.
$* Same as $argv
$0 .. $9 Same as $argv[0] .. $argv[9]



Previous Topic | Table of Contents | Next Topic

Copyright © 1988-2003 by Hamilton Laboratories. All rights reserved.