Skip to content

Instantly share code, notes, and snippets.

@stefaneng
Created March 21, 2018 17:00
Show Gist options
  • Save stefaneng/99db9882821620d9ba17785fdcac6794 to your computer and use it in GitHub Desktop.
Save stefaneng/99db9882821620d9ba17785fdcac6794 to your computer and use it in GitHub Desktop.
jq - Group by count
echo '[{"key": 1}, {"key": 2}, {"key": 1}]' | jq 'group_by (.key)[] | {key: .[0].key, length: length}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment