1、总计tcp状态数量
#!/bin/bash
declare -A tcps
for line in `netstat -antpl | grep tcp | awk '{print $6}'`
do
let tcps[$line]++
done
for i in ${!tcps[*]}
do
echo "状态码:$i 个数:${tcps[$i]}"
done
~
[root@localhost ~]# bash tcp.sh
状态码:ESTABLISHED 个数:1
状态码:LISTEN 个数:5
2、