Looks yout output is JSON, for appending to your output object you could use jq for example try this:
cat json.txt | jq --arg VariaA ABCD '. + {VariaA: $VariaA}'
In this case, if json.txt
contains your input:
{
"VariaB": "DONE",
"VariaC": "DONE",
"VariaD": null,
"VariaE": true
}
By using jq --arg VariaA ABCD '. + {VariaA: $VariaA}'
it will then output:
{
"VariaB": "DONE",
"VariaC": "DONE",
"VariaD": null,
"VariaE": true,
"VariaA": "ABCD"
}
If you would like to use more variables you need to use --arg
multiple times, for example:
jq --arg VariaA ABCD --argjson VariaX true '. + {VariaA: $VariaA, VariaX: $VariaX}'
The output will be:
{
"VariaB": "DONE",
"VariaC": "DONE",
"VariaD": null,
"VariaE": true,
"VariaA": "ABCD",
"VariaX": "true"
}
In this example cat json.txt
simulates your command output but worth mention that if you wanted to process an existing file you could use (notice the <
):
jq --arg VariaA ABCD '. + {VariaA: $VariaA}' < file.txt
By doing this you do all in one single process.