Skip to content

Instantly share code, notes, and snippets.

@stefaneng
Created March 21, 2018 17:00
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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