I’m trying to get a human-readable representation of thread siblings.
I have following output: output.
undercloud) [stack@undercloud ~]$ os baremetal introspection data save compute0 |jq '.numa_topology.cpus[] | select(.numa_node == 0) | .thread_siblings'
[
11,
51
]
[
9,
49
]
[
58,
18
],
....
...
..
.
(undercloud) [stack@undercloud ~]$
Common View: Common view.
(undercloud) [stack@undercloud ~]$ os baremetal introspection data save compute0 | jq '.numa_topology.cpus'
[
{
"thread_siblings": [
11,
51
],
"cpu": 11,
"numa_node": 0
},
{
"thread_siblings": [
9,
49
],
"cpu": 9,
"numa_node": 0
},
{
"thread_siblings": [
58,
18
],
"cpu": 18,
"numa_node": 0
},
....
...
..
.
(undercloud) [stack@undercloud ~]$
I want to get next output:
0, 1, 2, 3, 4, ... etc
40 41 42 43 44 ... etc
Is it possible to get such a list using jq
? Perhaps with subsequent awk/sed
processing.
P.S.: JSON moved to pastebin because the stackoverflow engine thinks my post has little detail and a lot of code, but I think I gave a pretty specific question and it doesn’t fall into the XY problem.
3
Answers
Here’s an approach that sorts each
.thread_siblings
array, and then the array of all sibling arrays, transposes it to get all first numbers in one array, and all last ones in another, and joins both with a glue string:Demo
You’re looking for something like this:
If I understand correctly, here’s another way to do it using
--raw-output
.Example output:
Try it on jqplay.org.