I am trying to monitor a log using tail -f
command and when ever I come across two different words in different lines on same log, need to capture those and send a email notification:
For example: cat example.txt
:
<event> 12345 </event>
<Description> Exception on file transfer for user ABC </Description>
I need to monitor for event '12345' having 'Exception' for user 'ABC'.
When I do tail -F example.txt | egrep "12345|Exception|ABC"
This
command prints if it sees any one of Grep keyword. Instead it needs to print only if it comes across all keywords in grep.