shell - Passed command line argument in double quotes to curl -
my script taking command line argument , needs pass curl command in double quotes. simplified version of tried far:
json=$1; echo $json; curl -x post -d '{"asin":\"$json\", "template":"bolt","version":"1d"}' -h "content-type: application/json" http://someurl
but not working. please help
$-variables in single quoted strings don't expanded. -d argument needs in double quotes, or @ least $json part needs be:
curl -x post -d '{"asin":"'"$json"'", "template":"bolt","version":"1d"}' -h "content-type: application/json" http://someurl '-terminates single-quoted string, "$json" follows, , ' starts adjacent single quoted string.
the "$json" variable shouldn't expand string containing unescaped double quotes or resulting json broken.
Comments
Post a Comment