Skip to content

Instantly share code, notes, and snippets.

@erichsu
Forked from stefaneng/jq_group_by_count.sh
Created January 28, 2021 14:29
Show Gist options
  • Save erichsu/a65774594171a37b228088b353cde156 to your computer and use it in GitHub Desktop.
Save erichsu/a65774594171a37b228088b353cde156 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