#!/usr/bin/gawk -f /^\[/ || /^\]/ { next } { domain = $0 login = $0 gsub("^.+domain\": \"", "", domain) gsub("\",\"login\": .+", "", domain) gsub(".+\",\"login\": \"", "", login) gsub("\" }.?$", "", login) data[login][domain] = 1 } END { for ( login in data ) { domains = "" nb = 0 for ( domain in data[login] ) { nb += 1 domains = (domains "\t" domain) } print nb, login, domains } }