[root@qls /service/scripts]# cat tcp_11.sh
#!/bin/bash
declare -A array_state
Type=$(ss -ant |sed '1d' |awk '{print $1}')
#1.对数组进行的索引赋值
for i in $Type
do
let array_state[$i]++
done
#2.遍历数组
for j in ${!array_state[@]}
do
echo -e "状态: $j\t\t次数: ${array_state[$j]}"
done
数组实现统计TCP中每种状态的数量
最新推荐文章于 2024-07-19 15:41:30 发布