Quantcast
Channel: User David Z - Stack Overflow
Viewing all articles
Browse latest Browse all 49

Answer by David Z for jq pass argument as a key to new field

$
0
0

As the error message suggests, put parentheses around the key:

jq -r --arg k "foo" --arg v "bar"  '.newField += {($k):$v}' myfile

jq requires keys given by expressions (i.e. not literal strings) to be parenthesized (noted in the manual).


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>