I have a large amount of long irregular logs that look like this:
###<date> errortext <errorcode-xxxxx>
errortext
errortext
errortext
errortext
###<date> errortext <errorcode-yyyy>
errortext
errortext
###<date> errortext <errorcode-<zzzzzzz>
errortext
errortext
errortext
errortext
errortext
errortext
errortext
etc
The length is irregular, and errors with the same error codes need to be found using grep/awk/sed or similar methods.
I need to split these documents by error code, printing all errors of one code into one document.
When I try to find a whole error code segment with a line like:
sed -n '/#</{:start /###/!{N;b start};/<errorcode-024332>/p}' file
The problem with lines like the above is that it will only print the line that includes the "errorcode-024332" and not all the errorcode until the next segment start(with the delimiter "###" in this case).
How do I achieve this?