Home > other >  how to use the bash variable in single quotes
how to use the bash variable in single quotes

Time:05-24

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.

CodePudding user response:

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\"}"

CodePudding user response:

You can concatenate variables directly.

'payload={"text": "failure with '${VAR}' failed for"}'
  •  Tags:  
  • bash
  • Related