Ignoring newlines in my search

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:

low debug 2010/4/1 9:00:33.40 ICSNotificationAlarm Prodics01ics0001 ICS "1.0^AB^A7611^A1270130433400^A1965^A1963^A2^Am[0]=801^A10635^AProdfixcas11v2fix61^ACD
890/CM/ConsumerProxy@29002971^Am[1]=19002^A10635^AProdfixcas11v2fix61^ACD890/CM/ConsumerProxy@29002971^A" 0

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.

low debug 2010/4/1 9:00:37.38 ICSNotificationAlarm Prodics01ics0001 ICS "1.0^AB^A7612^A1270130437380^A31829^A31827^A1^Am[0]=31806^A[[(ProdBC10x1OHServerHybri
dprdbc10b) ]] OhsSender(W_MAIN.ProdBC10x1HybridTradeServer4.Sender): : Exception while sending data to OHS.
-------- Exception --------
org.omg.CORBA.TIMEOUT: Request timed out after 10000065563 ns, falseNotifies(0). RequestId(2), typeId(IDL:orderHandlingServices/ManualOrderMaintenanceService
:1.0), operation(getQuoteQueryDataForProducts), orbName(ProdBC10x1OHServerHybridprdbc10b), iiopHost(prdbc10b), iiopPort(18202), tiopHost(prdbc10b), tiopPort(
18701)  vmcid: 0x0  minor code: 0 completed: Maybe
-------- Trace ------------
com.cboe.ORBInfra.Transport.PendingRequestManager.waitForCompletion(PendingRequestManager.java:133)
com.cboe.IIOPTransport.IIOPClientConnection.receiveReply(IIOPClientConnection.java:529)
com.cboe.IIOPTransport.IIOPClientConnection.receiveReply(IIOPClientConnection.java:513)
com.cboe.IIOPTransport.IIOPClientConnection.receiveReply(IIOPClientConnection.java:507)
com.cboe.ORBInfra.ORB.GenericBindMediator.twoWaySendAndReceive(GenericBindMediator.java:259)
com.cboe.ORBInfra.ORB.DelegateImpl.invoke(DelegateImpl.java:693)
org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
com.cboe.idl.orderHandlingServices._ManualOrderMaintenanceServiceStub.getQuoteQueryDataForProducts(_ManualOrderMaintenanceServiceStub.java:519)
com.cboe.ohsadapters.par.orderHandling.ParManualOrderMaintenanceServiceProxyImpl.getQuoteQueryDataForProducts(ParManualOrderMaintenanceServiceProxyImpl.java:
325)
com.cboe.ohsadapters.par.orderHandling.formatters.outbound.TopOfTheSpreadBookRequestHandler.sendMessage(TopOfTheSpreadBookRequestHandler.java:52)
com.cboe.ohsadapters.par.orderHandling.formatters.OhsOutboundHandler.send(OhsOutboundHandler.java:96)
com.cboe.ohsadapters.par.orderHandling.OhsSender.doTask(OhsSender.java:120)
com.cboe.lwt.thread.ThreadTask.execute(ThreadTask.java:365)
com.cboe.lwt.thread.WorkerThread.run(WorkerThread.java:164)
java.lang.Thread.run(Thread.java:619)
^AProdOHSA00ParAdapter9pprdaps04aA^AParAdapter^A" 0

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

Something like this:

  
awk '/low/ && $0 ~ /0 $/ {print ; next } /low/ { a=$0;next } $0 ~ /0 $/ {a=a""$0;print a ;a=""} {a=a""$0;next}' input_file

I tried that put I did not get any result.
Can you please explain to me what the code is doing?
Maybe I can explain it better also:
I have a file in which contains lines or error messages.
Those messages are deliminated with '^A' and each line has exactly the same number of values.
In my code, I take value number 1 and do something with it, value number 2 and do something with, etc, till I hit the last value.
95% of the file contains individual lines that all start with the 'low' and end with ' " 0' so those lines, I am having no trouble with.
5% of the file contains these lines over multiple lines and here is where I am running into a problem. If I try to do something with value 4, but it is on the 2nd line, then my grep gets all screwed up because i am not grepping over multiple lines.
So i need either one of two things.
Either I need to know how to grep over multiple lines so that newlines arent a problem or I need to figure out how to append all the lines that dont start with either 'low' or dont end with ' " 0"

Thanks!!

The code , i suggested will concatanate the line having "low" in the start and all the lines till it find's "0" in the end of the line to a single line. If the line have "low" and "0" in the start and end respectively in a single line, it will just print those.

i just realized that the line ends with a space after the 0 at the end.
Is there a way to do it so that we can have each line start with "low" but end with '" 0 ' (thats a quote space zero space)

Thanks a lot!!!

I just modified my previous script , have a look at it.

I really want to thank you!!
This worked out for me...
if you have a second, can you break down the code a bit to explain what you did. I am just trying to learn as much as i can.

Thanks a lot!!!!

Here it goes:

 
'/low/ && $0 ~ /0 $/ {print ; next } --> lines have "low" and "0 " , so just print them and go to next line
  
/low/ { a=$0;next } --> if the line have "low" , store it in "a" , go to next line
 
$0 ~ /0 $/ {a=a""$0;print a ;a=""} --->  if the line have "0 " in the end , print a , and reset a to nothing.
 
{a=a""$0;next}' input_file --> append the line to "a" , and go to next line ( search till you get a line with "0 " in the end).

To be more accurate use below:

 
 
awk '/^low/ && $0 ~ /0 $/ {print ; next } /^low/ { a=$0;next } $0 ~ /0 $/ {a=a""$0;print a ;a=""} {a=a""$0;next}' input_file