Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to match pattern. It should grep the following logs and email. I want to grep the word "Exception" and immediate logs those starts with "!" . Can you please give me the sed regex or grep regex that i can use in shell script . Below are logs and my desired output.
! java.lang.ClassNotFoundException: org.tmatesoft.svn.core.SVNException
! at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_20]
! at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_20]
! at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_20]
! at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_20]
! at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_20]
!... 58 common frames omitted
Thanks the above code worked. Now i want the regex can give me. Below are logs and the desired output.
Logs:
DEBUG 2014-10-13 07:58:07,725 [ID: ] [URL: ] c.o.p.s.db.Test - : jdbc:ingres://172.20.17.217:VW7/ACDB2
! java.lang.ClassNotFoundException: org.tmatesoft.svn.core.SVNException
! at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_20]
! at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_20]
! at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_20]
! at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_20]
! at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_20]
!... 58 common frames omitted
DEBUG 2014-10-13 07:59:17,725 [ID: ] [URL: ] c.o.p.s.db.Test - : jdbc:ingres://172.20.17.217:VW7/ACDB2
java.sql.SQLDataException: Integer divide by zero detected in query.
at rock.util.SqlExType.getSqlEx(SqlExType.java:103)
at rock.util.SqlExFactory.get(SqlExFactory.java:96)
at rock.rock(DrvObj.java:852)
at rock.jdbc.DrvObj.readResults(DrvObj.java:636)
at rock.jdbc.RsltFtch.preLoad(RsltFtch.java:611)
at rock.jdbc.RsltCurs.preLoad(RsltCurs.java:306)
at rock.jdbc.RsltCurs.<init>(RsltCurs.java:235)
Desired Output:
! java.lang.ClassNotFoundException: org.tmatesoft.svn.core.SVNException
! at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_20]
! at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_20]
! at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_20]
! at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_20]
! at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_20]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_20]
!... 58 common frames omitted
java.sql.SQLDataException: Integer divide by zero detected in query.
at rock.util.SqlExType.getSqlEx(SqlExType.java:103)
at rock.util.SqlExFactory.get(SqlExFactory.java:96)
at rock.rock(DrvObj.java:852)
at rock.jdbc.DrvObj.readResults(DrvObj.java:636)
at rock.jdbc.RsltFtch.preLoad(RsltFtch.java:611)
at rock.jdbc.RsltCurs.preLoad(RsltCurs.java:306)
at rock.jdbc.RsltCurs.<init>(RsltCurs.java:235)
Thanks the above code worked. Now i want the regex can give me. Below are logs and the desired output.
Can you show us ANY effort of your own??? Asking for handouts without showing some effort is fairly rude. You've been given help, and should be easily able to take what you've been handed and modify it to suit your needs.
You've been using Linux for four years now...have you not done ANYTHING with scripting, regex, awk/sed/grep in all that time?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.