Skip to content
Advertisement

Formating window values with jq

I would like to take the json output of window values from a program. The output of it currently is:

[
  3067,
  584
]
[
  764,
  487
]

But I need it to be formatted like: 3067,584 764x487. How would I go about doing this using jq or other commands?

I’m not very experienced with jq and json formatting in general, so I’m not really sure where to start. I have tried looking this up but am still not really sure how to do it.

Advertisement

Answer

A solution that does not --slurp would be using input for every other array:

jq -r 'join(",")+" "+(input|join("x"))'
3067,584 764x487

Demo

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement