#!/bin/bash awk '/3306/ && /ESTABLISHED/ {split($5, ip, ":"); count[ip[1]]++} END {for (i in count) print count[i], i}' | sort -nr