Awk 2023.4.24 2024.9.10 38 1 Awk awk按照key进行分组求和 参考文档 Awk Awk awk按照key进行分组求和 1 netstat -tnlp|awk '{print $4}'|grep ':'|grep -v '::'|awk -F ':' '{connect[$1]++;}END{printf "[";for (i in connect){printf "{\"%s\":\"%s\"},",i,connect[i]};print "]"}'|sed 's/,]$/]/' 参考文档 liuliancao https://blog.liuliancao.com/roams/2023-04-24-awk/ CC BY-NC-SA 4.0