(imported topic written by Steve73)
Hi Guys
Having trouble getting my head around this so help would be appreciated.
I need to query a file for a particular entry and pull out that line, the previous line and the following four lines. The enties may also be seen multiple times with different values, although one line will always be constant in the “block”
For instance, the below entries may appear in the log file, they all have one consistent line (Entry Type=WARNING)
How do I then pull this line, the previous line and the following four lines for each time the (Entry Type=WARNING) is seen in the log?:
Date : xx/xx/xxxx Time : xx:xx:xx
Entry Type=WARNING
File: abcdefg, Line: 2345
Details : Machine was rebooted unexpectedly and the component UninstallKey was not found
Component will not be added to software inventory.
Type: Component, Name: abc123
Date : xx/xx/xxxx Time : xx:xx:xx
Entry Type=WARNING
File: zzzzzzzzzzzzzzzzzz, Line: 1234
Details : Machine was rebooted unexpectedly and the component UninstallKey was not found
Component will not be added to software inventory.
Type: Component, Name: zzzzzzzzzzzzzzzz
I’ve been playing around with next line, previous line etc…but not getting very far forward at the moment due to the multiple entries
Cheers
Steve