Variable Substitution

Last published : Jul 27, 2026
Variable references are expanded within quoted strings in all contexts. For example, after
a = "foo"
b = "$a fighters"
the value of b is "foo fighters". Use curly braces to separate a variable name from the adjacent non-whitespace text:
b = "${a}bar"            # b contains "foobar"
Inside quotation marks, represent a quote by escaping it with another quotation mark. Also, inside quotation marks, represent the dollar sign character by escaping it with another dollar sign. For example:
a = """hello"""            # a contains "hello"
b = "$$100"            # b contains $100
The backquote can also be used to assign the output of a shell command to a variable. For example:
datetime = ‘date‘
Related information