题解 | #netstat练习4-输出和3306端口建立连接
netstat练习4-输出和3306端口建立连接总的各个状态的数目
https://www.nowcoder.com/practice/5ce76fd1513d4eacae68ad3b2aca1fbb
#!/bin/bash a=`cat nowcoder.txt | grep 3306 | awk '{print $5}' | awk -F ':' '{print $1}' | sort | uniq -c | awk 'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}'` b=`cat nowcoder.txt | grep 3306 | awk '{print $5}' | awk -F ':' '{print $1}' | sort | uniq -c | wc -l` echo "TOTAL_IP $b" echo "ESTABLISHED $a" echo "TOTAL_LINK $a"