帮助.......仍然没有工作
我有一个包含字符串的文件:
http://mediafire.com/?a6o37kfc7m68dri
部分内容:
BIF in setInputTag> set input tag value, name/value:ACCOUNT_NO/1746056
BIF in setInputTag> set input tag value, name/value:bill_ref_no/197546058
BIF in setInputTag> set input tag value, name/value:bill_ref_resets/1
BIF in setInputTag> set input tag value, name/value:DISPUTE_AMOUNT/0
BIF in setInputTag> set input tag value, name/value:NOD_FLAG/0
BIF in setInputTag> set input tag value, name/value:OUTSTANDING_BALANCE/510312
BIF in setInputTag> set input tag value, name/value:TOTAL_DUE/510312
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLZIPCODE) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLEDACCOUNTNUMBER) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLNUMBER) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLNUMBERRESETS) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=10593131,0
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=26203008,0
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292633,0
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=914416,0
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=914415,0
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(OWNINGACCOUNTNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBER) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(SUBSCRBNUMBERRESET) into SI inherited_map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(DEFAULTEXTERNALID) into SI inherited_map
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292561,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=914415,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=914416,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=10593131,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=26203008,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292561,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292633,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=914415,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292561,0
BIF in InvoiceRecord> INFO: Output data to SI map,successful. SI=57292561,0
BIF in setInputTag> set input tag value, name/value:ACCOUNT_NO/1746056
BIF in setInputTag> set input tag value, name/value:bill_ref_no/202085235
BIF in setInputTag> set input tag value, name/value:bill_ref_resets/1
BIF in setInputTag> set input tag value, name/value:DISPUTE_AMOUNT/0
BIF in setInputTag> set input tag value, name/value:NOD_FLAG/0
BIF in setInputTag> set input tag value, name/value:OUTSTANDING_BALANCE/962908
BIF in setInputTag> set input tag value, name/value:TOTAL_DUE/962908
BIF in run> INFO: updateParameterValues finished
BIF in getFile> INFO: Feed file(/arbordata/feedfile/PS-M26-1104-20130726-20130911-201711-1-bif01-1.DAT) for current invoice
BIF in insertNewFile> m_pcurFileNameAttr->file_seq_no:(1)
BIF in insertNewFile> INFO:Output fileHeader(000020130911201711
) to feedfile,successful
BIF in setInputTag> set input tag value, name/value:ACCOUNT_NO/1746056
BIF in setInputTag> set input tag value, name/value:bill_ref_no/202085235
BIF in setInputTag> set input tag value, name/value:bill_ref_resets/1
BIF in setInputTag> set input tag value, name/value:DISPUTE_AMOUNT/0
BIF in setInputTag> set input tag value, name/value:NOD_FLAG/1
BIF in setInputTag> set input tag value, name/value:OUTSTANDING_BALANCE/962908
BIF in setInputTag> set input tag value, name/value:TOTAL_DUE/962908
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLZIPCODE) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inherited value of field(BILLEDACCOUNTNUMBER) into ACCT map
BIF in addInheritedByField> INFO: Succeed to put the inhelibarbor_db/database_gen.c(4670): arb_db_err - Entry
errtype = 2
exec_user_handler = 1
errcode = 1422
errtext = Error in execution of OCI function unused:
retcode = -1 (OCI_ERROR)
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "ARBOR.PROJ_CSA_PROC2", line 9
我的方案是我想创建一个.sh脚本,它将从文件中获取所需的所有字符串,并将其格式化如下,最后将其输出到新文件:
修改
1729030|192840714|1|1422|Error in execution of OCI function unused:
1746056|202085235|1|1422|Error in execution of OCI function unused:
809434|201632617|1|1422|Error in execution of OCI function unused:
6993375|202888775|1|1422|Error in execution of OCI function unused:
7453294|199851665|1|1422|Error in execution of OCI function unused:
其中:
BIF in setInputTag> set input tag value, name/value:ACCOUNT_NO/
1729030 BIF in setInputTag> set input tag value, name/value:bill_ref_no/
192840714 BIF in setInputTag> set input tag value, name/value:bill_ref_resets/
1 errcode =
1422 errtext =
执行未使用的OCI功能时出错: 修改
最后我感觉更接近我的目标
执行此代码后:
egrep -e 'ACCOUNT_NO|bill_ref_no|bill_ref_resets|errcode|errtext' logs.txt | awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=4 a=0 s='errtext'
(与上述相同:突破线路) - 运行时将其放入一行:
egrep -e 'ACCOUNT_NO|bill_ref_no|bill_ref_resets|errcode|errtext' logs.txt
|awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}'
b=4 a=0 s='errtext'
修改
将这行代码添加到我之前的代码中后:
| sed -e 's/=/:/' -e 's/^BIF.*://' -e 's=/=:=' -e 's/^ *//' -e 's/ *: /:/' | sed -e 's/ACCOUNT_NO://g' -e 's/bill_ref_no:/|/g' -e 's/bill_ref_resets:/|/g' -e 's/errcode:/|/g' -e 's/errtext:/|/g'
现在这是我的输出:
1729030
|192840714
|1
|1422
|Error in execution of OCI function unused:
1746056
|202085235
|1
|1422
|Error in execution of OCI function unused:
809434
|201632617
|1
|1422
|Error in execution of OCI function unused:
6993375
|202888775
|1
|1422
|Error in execution of OCI function unused:
7453294
|199851665
|1
|1422
|Error in execution of OCI function unused:
现在最后的问题是如何修改换行符以使输出低于
它尝试添加此代码,但它不起作用:
| sed -e 's/\n//g;'
如何修剪这些新线?
所需的输出是:
1729030|192840714|1|1422|Error in execution of OCI function unused:
1746056|202085235|1|1422|Error in execution of OCI function unused:
809434|201632617|1|1422|Error in execution of OCI function unused:
6993375|202888775|1|1422|Error in execution of OCI function unused:
7453294|199851665|1|1422|Error in execution of OCI function unused:
现在我的整个代码:
egrep -e 'ACCOUNT_NO|bill_ref_no|bill_ref_resets|errcode|errtext' logs.txt | awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=4 a=0 s='errtext' | sed -e 's/=/:/' -e 's/^BIF.*://' -e 's=/=:=' -e 's/^ *//' -e 's/ *: /:/' | sed -e 's/ACCOUNT_NO://g' -e 's/bill_ref_no:/|/g' -e 's/bill_ref_resets:/|/g' -e 's/errcode:/|/g' -e 's/errtext:/|/g' | sed -e 's/\n//g;'
答案 0 :(得分:0)
请试试这个,
egrep -e 'ACCOUNT_NO|bill_ref_no|bill_ref_resets|errcode|(Error in execution)'
logs.txt
|
grep -B4 'Error in execution'
|
sed -e 's/ACCOUNT_NO\/\(.*\)/\1|/' -e 's/.*bill_ref_no\/\(.*\)/\1|/' -e 's/.*bill_ref_resets\/\(.*\)/\1|/' -e 's/.*errcode.*= \(.*\)/\1|/'
-e 's/.*errtext.*= \(.*\)/\1/' -e '/--/d'
| tr -d '\n' | sed -e 's/:/:\n/g' -e 's/ |/|/g'
> out_put_file.txt
我用bash在Ubuntu 12.10上工作。这太长了所以我把它分成几行,当你运行它时你需要把它们放在一行。 StackOverflow也有一些格式问题。我需要编辑它以显示完整的命令行。
这是我的输出,
1729030|192840714|1|1422|Error in execution of OCI function unused:
1746056|202085235|1|1422|Error in execution of OCI function unused:
809434|201632617|1|1422|Error in execution of OCI function unused:
6993375|202888775|1|1422|Error in execution of OCI function unused:
7453294|199851665|1|1422|Error in execution of OCI function unused:
根据给定的logs.txt,原始输出的第二行似乎是错误的。
答案 1 :(得分:0)
只有一个awk命令可以执行:
#!/usr/bin/awk -f
{
if (/ACCOUNT_NO/) {
sub(/.*\//, "")
account_no = $NF
step = 2
} else if (/bill_ref_no/) {
if (step++ == 2) {
sub(/.*\//, "")
bill_ref_no = $NF
} else {
step = 1
}
} else if (/bill_ref_resets/) {
if (step++ == 3) {
sub(/.*\//, "")
bill_ref_resets = $NF
} else {
step = 1
}
} else if (/errcode/) {
if (step++ == 4) {
sub(/.* = /, "")
errcode = $0
} else {
step = 1
}
} else if (/errtext/) {
if (step == 5) {
sub(/.* = /, "")
print account_no "|" bill_ref_no "|" bill_ref_resets "|" errcode "|" $0
}
step = 1
}
}
运行方式:
awk -f script.awk log.txt
基于以上输入的输出:
1746056|202085235|1|1422|Error in execution of OCI function unused: