Hi guys
I have an log from an regular application processing where the processing is done every 10 minutes and is written to the same log which is rotated on daily basis.
the block of log starts always with "Starting" and ends with a certain pattern "Completed"
The catch is I want to create an shell script for checks if an Oracle ORA error is found in this log block and if yes this is collected and send after whole log was checked to several recipients.
I have an idea how to do the whole thing what I have an issue is the part of script which checks in the log block for the ORA message
how does the log look like:
Starting
14:10:*
14:10:* some stuff
14:10:*
14:10:* blabla
Completed
Starting
14:20:*
14:20:* some stuff
14:20:* ORA- error constaint voilated
14:20:* blabla
Completed
Starting
14:30:*
14:30:* some stuff
14:30:* blabla
14:30:* blabla
Completed
Starting
14:40:*
14:40:* some stuff
14:40:* ORA- error constaint voilated
14:40:* blabla
Completed
Starting
14:50:*
14:50:* some stuff
14:50:* blabla
14:530:* blabla
Completed
the final report should contain in the blocks
Starting
14:20:*
14:20:* some stuff
14:20:* ORA- error constaint voilated
14:20:* blabla
Completed
Starting
14:40:*
14:40:* some stuff
14:40:* ORA- error constaint voilated
14:40:* blabla
Completed
keep in mind that the number of lines between Starting and Completed isnt fixed but may change
the bocks can be extracted like this: sed -n '/StartPattern/,/EndPattern/p' FileName
$ awk '/abc/{flag=1;next}/mno/{flag=0}flag' file
now I could do the grep -A50 -B50 'ORA-' file >> report
but this would extract more what I like, I want to make the report clean.
One idea was maybe to get the Line number when the error ORA appers and then do an row-1 until Starting is found and row+1 until the Completed is found and get those line numbers and to an sed -n 'X,Yp' file
Any suggestion thank you in advance.
Martin