I'm trying an include/exclude list in 1 hit for a wrapper script
I want to get a hit on the string "exception" but exclude all the
other java bit's that are ok
egrep "[^(javax.mail.MessagingException)+|^(java.net.UnknownHost)+|^
(nested exception is )+]?exception"
kind of works; but not excluding this pattern:
nested exception is:
I'm basically trying to exclude all of this, but catch lines with
"exception"
[17/10/09 18:30:16:524 NZDT] 0000005b SystemErr R
javax.mail.MessagingException: Unknown SMTP host: mailhost;
nested exception is:
java.net.UnknownHostException: mailhost
|
|
0
|
|
|
|
Reply
|
snogfest_hosebeast (252)
|
10/29/2009 2:09:26 AM |
|
Mebbe:
egrep "^[javax.mail.MessagingException|java.net.UnknownHost|nested
exception is]?exception"
Hope this helps
Casey
On Oct 28, 9:09=A0pm, Henry <snogfest_hosebe...@yahoo.com> wrote:
> I'm trying an include/exclude list in 1 hit for a wrapper script
> I want to get a hit on the string "exception" but exclude all the
> other java bit's that are ok
>
> egrep "[^(javax.mail.MessagingException)+|^(java.net.UnknownHost)+|^
> (nested exception is )+]?exception"
>
> kind of works; but not excluding this pattern:
> nested exception is:
>
> I'm basically trying to exclude all of this, but catch lines with
> "exception"
>
> [17/10/09 18:30:16:524 NZDT] 0000005b SystemErr =A0 =A0 R
> javax.mail.MessagingException: Unknown SMTP host: mailhost;
> =A0 nested exception is:
> =A0 =A0 =A0 =A0 java.net.UnknownHostException: mailhost
|
|
0
|
|
|
|
Reply
|
caseyjbrotherton
|
10/30/2009 3:00:36 PM
|
|
On Oct 31, 4:00=A0am, "caseyjbrother...@gmail.com"
<caseyjbrother...@gmail.com> wrote:
> Mebbe:
>
> egrep "^[javax.mail.MessagingException|java.net.UnknownHost|nested
> exception is]?exception"
>
> Hope this helps
> Casey
>
> On Oct 28, 9:09=A0pm, Henry <snogfest_hosebe...@yahoo.com> wrote:
>
> > I'm trying an include/exclude list in 1 hit for a wrapper script
> > I want to get a hit on the string "exception" but exclude all the
> > other java bit's that are ok
>
> > egrep "[^(javax.mail.MessagingException)+|^(java.net.UnknownHost)+|^
> > (nested exception is )+]?exception"
>
> > kind of works; but not excluding this pattern:
> > nested exception is:
>
> > I'm basically trying to exclude all of this, but catch lines with
> > "exception"
>
> > [17/10/09 18:30:16:524 NZDT] 0000005b SystemErr =A0 =A0 R
> > javax.mail.MessagingException: Unknown SMTP host: mailhost;
> > =A0 nested exception is:
> > =A0 =A0 =A0 =A0 java.net.UnknownHostException: mailhost
>
>
no. returns null
|
|
0
|
|
|
|
Reply
|
Henry
|
10/30/2009 7:37:25 PM
|
|
>
> > > egrep "[^(javax.mail.MessagingException)+|^(java.net.UnknownHost)+|^
> > > (nested exception is )+]?exception"
>
Whoops,
Sorry about that.
So, I think that I made two mistakes:
1) made a mistake last time, and read ^ in your regexp as "not"
instead of "Beginning of line", and transferred that to my thinking.
Not sure where that came from.
2) I copied your example, and added two lines with "exception"
before and after, but
it worked by coincidence. Some of the exclusions were based on the
excludes not being at the beginning of the string.
The javax.mail exclusion worked because there wasn't also a
"exception" on the same line (With all lowercase)
It still should have picked up any lines with "exception" though...So
I assume that maybe you want a mixed case exception to be printed?
I would normally cheat with something like this, and use perl. More
verbose...But (to me) easier to read.
(Everything below should be for mixed case "exception"
cat ~/junk | perl -ne '/exception/i and do{ /
javax.mail.MessagingException/ and next;
/java.net.UnknownHost/ and next;
/nested exception is/ and next;
print $_;
}'
Or awk:
cat ~/junk | awk '/java.net.UnknownHost/||/
javax.mail.MessagingException/||/nested exception is/{next;} tolower
($0)~/exception/'
But looking at the egrep man page, I don't see how to get a "not" out
of egrep, except this two stage approach:
cat ~/junk | grep -i exception | egrep -v 'java.net.UnknownHost|
javax.mail.MessagingException|nested exception is'
Hope that actually helps.
Casey
|
|
0
|
|
|
|
Reply
|
caseyjbrotherton
|
11/2/2009 5:03:36 PM
|
|
On Nov 3, 6:03=A0am, "caseyjbrother...@gmail.com"
<caseyjbrother...@gmail.com> wrote:
> > > > egrep "[^(javax.mail.MessagingException)+|^(java.net.UnknownHost)+|=
^
> > > > (nested exception is )+]?exception"
>
> Whoops,
> Sorry about that.
>
> So, I think that I made two mistakes:
> 1) =A0made a mistake last time, and read ^ in your regexp as "not"
> instead of "Beginning of line", and transferred that to my thinking.
> =A0 =A0 Not sure where that came from.
>
> 2) =A0I copied your example, and added two lines with "exception"
> before and after, but
> =A0 it worked by coincidence. Some of the exclusions were based on the
> excludes not being at the beginning of the string.
> =A0 The javax.mail exclusion worked because there wasn't also a
> "exception" =A0on the same line (With all lowercase)
>
> It still should have picked up any lines with "exception" =A0though...So
> I assume that maybe you want a mixed case exception to be printed?
>
> I would normally cheat with something like this, and use perl. =A0More
> verbose...But (to me) =A0easier to read.
> (Everything below should be for mixed case "exception"
>
> cat ~/junk | perl -ne '/exception/i and do{ /
> javax.mail.MessagingException/ and next;
> /java.net.UnknownHost/ and next;
> /nested exception is/ and next;
> print $_;
>
> }'
>
> Or awk:
> cat ~/junk | awk '/java.net.UnknownHost/||/
> javax.mail.MessagingException/||/nested exception is/{next;} =A0tolower
> ($0)~/exception/'
>
> But looking at the egrep man page, I don't see how to get a "not" =A0out
> of egrep, except this two stage approach:
>
> cat ~/junk | grep -i exception | egrep -v 'java.net.UnknownHost|
> javax.mail.MessagingException|nested exception is'
>
> Hope that actually helps.
> Casey
thanks Casey, I was trying to use a standard Nagios plug-in called
check_log which uses grep.
I have switched to a hand-written awk script :)
|
|
0
|
|
|
|
Reply
|
Henry
|
11/2/2009 9:46:22 PM
|
|
|
4 Replies
166 Views
(page loaded in 0.158 seconds)
Similiar Articles: pattern match and dw in vim - comp.unix.adminI want to delete the end of every line from the last - onwards. Can I pattern match $- and then dw using vim? ... Join two lines in pattern matching, search, then assign fields to ...I have a file on stdin that I want contains a bunch of lines that are basically a dump from a flatfile database. I want to be able to match a field i... Delete line above and below the line which matches a pattern ...perl + regex bug? - comp.lang.perl.misc If the above pattern did not match, $1 will be whatever it ... orbitals (for example the 20 lines of numbers including a header ... gawk problem matching multiple patterns ?!? HOW-TO? - comp.lang ...running gawk; I have an ascii file with the following format: start: record 1 head1: fjoijefowijfwoijf head2: fiwjowiefojwf head3: fwofjwfoiwfoj head... Bash Test for Partial Match of String - comp.unix.shellbash search for a pattern within a string variable Does anyone know a bash command to check for a pattern match within a string. ... leviticus:~$ cat tmp.sh #! /bin/bash ... wildcard matching algorithm - comp.lang.rexxpattern match and dw in vim - comp.unix.admin Awk arrays and specific character matching - comp.lang.awk ... pattern match ... wildcard matching algorithm - comp.lang.rexx ... perl + regex bug? - comp.lang.perl.miscYou're not using warnings, so Perl doesn't bother telling you that you've included an undef inside your pattern match, and instead treats it as the empty string. Regex to match a numerical IP range - comp.lang.perl.misc ...Join two lines in pattern matching, search, then assign fields to ..... from a flatfile database. I want to be able to match a ... LINE | awk '{print $2}'` echo Machine ... /etc/project user-list format - comp.unix.solarisI assume that such a pattern won't match pczzzz but I need to be sure. Are there some docs that detail the allowable patterns for this field more than the man page? panorama stitching - comp.soft-sys.matlab> > But pattern matching in general is a big field and there is some > hope. Lots of article on pattern matching, like here: > http://iris.usc.edu/Vision-Notes ... Pattern matching - Wikipedia, the free encyclopediaIn computer science, pattern matching is the act of checking some sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern ... Pattern Matching (F#) - Microsoft Corporation: Software ...Patterns are used in many language constructs, such as the match expression. They are used when you are processing arguments for functions in let bindings, lambda ... 7/26/2012 2:51:22 PM
|