I have a log file which prints the following lines:

01:15:21.882 DEBUG [SampleProcess] 
Sample Message
01:15:21.882 DEBUG [SampleProcess1] 
Summary Report
Sample Text1: 126
Sample Text2: 2330
Sample Text3: 2331
Sample Text4: 0
01:15:21.883 DEBUG [SampleProcess2] 

I was able to extract the Summary Report by using the below sed command sed -n '/Summary Report/,/Sample Text4/p' samplefile.log However, I also want to print the timestamp when the Sample Report was generated.

So, currently with sed -n '/Summary Report/,/Sample Text4/p' samplefile.log, I see the output as

Summary Report
    Sample Text1: 126
    Sample Text2: 2330
    Sample Text3: 2331
    Sample Text4: 0

I want the output as

01:15:21.882 DEBUG [SampleProcess1] 
    Summary Report
    Sample Text1: 126
    Sample Text2: 2330
    Sample Text3: 2331
    Sample Text4: 0

Kindly provide your guidance. Thanks.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.