How to grep next few lines of a pattern.i.e. whenever a pattern is found the command should also returned the next 2 immediate lines below pattern.
below the lines
2008-10-14 10:32:31,046 [Thread-7] INFO - Added RegisterRead record to DB.
2008-10-14 10:35:50,343 [Thread-6] INFO - Message Subject: EMETER.ALL.DATA.METER.CLEAN
2008-10-14 10:35:50,383 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 62
2008-10-14 10:35:50,384 [Thread-6] INFO - LPBatch: [null, 1-SR0CU, null, DC:Tue Oct 14 15:35:50 UTC 2008, null, null, Mon Oct 13 10:45:00 CDT 2008, Mon Oct 13 15:45:00 UTC 2008,
2008-10-14 10:35:50,391 [Thread-6] INFO - Number of Intervals Not Inserted: 62 / 95
--------------------------------------------------------------------------
I m using the below command to grep a pattern :
cat Archiver* | grep '2008-10-14' | grep 'ERROR' | grep 'CleanLPDataMessage: Missing Intervals'
How to get even lines which are immediately below the grep pattern
2008-10-14 10:35:50,384 [Thread-6] INFO - LPBatch: [null, 1-SR0CU, null, DC:Tue Oct 14 15:35:50 UTC 2008, null, null, Mon Oct 13 10:45:00 CDT 2008, Mon Oct 13 15:45:00 UTC 2008,
2008-10-14 10:35:50,391 [Thread-6] INFO - Number of Intervals Not Inserted: 62 / 95
I mean to say i need a command that will give me next 2 lines immediately after the grep pattern.
when i grep ''2008-10-14' | grep 'ERROR' | grep 'CleanLPDataMessage: Missing Intervals' . it should return this as well as next 4 lines and so on till it finishes