Dieser Perl-One-Liner erledigt die Arbeit:
perl -0777 -nE 'say $1 while(/(\d-\d\d-\d\d \d\d:\d\d:\d\d,\d+(?:(?!ORA-\d+)(?!\d-\d\d-\d\d \d\d:\d\d:\d\d,\d+).)*ORA-\d+(?:(?!\d-\d\d-\d\d \d\d:\d\d:\d\d,\d+).)*)/sg)' file.txt
Dadurch wird der Inhalt der Gruppe 1 ( $1
) jedes Mal gedruckt, wenn er gefunden wurde.
Optionen:
-0777 : slurp mode -n : add a loop around the script -E : enable features ("say" in this case)
Regex:
/ : regex delimiter ( : start group 1 \d-\d\d-\d\d \d\d:\d\d:\d\d,\d+ : regex for date (?: : start non capture group (?! : negative look ahead, make sure we don't have the following ORA-\d+ : literally "ORA-" followed by digits ) : end lookahead (?! : negative look ahead, make sure we don't have the following \d-\d\d-\d\d \d\d:\d\d:\d\d,\d+ : regex for date ) : end lookahead . : any character )* : non capture group is present 0 or more times ORA-\d+ : literally "ORA-" followed by digits (?: : start non capture group (?! : negative look ahead, make sure we don't have the following \d-\d\d-\d\d \d\d:\d\d:\d\d,\d+ : regex for date ) : end lookahead . : any character )* : non capture group is present 0 or more times ) : end group 1, contents in "$1" /sg : regex delimiter, s: single line, g: global
Eingabedatei Beispiel:
2017-11-29 23:51:46,013 (Foo.java:67) FATAL - foo.bar()-got exception during load of zzz javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","selec t licensekey0_.ID as ID...","sga heap(1,0)","kglsim object batch") 2017-11-29 23:51:46,013 (Foo.java:67) FATAL - foo.bar()-got exception during load of zzz javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) (NO ORA.....) unable to allocate 3896 bytes of shared memory ("shared pool","selec t licensekey0_.ID as ID...","sga heap(1,0)","kglsim object batch") 2017-11-29 23:51:46,013 (Foo.java:67) FATAL - foo.bar()-got exception during load of zzz javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","selec t licensekey0_.ID as ID...","sga heap(1,0)","kglsim object batch")
Ergebnis:
2017-11-29 23:51:46,013 (Foo.java:67) FATAL - foo.bar()-got exception during load of zzz javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","selec t licensekey0_.ID as ID...","sga heap(1,0)","kglsim object batch") 2017-11-29 23:51:46,013 (Foo.java:67) FATAL - foo.bar()-got exception during load of zzz javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) ORA-04031: unable to allocate 3896 bytes of shared memory ("shared pool","selec t licensekey0_.ID as ID...","sga heap(1,0)","kglsim object batch")
Der zweite Block wird nicht angezeigt