Created
September 17, 2024 06:30
-
-
Save sepastian/eaa2a6c668330214e1bb1240fe65b932 to your computer and use it in GitHub Desktop.
jq: select objects missing a specific attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# Select all objects which do not contain an attribute named 'message'. | |
# | |
# Background: a log file contains messages from an application and | |
# numerous messages from Mongo db; the messages from Mongo contain | |
# an attribute called 'message', the application logs contain 'msg' | |
# instead. Filter the application logs only by selecting all objects | |
# which do not contain the 'message' attribute. | |
jq 'select(.message|not)' logs.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment