Sponsored Content
Top Forums Shell Programming and Scripting Only Regex pattern match help Post 302887365 by radioactive9 on Friday 7th of February 2014 03:41:57 AM
Old 02-07-2014
[Solved] 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 thatSmilie. 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 Smilie

Here is the pattern

Code:
 
[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
Code:
 
^.*\[(.*)\].*\"(.*)\".*(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

Last edited by vbe; 02-07-2014 at 05:16 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match first pattern first then extract second pattern match

My input file: <accession>Q91G55</accession> <name>043L_IIV6</name> <protein> <recommendedName> <location> <position position="294"/> </location> <fullName>Uncharacterized protein 043L</fullName> <accession>P18556</accession> <name>1106L_ASFB7</name> <protein> <recommendedName>... (5 Replies)
Discussion started by: patrick87
5 Replies

2. Shell Programming and Scripting

AWK match $1 $2 pattern in file 1 to $1 $2 pattern in file2

Hi, I have 2 files that I have modified to basically match each other, however I want to determine what (if any) line in file 1 does not exist in file 2. I need to match column $1 and $2 as a single string in file1 to $1 and $2 in file2 as these two columns create a match. I'm stuck in an AWK... (9 Replies)
Discussion started by: right_coaster
9 Replies

3. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

4. Shell Programming and Scripting

Awk to match a pattern and perform a search after the first pattern

Hello Guyz I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline ABC DEF LMN EFG HIJ LMN OPQ In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies

5. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

6. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

7. Shell Programming and Scripting

Regex: print matched line and exact pattern match

Hi experts, I have a file with regexes which is used for automatic searches on several files (40+ GB). To do some postprocessing with the grep result I need the matching line as well as the match itself. I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Discussion started by: stresing
2 Replies

8. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

9. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

10. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies
VARNISHSIZES(1) 														   VARNISHSIZES(1)

NAME
varnishsizes - Varnish object size request histogram SYNOPSIS
varnishsizes [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-m tag:regex ...] [-n varnish_name] [-r file] [-V] [-w delay] [-X regex] [-x tag] DESCRIPTION
The varnishsizes utility reads varnishd(1) shared memory logs and presents a continuously updated histogram showing the distribution of the last N requests by their processing. The value of N and the vertical scale are displayed in the top left corner. The horizontal scale is a logarithmic representation of bytes. Hits are marked with a pipe character ("|"), and misses are marked with a hash character ("#"). The following options are available: -b Include log entries which result from communication with a backend server. If neither -b nor -c is specified, varnishsizes acts as if they both were. -C Ignore case when matching regular expressions. -c Include log entries which result from communication with a client. If neither -b nor -c is specified, varnishsizes acts as if they both were. -d Process old log entries on startup. Normally, varnishsizes will only process entries which are written to the log after it starts. -I regex Include log entries which match the specified regular expression. If neither -I nor -i is specified, all log entries are included. -i tag Include log entries with the specified tag. If neither -I nor -i is specified, all log entries are included. -m tag:regex only list record where tag matches regex. Multiple -m options are AND-ed together. -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. -r file Read log entries from file instead of shared memory. -V Display the version number and exit. -w delay Wait at least delay seconds between each update. The default is 1. file instead of displaying them. The file will be overwritten unless the -a option was specified. -X regex Exclude log entries which match the specified regular expression. -x tag Exclude log entries with the specified tag. SEE ALSO
o varnishd(1) o varnishlog(1) o varnishncsa(1) o varnishstat(1) o varnishtop(1) HISTORY
The varnishsizes utility was developed by Kristian Lyngstol based on varnishhist. This manual page was written by Kristian Lyngstol, Dag-Erling Smorgrav and Per Buer. COPYRIGHT
This document is licensed under the same licence as Varnish itself. See LICENCE for details. o Copyright (c) 2010 Varnish Software AS AUTHOR
Dag Erling Smorgrav, Kristian Lyngstol, Per Buer 1.0 2010-05-31 VARNISHSIZES(1)
All times are GMT -4. The time now is 09:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy