gaurav sharma
gaurav sharma

Reputation: 133

How to concatenate two variables from azure variable group and assign them to one with single quotes

I'm having 2 Variables inside a variable group and their values are as shown below:

cr  2200
tr  cd1200

I would like to assign these two variables to a third variable cd as shown below:

cd  '2200;cd1200;abc.txt'

I'm trying to use below script but it is showing too many arguments. Can someone please help in this.

I'm using below code:

cd = \'"$cr";"$tr";abc.txt\'
echo "$cd"

I need output as:

cd = '2200;cd1200;abc.txt'

Upvotes: 1

Views: 859

Answers (1)

mklement0
mklement0

Reputation: 437090

Using Azure macro syntax ($(<varName>)):

$cd = '$(cr);$(tr);abc.txt'

Note:

  • PowerShell always needs the $ sigil when accessing a variable - even when assigning to it (unlike in POSIX-compatible shells such as Bash).

  • Azure's macro syntax - which textually expands references to Azure variables up front, before PowerShell sees the code, is not be confused with PowerShell's subexpression operator ($(...))

Upvotes: 1

Related Questions