[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [multitail] regex help
Sorry, I sent the last message by mistake.
Laurent TAUPIAC wrote:
>> multitail -em "(\d\.\d\.108\.226|\d\.\d\.108\.226|^\[.+\] \[\S\] )"
My mistake, I've been working too much with perl and python which use this
notation but it is completly wrong for multitail.
>> but I think what you really want is the context option in GNU's grep (i.e. -A or
>> --after-context=NUM), to match the line with the IP address and show the next
>> line... I don't see that option in multitail. You can ask for a new feature.
> Generic line (i mean line not assigned to IP) are not always folling
> something. The 3 line of sample is not ordered. So next line that
> following the matching one is not a valid solution for me.
> I try your alternative, some remarks
> - \d\.\d\.108\.226 will match 22.214.171.124 but not 126.96.36.199, you should wrote \d+\.\d+\.108\.226
> - You had set twice 108.226 but this should be mistype.
> - the \d char classes doesn't work for me in multiltail, but [0-9] do.
> - ^\[.+\] \[\S\] will not match anything unless the second brackets pair hold only one no space char such [a], should put [\S+] to match more stuff, anyway, even corrected, this regexp will match all line since all line start with the format '[date] [level] ', that's why i appended the negative look ahead assertion in my example. eg: start(?!\[) => match start if not followed by \[
> - As for \d, \S is not working in my myltitail.
The equivalents to that notation are something like:
\d [:digit:]+ or [0-9]+
\S [:alpha:]+ or [a-zA-Z]+
\s [:space:]+ or [ \t]+
So the expression becomes:
> Could someone confirm that standard base character classes for regexp
> work or not in multitail ?
> List of base character classes i know
> classes <=> equivalent
> \w <=> [a-zA-Z0-9_]
> \W <=> [^a-zA-Z0-9_]
> \s <=> [ \t\n\r]
> \S <=> [^ \t\n\r]
> \d <=> [0-9]
> \D <=> [^0-9]
No, they will not work. My mistake, as I said.
> I have compiled multitail 4.2.0 on SunOS 5.9 Generic_112233-08 sun4u
> sparc SUNW,Sun-Blade-1000
You can confirm the regular expression syntax by looking at 'man -s 7 regex',
the program is using regcomp/regexec/regerror/regfree (which appear in 'man -s 3