标签:int pre 总数 文件内容 success asd for awk print
# cat all.txt
[100] 15:06:03 [SUCCESS] 405b.cloud
Id Name State
----------------------------------------------------
1 i-nd105asdfjkhsfowefwefwfe run
2 i-nd105asdfjkhsfowefwefwfe run
3 i-nd105asdfjkhsfowefwefwfe run
4 i-nd105asdfjkhsfowefwefwfe run
5 i-nd105asdfjkhsfowefwefwfe run
6 i-nd105asdfjkhsfowefwefwfe run
7 i-nd105asdfjkhsfowefwefwfe run
[100] 15:06:03 [SUCCESS] 405b0.cloud
Id Name State
----------------------------------------------------
1 i-nd105asdfjkhsfowefwefwfe run
2 i-nd105asdfjkhsfowefwefwfe run
[100] 15:06:05 [SUCCESS] 405b.cloud
Id Name State
----------------------------------------------------
1 i-nd105asdfjkhsfowefwefwfe run
2 i-nd105asdfjkhsfowefwefwfe run
3 i-nd105asdfjkhsfowefwefwfe run
4 i-nd105asdfjkhsfowefwefwfe run
5 i-nd105asdfjkhsfowefwefwfe run
6 i-nd105asdfjkhsfowefwefwfe run
7 i-nd105asdfjkhsfowefwefwfe run
4 i-nd105asdfjkhsfowefwefwfe run
5 i-nd105asdfjkhsfowefwefwfe run
6 i-nd105asdfjkhsfowefwefwfe run
7 i-nd105asdfjkhsfowefwefwfe run
# awk ‘/SUCCESS/{b=$0;a[b]}/run/{a[b]++}END{for(i in a)print i,a[i]}‘ all.txt
[100] 15:06:03 [SUCCESS] 405b.cloud 7
[100] 15:06:03 [SUCCESS] 405b.cloud 2
[100] 15:06:05 [SUCCESS] 405b.cloud 11
# awk -F ‘[ :]+‘ ‘{print $4,$NF}‘ all.txt
405b.cloud 7
405b.cloud 2
405b.cloud 11
标签:int pre 总数 文件内容 success asd for awk print
原文地址:https://www.cnblogs.com/cfy930721/p/12859191.html