Usando jq
:
$ cat data.json
{"first": "xxx", "second": "xxx"}
{"first": "yyy", "second": "yyy"}
{"first": "zzz", "second": "zzz"}
$ jq 'with_entries(.value = .key + "_42")' data.json
{
"first": "first_42",
"second": "second_42"
}
{
"first": "first_42",
"second": "second_42"
}
{
"first": "first_42",
"second": "second_42"
}
Com uma variável de shell:
$ number=9
$ jq 'with_entries(.value = .key + "_'$number'")' data.json
{
"first": "first_9",
"second": "second_9"
}
{
"first": "first_9",
"second": "second_9"
}
{
"first": "first_9",
"second": "second_9"
}
Se você preferir uma saída compacta:
$ jq -c 'with_entries(.value = .key + "_'$number'")' data.json
{"first":"first_9","second":"second_9"}
{"first":"first_9","second":"second_9"}
{"first":"first_9","second":"second_9"}