Count Array Occurrences

Count occurrences of each value in an array and return a frequency map.

Code

General
echo "$arr" | jq 'group_by(.) | map({(.[0]): length}) | add'

Parameters

JSON array

Server

More Bash Snippets