我有以下问题作为输入数据文件,格式为
Jun 18 2020 12:46:20 | ERR | XFW | Common:1 | 10 | ORA Error, ORA-03113: end-of-file on communication channel
Process ID: 32759
Session ID: 2291 Serial number: 11145
while executing "DELETE FROM ATSD_Price WHERE ( ( Table_ID = :1 ) AND ( Entry_ID = :2 ) )" with :1="Scenario157", :2=37879.
Jun 18 2020 12:47:08 | TXT | APP | SG:1 | 9166 | One minute timer - 12:47
Jun 18 2020 12:47:20 | ERR | REFM | Common:1 | 17 | Request is Failed
Jun 18 2020 12:48:07 | TXT | APP | SG:1 | 9166 | One minute timer - 12:48
只应从中选择带有 ERR 标记的行。但有时错误是多行的,就像第一个出现的一样,有时是单行的,就像第二个一样。在一种情况下,我需要将所有错误行扩展为由空格分隔的 1 行,在 2 种情况下只有这一行。所以我想要结束的是:
Jun 18 2020 12:46:20 | ERR | XFW | Common:1 | 10 | ORA Error, ORA-03113: end-of-file on communication channel Process ID: 32759 Session ID: 2291 Serial number: 11145 while executing "DELETE FROM ATSD_Price WHERE ( ( Table_ID = :1 ) AND ( Entry_ID = :2 ) )" with :1="Scenario157", :2=37879.
Jun 18 2020 12:47:20 | ERR | REFM | Common:1 | 17 | Request is Failed
我考虑了 grep -A 4 ERR 文件,然后将行扩展为 1 并切断每行 2 个日期,但我不确定多行错误是否会在 4 行中删除,可能还有更多。我怎样才能做到这一点?提前致谢