Bash Parameter and Variable Expansion: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 5: Line 5:
=Overview=
=Overview=


A dollar sign ($) that is NOT followed by an open parenthesis initiates parameter or variable expansion. The simplest case of parameter expansion is retrieving the parameter value: the associated value is retrieved by prefixing the parameter's number, character or name with $ or enclosing it in ${...}.
A dollar sign ($) that is NOT followed by an open parenthesis initiates parameter or variable expansion. Parameter and variable expansion is a particular case of [[Bash_Command_Line_Expansion#Parameter_and_Variable_Expansion|command line expansion]]: The simplest case of parameter expansion is retrieving the parameter value: the associated value is retrieved by prefixing the parameter's number, character or name with $ or enclosing it in ${...}.
 
Parameters and variables are not expanded if the string they are included in are enclosed within [[Bash_Concepts#Single_Quotes|single quotes]] or if the leading dollar sign is escaped. Parameters and variables are expanded if the string they are included in is enclosed within [[Bash_Concepts#Double_Quotes|double quotes]].
 
=Difference between $ and ${...}=
=Difference between $ and ${...}=
<font color=darkgray>TODO</font>
<font color=darkgray>TODO</font>

Revision as of 21:16, 18 September 2019

Internal

Overview

A dollar sign ($) that is NOT followed by an open parenthesis initiates parameter or variable expansion. Parameter and variable expansion is a particular case of command line expansion: The simplest case of parameter expansion is retrieving the parameter value: the associated value is retrieved by prefixing the parameter's number, character or name with $ or enclosing it in ${...}.

Parameters and variables are not expanded if the string they are included in are enclosed within single quotes or if the leading dollar sign is escaped. Parameters and variables are expanded if the string they are included in is enclosed within double quotes.

Difference between $ and ${...}

TODO