我需要抓住当前时间出现的错误,忽略早期发生。问题是日期是几行以上(与错误代码不在同一行)。如何从
返回信息***begin ibmdb error message***
有日期&时间将其等同于当前时间,并包括所有这些错误日志数据:
*** begin ibmdb error message ***
Sun Dec 18 21:50:57 2016 - program 'execjob', User 'OSID:root', RMId 'root' Driver Version '9.0.1.14.865 2015-01-20 04:00:00'
DELETEDBREC() error on file 'USERRPT' in 'GEN'
DeleteSqlRec(lawson."USERRPT", 1)
DB2 FATAL ERROR for SQLExecute - Code: 40001/-911
[IBM][CLI Driver][DB2/AIX64] SQL0911N The current transaction has been rolled
back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001
awk 'BEGIN{FS="begin ibmdb error message"}
捕获了开头 - 如何用 - Reason code "68"
答案 0 :(得分:0)
这样的东西?我从时间点开始只是为了测试而不是begin ibmdb error message
,因为我认为可能会有更多以相同文本开头的部分。
$ awk '/21:50/,/Reason code "68"/' file11
Sun Dec 18 21:50:57 2016 - program 'execjob', User 'OSID:root', RMId 'root' Driver Version '9.0.1.14.865 2015-01-20 04:00:00'
DELETEDBREC() error on file 'USERRPT' in 'GEN'
DeleteSqlRec(lawson."USERRPT", 1)
DB2 FATAL ERROR for SQLExecute - Code: 40001/-911
[IBM][CLI Driver][DB2/AIX64] SQL0911N The current transaction has been rolled
back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001
提示:您可以在此处查看有关模式匹配的awk功能:https://www.gnu.org/software/gawk/manual/html_node/Expression-Patterns.html
答案 1 :(得分:0)
FS 告诉awk您线路上的字段将被'开始ibmdb错误消息'
分开您可能想要做类似
的事情awk '/begin ibmdb error message/,/Reason code "68"/'