json - Bash scripting, cannot substitute a command line variable -


this small command line script used post json body in http server. finding difficulties pass first command line argument $1 json body.

#!/bin/bash curl  -x post -d '{  "game": 16, "id": $(($1)) }' http://localhost:10000/ 

the command not fail, http body contains

{ "game": 16, "id": $(($1)) }

i want run script ./script 123 , send json body

{  "game": 16, "id": 3 } 

how can using bash?

using single quotes print literal characters. need use double quotes string interpolation. try:

curl  -x post -d "{  \"game\": 16, \"id\": $1 }" http://localhost:10000/ 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -