Skip to content

Instantly share code, notes, and snippets.

@jage
Last active December 14, 2015 02:28
Show Gist options
  • Save jage/5013373 to your computer and use it in GitHub Desktop.
Save jage/5013373 to your computer and use it in GitHub Desktop.
Group domain counts by main domain.

Data

123 oh.duh.se
9000  duh.se

Output

9123 duh.se 
#!/usr/bin/awk -f
BEGIN { FS = "[.\t]" }
{
domain = $(NF-1) "." $NF
domains[domain] = domains[domain] + $1
}
END {
for (domain in domains)
print domains[domain] "\t" domain
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment