netstat -an|awk '/^tcp/{++S[$NF]}END{for (a in S)print a,S[a]}'
输出结果:
TIME_WAIT 65 ESTABLISHED 99 CLOSING 1 LISTEN 735