grep/sort/unqiu/sed
# netstat -n |grep -E '^tcp'|awk '{print $NF}' |sort |uniq -c
sed
# netstat -n | awk '/^tcp/ {++s[$NF]} END {for (i in s) print s[i], i}'
# netstat -n |grep -E '^tcp'|awk '{print $NF}' |sort |uniq -c
# netstat -n | awk '/^tcp/ {++s[$NF]} END {for (i in s) print s[i], i}'