[root@tiaobanji ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:50020 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:41224 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:21224 0.0.0.0:* LISTEN
netstat -an|awk '/^tcp/{++S[$NF]}END{for (a in S)print a,S[a]}'
netstat -an |grep 'ESTABLISHED' |grep 'tcp' |wc -l