Hanamant
Hanamant

Reputation: 44

how to use the bash variable in single quotes

I am having bash code like below

'payload={"text": "failure with ${VAR} failed for"}'

but the variable is not resolving to actual value Please don't put negative as I don't have that much experience in Bash so.

Upvotes: 1

Views: 4462

Answers (2)

user1934428
user1934428

Reputation: 22356

Variables don't expand in single quotes, which means that you simply have to ensure that they are not single-quoted. You have several possibilities, for instance:

'payload={"text": "failure with '"${VAR}"' failed for"}'

or

"payload={\"text\": \"failure with ${VAR} failed for\"}"

Upvotes: 7

过过招
过过招

Reputation: 4244

You can concatenate variables directly.

'payload={"text": "failure with '${VAR}' failed for"}'

Upvotes: 0

Related Questions