2

帮助.......仍然无法正常工作

相关主题

我有一个文件包含字符串:

日志.txt

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
  • 第2栏:BIF in setInputTag> set input tag value, name/value:bill_ref_no/192840714
  • 第 3 列:BIF in setInputTag> set input tag value, name/value:bill_ref_resets/1
  • 第 4 栏:errcode =1422
  • Column5: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'

(上同:断线) - 运行时将其放入 1 行:

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;'
4

2 回答 2

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,您的原始输出的第二行似乎是错误的。

于 2013-09-20T03:04:21.587 回答
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:
于 2013-09-26T18:22:31.713 回答