一个log文件中,有大量有一定格式且重复的内容,如:
test:
aaaaaaa,
1error:bbbbbb
test:
aaaaaaa,
1error:bbbbbb
test:
qqqqqqq,
2error:cccccc
test:
qqqqqqq,
2error:cccccc
test:
xxxxxxx,
3error:cccccc
要提取的内容均是以test开头,最后一行以xxerror:xx结尾。
如何用shell编程对该文件中重复内容进行提取、去重并计数,使输出如下:
test:
aaaaaaa,
1error:bbbbbb
count:2
test:
qqqqqqq,
2error:cccccc
count:2
test:
xxxxxxx,
3error:cccccc
count:1