Questions tagged [jq]
Questions about the command line JSON processing tool jq.
406 questions
1 vote
2 answers
83 views
How to pretty print one column of piped input?
bash 4.4.20 and jq-1.6 on RHEL8 I get this nice output from jq and column. Hard to read, though. pgbackrest info --output=json \ | jq -r '.[] | .backup[] | "\(.type) \(.label) \(.info.delta)...
2 votes
1 answer
89 views
Append to matching children of an arbitrarily deep array
I am attempting to edit an OpenAPI specification by changing all parameters to be nullable. A parameter definition looks like this: { "name": "foo", "required": ...
0 votes
1 answer
195 views
Why did I got jq: 1 compile error?
I tried this script to see kubernetes volumes usage k get pods -n elk | jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) ''{name: .pvcRef.name, capacityBytes, usedBytes, ...
6 votes
2 answers
390 views
Update object inside array inside another JSON object
I have a huge JSON object with an array of objects inside it. I have to add key:value pair to a specific object in the array. For example, let the input object is: { "a": { "b&...
1 vote
1 answer
2k views
jq select multiple elements from an array
I have a JSON which looks like: { "type": "server-firmwareinventory-list-1", "members": [ { "type": "sever-hardware-firmware-1", &...
3 votes
2 answers
2k views
jq create object with property name from variable
$ n="foo"; echo "{}" | jq --arg n "$n" '. += { "$n": $n }' { "$n": "foo" } My reading of https://jqlang.github.io/jq/manual/#types-and-...
11 votes
3 answers
853 views
jq - ip addr show in tabular format
I'd like to pretty print the ip addresses and show the output in in tabular format, including all the meta data such as valid_lft, temporary, etc. I figured out that ip -j addr show eth0 is giving me ...
3 votes
2 answers
383 views
Pairing and structuring elements from a JSON array, with jq
[ { "key": "@timestamp", "value": "2024-08-21 03:02:57.871" }, { "key": "@message", "value": "Aug 21, ...