#!/usr/bin/awk -f # The input file format should be: # login password domain # # (the "password" field won't actually be used) BEGIN { OFS = "\t" } { login = $1 domain = $3 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 } }