我需要执行以下步骤,以通过GREP或任何其他命令在第二行以下提取唯一的错误代码。由于某些原因,我无法获得完整的结果。能否请你帮忙?谢谢!
grep -e '.*[A-Z]-[0-9]*:' -o -e '.*row.[.0-9]*' test.log
- 需要捕获错误代码下仅一行(以“错误处理列...”开头的行)的ORA / KUP错误代码行。
- 请注意,对于ora-01843行,我们有两条不同的第二行,因此我们只需要第一行带有“ CON_START_DATE在第7行”,而另一行则是用于“错误处理列CON_END_DATE在第66行”。 对于具有相同列名的其他行,不需要任何其他行。其他错误代码也是如此(例如ORA-01722)。 基本上,错误代码和错误处理行必须是唯一的。
- 必须在行号后剪切任何文本。例如,“数据文件test_data1.csv第6行中的错误处理列CON_START_DATE” 将变为“第6行中的错误处理列CON_START_DATE” 。
- 如果没有任何错误代码的第二行(以“错误处理列......开头”),则必须将其删除。
test.log:
LOG file opened at 01/01/18 10:10:10
KUP-05004: Warning: parallel select was not requested.
Field Definitions for table DATA_1_STG
Record format DELIMITED BY NEWLINE
Data in file has same endianness as the platform
Reject rows with all null fields
error processing column CON_START_DATE in row 1 for datafile test_data1.csv
ORA-01858: a non-numeric character was found where a numeric was expected
error processing column SUPPLIER_ID in row 3 for datafile test_data1.csv
ORA-01722: invalid number
error processing column CON_START_DATE in row 6 for datafile test_data1.csv
ora-01843: not a valid month
error processing column CON_START_DATE in row 7 for datafile test_data1.csv
ora-01843: not a valid month
error processing column CON_START_DATE in row 8 for datafile test_data1.csv
ORA-01722: invalid number
error processing column CON_START_DATE in row 6 for datafile test_data1.csv
ora-01843: not a valid month
KUP-04073: record ignored because all referenced fields are null for a record
error processing column CON_END_DATE in row 65 for datafile test_data1.csv
ora-01843: not a valid month
error processing column CON_END_DATE in row 66 for datafile test_data1.csv
ora-01843: not a valid month
error processing column CON_END_DATE in row 67 for datafile test_data1.csv
ora-01843: not a valid month
error processing column CON_START_DATE in row 102 for datafile test_data1.csv
ora-01843: not a valid month
所需结果:
KUP-05004: Warning: Intra source concurrency disabled because parallel select was not requested.
error processing column CON_START_DATE in row 1
ORA-01858: a non-numeric character was found where a numeric was expected
error processing column SUPPLIER_ID in row 3
ORA-01722: invalid number
error processing column CON_START_DATE in row 6
ora-01843: not a valid month
error processing column CON_START_DATE in row 7
KUP-04073: record ignored because all referenced fields are null for a record
error processing column CON_END_DATE in row 65
ora-01843: not a valid month
error processing column CON_END_DATE in row 66