Shell script: while variable concatenation
Shell script: while variable concatenation This is my straightforward function: generate_post_data() { cat <<-EOF {"stringData": {}} EOF } This is my other function: generate_curl_body() { template=$(generate_post_data $secret_id) echo "$template" echo "$KVS_VARIABLES" | while read -r key value do template=$(echo "$template" | jq ".stringData += { "$key" : "$value" }") echo $template done } The output is: #Before while -> {"stringData": {}} #1 iteration -> { "stringData": { "VAR1": "VAL1" } } #2 iteration -> { "stringData": { "VAR1": "VAL1", "VAR2": "VAL2" } } #3 iteration -> { "stringData": { "VAR1": "VAL1", "VAR2": "VAL2", "VAR3": "VAL3" } } #After while -> {"stringData": {}} Why template variable is not ...