Hello, i have a little problem with correct formatting of my output in ubuntu. It is output from very large log file (100MB - 3GB). My problem is as follows:
Entry in log has from 8 up to xxx lines. First and last line carry always the same information but different parameters. I need to only show those entries(those multiple lines), that have specific parameters in last line. Entries are separated by "--" which is done by previous grep-ing
Format sample:
--
First line of FIRST ENTRY (contains string "INSERT")
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
Last line of FIRST ENTRY (contains string "sample1")
--
First line of SECOND ENTRY (contains string "INSERT")
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
Last line of SECOND ENTRY (contains string "sample2")
--
First line of THIRD ENTRY (contains string "INSERT")
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
Last line of THIRD ENTRY (contains string "sample1")
In this partial output, only entries FIRST and THIRD contain desired string in last line so those are the only ones i need. Therefore i need to only output those two. Problem is, that in the first line parameters are variable and unpredictable. The first line contains time stamp, session info and so on, which cant be foretold although first line always contains string "INSERT" at the very beginning of line (INSERT,next parameter,next parameter,...).
So right now i have script that returns above described output, and i need to add another pipe and only print specific entries as described above.
Something like: print lines from string "sample1" upwards up to first occurrence of string "INSERT".
Can anyone help me with this one?



Adv Reply


Bookmarks