netstat -na | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

netstat -an|grep  ^tcp|awk '{print $NF}'|sort -nr|uniq -c