#!/bin/bash awk '{if ($5 ~ /3306/){ if ($6=="ESTABLISHED"){ es++ } ans++ arr[$5]++ } }END{printf "TOTAL_IP %d\nESTABLISHED %d\nTOTAL_LINK %d",length(arr),es,ans}'