I want something like
jq 'select(.x in [2,4])' <<<'[{"x":1}, {"x": 2}, {"x": 3}, {"x": 4}]'
[{"x": 2}, {"x": 4}]
How do I do this?
Here's an efficient solution that has the advantage of also being simple and concise:
[2,4] as $list
| map(.x as $x | select( any($list[]; . == $x )))
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