Q:

grep log file for only X newest entries of special value

I want to get (only!)  the three newest entries with type "ERROR:" from a log file. 
(Or the last 5 warnings, etc...)
The latest three entries from botton to top, the log file is written permanently. 
How can i get the outout of a log file like this? 
example log file:
INFO: message text line 1.....
      message text line 2.....
ERROR: message text line 1.....
       message text line 2.....
WARNING: message text line 1.....
         message text line 2.....
ERROR: message text line 1.....
       message text line 2.....
INFO: message text line 1.....
      message text line 2.....
INFO: message text line 1.....
      message text line 2.....
WARNING: message text line 1.....
         message text line 2.....
etc...

A:

This will give you LAST 3  ERROR OR WARNING.  hope this helps
egrep "ERROR|WARNING" YOURFILE | tail -n 3
Tharanga Abeyseela

