Get the latest 5 events
Sort by timestamp, newest first, and take the first 5
jq 'sort_by(.timestamp) | reverse | .[0:5]' events.json
More jq commands
-
jq -r '.[] | [.id, .name, .status] | @csv' data.jsonPrint id, name and status as CSV lines
-
jq '[.[] | . + {"env": "prod"}]' items.jsonAdd env: prod to every array item
-
jq 'walk(if type == "string" then ascii_downcase else . end)' data.jsonConvert every string value in the document to lowercase
-
cat data.json | jq '.'Format and colorize a JSON file
-
cat data.json | jq '.items[] | select(.status == "Running")'Select items whose status field equals Running