I am trying to write a script (well, a one-liner really) to extract the important part of a debug log, so that people can easily send it to me instead of dragging me onto a conference call or having to collect the whole file. I can tell them what to do in less or vi to get the info, but I would like it as a command if possible.
In less
:
$ less filename
G
?Server\ version
/SEVERE
[read line including first match for SEVERE from this point, stop reading when get to next instance of SEVERE]
I have been trying to write an awk
command that will accomplish this, and it is not going well.
This is as close as I got that does not work:
awk '{if (/Server version/) {chunk=""} else {chunk=chunk $0 RS}} END {printf "%s", chunk}' filename | awk '/SEVERE/,/SEVERE/'
awk
doesn't seem to like using the same pattern for the beginning and end of the part I want printed out at the end.
I am open to using other tools, but for my use case, I need to use utilities that come by default on RHEL7.
If the info helps at all, I am looking at apache tomcat debug logs.