- 论坛徽章:
- 0
|
还想去下重啊!
最后一行我加了一个
china sina 192.168.1.1 8182 tomcat2
:~/monitor/bin> cat test.log
china baidu 172.27.1.84 8183 tomcat3
usa sina 172.27.1.84 8183 tomcat3
china baidu 172.27.1.84 8183 tomcat2
usa sina 172.27.1.84 8183 tomcat2
china baidu 172.27.1.84 8184 tomcat3
usa sina 172.27.1.84 8184 tomcat3
china baidu 172.27.1.84 8182 tomcat2
usa sina 172.27.1.84 8182 tomcat2
china baidu 192.168.1.1 8182 tomcat2
usa sina 192.168.1.1 8182 tomcat2
china sina 192.168.1.1 8182 tomcat2
~/monitor/bin> cat test.log |awk '{a[$3" "$4" "$5]=a[$3" "$4" "$5]","$1;b[$3" "$4" "$5]=b[$3" "$4" "$5]"|"$2}END{for (i in a) {print substr(a,2)" "substr(b,2)" "i}}'
china,usa baidu|sina 172.27.1.84 8182 tomcat2
china,usa baidu|sina 172.27.1.84 8183 tomcat2
china,usa baidu|sina 172.27.1.84 8184 tomcat3
china,usa baidu|sina 172.27.1.84 8183 tomcat3
china,usa,china baidu|sina|sina 192.168.1.1 8182 tomcat2 可不可以让1,2列每个元素之出现一次 类似于 !a[$1]++ |
|