I have jq command like this:
jq --arg ts "$TS" '.Date = $ts, .Marker.Date = $ts, .InfoFromTerminator.Timestamp = $ts'
but it appears to only replace the last item keeping the previous two as is. How do I rewrite the query to replace for all 3 parameters?
Comma is an operator in jq
:
Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then for each of those, the values generate by the expression on the right of the comma.
Changing multiple elements can be done by piping from one filter/assignment in to the next as follows:
jq --arg ts "$TS" '.Date = $ts | .Marker.Date = $ts | .InfoFromTerminator.Timestamp = $ts'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With