Only Regex pattern match help

Hi

We have a tool to monitor logs in our environment. The tool accepts log pattern match only using regex and I accept I am a n00b in that:confused:. I had been banging my head to make it work without much success and at last had to turn on to my last option to post it here. I had got great helps in the past and hoping I will get the same again :slight_smile:

Here is the pattern

 
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 500
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 200 587
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 5020 1221 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 531 206 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 5991 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 300 abcd123

The requirement is

I need a regex pattern match which should only pick 5XX marked bold and discard any other pattern. 5XX is 500 - 599

Line - 1 Line - 2 and Line - 4 should be picked and rest should go unmatched

I thought of this

 
^.*\[(.*)\].*\"(.*)\".*(5[0-9][0-9])[^0-9].*$
 

But this is missing out in first and second line where the line ends with 500

Please help

[user@host ~]$ cat file
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 500
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 200 587
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 5020 1221 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 531 206 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 5991 abcd123
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 300 abcd123
[user@host ~]$ egrep " 5[0-9][0-9]( |$)" file
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 500
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 200 587
[26/Jan/2014:09:47:34 +0000] "GET /etc/designs/dlg/clientlibs/commons/base/img/close-icon.png HTTP/1.1" 531 206 abcd123
[user@host ~]$
1 Like

I love you man. I love you

You are a real life saver buddy

Here is what I used

 
^.*\[(.*\].*\".*\".*5[0-9][0-9])(\s|$)(.*)