Replacing a string with a variable in a cURL command [duplicate] Replacing a string with a variable in a cURL command [duplicate] curl curl

Replacing a string with a variable in a cURL command [duplicate]


The var will not be evaluated because it's w/in single quotes. One way around this is to just smash 3 strings together:

curl -d '{"text" : "'"$var"'Your message here", "bot_id" : "this_is_a_secret_string"}' https://api.groupme.com/v3/bots/post
  • string 1: '{"text" : "'
  • string 2: "$var"
  • string 3: 'Your message here", "bot_id" : "this_is_a_secret_string"}'

NOTE: this will only work if the contents of var are very simple. The expanded string must still be a valid JSON string.