I need to count the occurance of a multiline pattern of 3 lines in a htm file. The problem is that I have a fix content in line 1 and 3, however the content of line 2 is not fix, it can change (the file is a log). Here's an example of what I mean:
fix line 1
changing line 2
fix line 3
I have searched for solutions, but haven't found a 100% suitable one... pcregrep
should work, but how do I include the changing line 2? So far I can only look for two fix lines. The code itself is the problem here, but the output is very easy to use for me.
pcregrep -Mc '^line1\n^line2\n^line3' file
Or should I use sed
instead? The code works, but the output is complicated to use. How do I handle it to count the occurances of this multiline pattern? Because there has to be just one line between line 1 and 3, that's important.
sed -n '/^line1/,/^line3/=' file
I hope you can help me. Thank you very much!