jq count the number of items in json by a specific key
Here’s one solution (assuming the input is a stream of valid JSON objects) and that you invoke jq with the -s option: map({ItemId: .Properties.ItmId}) # extract the ItmID values | group_by(.ItemId) # group by “ItemId” | map({ItemId: .[0].ItemId, Count: length}) # store the counts | .[] # convert to a stream A slightly more memory-efficient … Read more