Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 522

how to select Any of available fields with jq?

$
0
0

I'm trying to filter some journald logs which might have some-what similar information in different keys.

journalctl -o json | head -n 1000 | jq '.UNIT, .USER_UNIT, ._SYSTEMD_UNIT

Those 3 keys might have the unit name, depending on how the log entry was created (by the unit, by the system starting the unit, etc)... I don't care about this and just want to get the related-unit.

How can I extract something like jq '.UNIT OR .USER_UNIT OR ._SYSTEMD_UNIT (or doesn't work as it is a boolean converter to be used in select(), and | tries to route to a function)

I also cannot use + because when .UNIT key is present there will be something i don't want to collect in ._SYSTEMD_UNIT.


Viewing all articles
Browse latest Browse all 522

Trending Articles



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