appending lines

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

    #1

    appending lines

    I have some data that I would like appended into one full like.
    How do I go about doing that?

    [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]

    At the end of each line, starts a new line and I want all of this to be one full line so that break it up and manipulate pieces of it. Because each endline starts a new line, I am not able to handle each field as I would like.

    Thanks
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Gosh my English is so poor .. You want to remove the new line characters don't you?

    Comment

    • ndedhia1
      New Member
      • Jan 2009
      • 112

      #3
      Yes, I would like to get rid of new line characters after every line that doesnt end with " 0

      each line that starts with "low debug" should be a new line and it ends with " 0

      there are a few instances like the example I gave you like:
      [code=unix]
      # -------- 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]

      where each line is a new line and i want them appended to the line above so they are all one big line starting with the low debug line.

      here are a few examples of correct lines of output in my file: none of these have breaks in the line and are one big line, all separated by the '^A' character

      [code=unix]
      low debug 2010/4/1 9:00:33.05 ICSNotification Alarm Prodics01ics000 1 ICS "1.0^AB^A7609^A 1270130433040^A 33704^A33702^A3 ^Am[0]=33701^A CMS: abort preclean due t
      o time [37 iterations, 36 waits, 245 cards)] 2010-04-01T09:00:29.275-0500: 33367.475: [CMS-concurrent-abortable-preclean: 1.400/5.021 secs] (CMS-concurrent-
      abortable-preclean yielded 0 times)^A/sbt/prod/infra/run_dir/log/ProdTraderServi ceA.out^AProdLo gWatcherprdgc2a ^A" 0
      [/code]
      [code=unix]
      low debug 2010/4/1 9:00:33.33 ICSNotification Alarm Prodics01ics000 1 ICS "1.0^AB^A7610^A 1270130433310^A 28111^A28108^A3 ^Am[0]=28100^A165^APr odBC81x1HybridT rade
      Server4prdbc81b ^Aprdgc2a:18116 :0/OutstandingCall s^Am[1]=28099^A165^APr odBC81x1HybridT radeServer4prdb c81b^Aprdgc2a:1 8116:0/OutstandingCall s^A" 0
      [/code]
      [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]

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        The question is if the line is ending with '0' then the next line is starting with 'low debug'?
        If so you can try something like that
        Code:
        sed ':a;N;/0$/!ba;s/\n//g' filename
        does it work for you?
        I found that solution somwhere on the net if you google you will find some other solutions.

        Comment

        • ndedhia1
          New Member
          • Jan 2009
          • 112

          #5
          basically, if the line starts with 'low debug' it should be a new line.
          IF the line does not start with low debug, no matter what it starts with, it should be part of the line above it.

          The sed statement you gave me got an error saying:
          Label too long: :a;N;/0$/!ba;s/\n//g


          thanks for the help!!

          Comment

          • rski
            Recognized Expert Contributor
            • Dec 2006
            • 700

            #6
            What about that
            Code:
            sed ':a;/0$/!{N;s/\n//;ba;}' test.txt
            Both works for me but it looks for 0 at the end of line because you wrote
            Yes, I would like to get rid of new line characters after every line that doesnt end with " 0
            What OS do you use?

            Comment

            • ndedhia1
              New Member
              • Jan 2009
              • 112

              #7
              I am on a unix box.
              This is the error that i am getting:
              [code=unix]
              sed ':a;/0$/!{N;s/\n//;ba;}' alarmNotificati on.log
              Label too long: :a;/0$/!{N;s/\n//;ba;}
              [/code]

              maybe instead of looking for the 0 at the end of the line, it could look for the 'low debug' at the beginning of the line, and if the line does not start with low debug, it can append that line to the one above it.
              Is there a way to do that?

              Thanks

              Comment

              • ndedhia1
                New Member
                • Jan 2009
                • 112

                #8
                I have posted my same question like this also...maybe this better explains my situation:

                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!!!

                Comment

                Working...