discarding new lines from my file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ndedhia1
    New Member
    • Jan 2009
    • 112

    discarding new lines from my file

    I have a file that has lines that are deliminated with '^A', but some of the lines go for a few lines and I need those lines to be appended into one line.

    All of the lines start with 'low debug' and end with ' " 0 '.

    How can I read each line from start to finish without some of the data being screwed up because the middle of the line starts at a new line.

    Here are some examples:
    This is an example of a line that is correct from beginning to end:
    [code=unix]
    low debug 2010/4/1 9:00:33.40 ICSNotification Alarm Prodics01ics000 1 ICS "1.0^AB^A7611^A 1270130433400^A 1965^A1963^A2^A m[0]=801^A10635^APr odfixcas11v2fix 61^ACD
    890/CM/ConsumerProxy@2 9002971^Am[1]=19002^A10635^A Prodfixcas11v2f ix61^ACD890/CM/ConsumerProxy@2 9002971^A" 0
    [/code]

    Notice how the line is deliminated with ^A. I use those fields in the data that I need to capture.

    Here is an example of one that is broken up into a few new lines which does not help because when I try to search for $7(the 7th value), my data gets all screwed up because that value is on a new line and since the value number starts over each time a new line begins, everything gets messed up.

    [code=unix]
    low debug 2010/4/1 9:00:37.38 ICSNotification Alarm Prodics01ics000 1 ICS "1.0^AB^A7612^A 1270130437380^A 31829^A31827^A1 ^Am[0]=31806^A[[(ProdBC10x1OHSe rverHybri
    dprdbc10b) ]] OhsSender(W_MAI N.ProdBC10x1Hyb ridTradeServer4 .Sender): : Exception while sending data to OHS.
    -------- Exception --------
    org.omg.CORBA.T IMEOUT: Request timed out after 10000065563 ns, falseNotifies(0 ). RequestId(2), typeId(IDL:orde rHandlingServic es/ManualOrderMain tenanceService
    :1.0), operation(getQu oteQueryDataFor Products), orbName(ProdBC1 0x1OHServerHybr idprdbc10b), iiopHost(prdbc1 0b), iiopPort(18202) , tiopHost(prdbc1 0b), tiopPort(
    18701) vmcid: 0x0 minor code: 0 completed: Maybe
    -------- Trace ------------
    com.cboe.ORBInf ra.Transport.Pe ndingRequestMan ager.waitForCom pletion(Pending RequestManager. java:133)
    com.cboe.IIOPTr ansport.IIOPCli entConnection.r eceiveReply(IIO PClientConnecti on.java:529)
    com.cboe.IIOPTr ansport.IIOPCli entConnection.r eceiveReply(IIO PClientConnecti on.java:513)
    com.cboe.IIOPTr ansport.IIOPCli entConnection.r eceiveReply(IIO PClientConnecti on.java:507)
    com.cboe.ORBInf ra.ORB.GenericB indMediator.two WaySendAndRecei ve(GenericBindM ediator.java:25 9)
    com.cboe.ORBInf ra.ORB.Delegate Impl.invoke(Del egateImpl.java: 693)
    org.omg.CORBA.p ortable.ObjectI mpl._invoke(Obj ectImpl.java:45 7)
    com.cboe.idl.or derHandlingServ ices._ManualOrd erMaintenanceSe rviceStub.getQu oteQueryDataFor Products(_Manua lOrderMaintenan ceServiceStub.j ava:519)
    com.cboe.ohsada pters.par.order Handling.ParMan ualOrderMainten anceServiceProx yImpl.getQuoteQ ueryDataForProd ucts(ParManualO rderMaintenance ServiceProxyImp l.java:
    325)
    com.cboe.ohsada pters.par.order Handling.format ters.outbound.T opOfTheSpreadBo okRequestHandle r.sendMessage(T opOfTheSpreadBo okRequestHandle r.java:52)
    com.cboe.ohsada pters.par.order Handling.format ters.OhsOutboun dHandler.send(O hsOutboundHandl er.java:96)
    com.cboe.ohsada pters.par.order Handling.OhsSen der.doTask(OhsS ender.java:120)
    com.cboe.lwt.th read.ThreadTask .execute(Thread Task.java:365)
    com.cboe.lwt.th read.WorkerThre ad.run(WorkerTh read.java:164)
    java.lang.Threa d.run(Thread.ja va:619)
    ^AProdOHSA00Par Adapter9pprdaps 04aA^AParAdapte r^A" 0
    [/code]

    Notice here, the beginning of the first line starts with 'low debug', and the end of the last line ends with ' " 0 ' but every com.cboe is a new line along with a few others, like -------- Exception -------- and -------- Trace ------------ are new lines. I need this too all be one line.

    Please help. Thanks!!!
  • Hydaral
    New Member
    • Jun 2010
    • 24

    #2
    I presume you want to replace the newlines with the field delimiter: ^A?

    Using AWK:
    Code:
    {
    	# If this is the first line of a new message, reset the string
    	if ($0 ~ /low debug/) {
     		string=$0
        }
    
        # If it is not the first line, append
        else {
    	 	string=string "^A" $0
        }
    
        # When the last line of a message is found, print the string
    	if ($0 ~ /\" 0$/) {
    		print string
        }
    }

    Comment

    Working...