03-16-2009
searching thru or combining multiple lines in a unix file
This is the problem actually:
This regex:
[code=unix]
egrep "low debug.*\".*\"" $dbDir/alarmNotification.log
[/code]
is looking for data between the two quotation marks:
[code=unix]
".*\"
[/code]
When I hate data like this:
[code=data]
low debug 2009/3/9 8:30:20.47 ICSNotificationAlarm Prodics01ics0003 IC "1.0^AB^A4594^A1236605420470^A15906^A15902^A1^Am[0]=15901^Acom.cboe.exceptions.DataValidationException,IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY,com.cboe.exceptions.DataValidationException: IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY
at com.cboe.util.ExceptionBuilder.dataValidationException(ExceptionBuilder.java:99)
at com.cboe.businessServices.brokerService.BrokerProcessorBase.processUpdate(BrokerProcessorBase.java:2 467)
at com.cboe.businessServices.brokerService.BrokerProcessorHybridImpl.processUpdate(BrokerProcessorHybri dImpl.java:2388)
at com.cboe.businessServices.brokerService.AcceptQuoteUpdateCommand.doExecute(AcceptQuoteUpdateCommand. java:109)
at com.cboe.businessServices.brokerService.BrokerCommand.execute(BrokerCommand.java:111)
at com.cboe.server.commandProcessing.TradingClassBlockCommandSingleThreadImpl.acceptCommands(TradingCla ssBlockCommandSingleThreadImpl.java:27)
at com.cboe.server.commandProcessing.TradingClassBlockCommand.processBlock(TradingClassBlockCommand.jav a:203)
at com.cboe.server.commandProcessing.TradingClassBlockCommand.execute(TradingClassBlockCommand.java:146 )
at com.cboe.server.commandProcessing.TradingClassCommandQueueProcessor.run(TradingClassCommandQueueProc essor.java:51)
at java.lang.Thread.run(Thread.java:619)
,^AProdBC04x1HybridTradeServer1prdbc04a^AHybridTradeServer1^A" 0
[/code]
There are line break before each
[code=data]
at com.cboe.util.ExceptionBuilder.dataValidationException(ExceptionBuilder.java:99)
[/code]
and so there is no closing quote after this line:
[code=data]
low debug 2009/3/9 8:30:20.47 ICSNotificationAlarm Prodics01ics0003 IC "1.0^AB^A4594^A1236605420470^A15906^A15902^A1^Am[0]=15901^Acom.cboe.exceptions.DataValidationException,IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY,com.cboe.exceptions.DataValidationException: IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY
[/code]
I want my output to have everything, including the "at com.cboe..."
[code=data]
low debug 2009/3/9 8:30:20.47 ICSNotificationAlarm Prodics01ics0003 IC "1.0^AB^A4593^A1236605420470^A15904^A15902^A1^Am[0]=15901^Acom.cboe.exceptions.DataValidationException,IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY,com.cboe.exceptions.DataValidationException: IDL:exceptions/DataValidationException:1.0 com.cboe.exceptions.OrderBookTradableNotFoundException: No tradables in book at specified price: 639898851:SUN:BUY at com.cboe.util.ExceptionBuilder.dataValidationException(ExceptionBuilder.java:99) at com.cboe.businessServices.brokerService.BrokerProcessorBase.processUpdate(BrokerProcessorBase.java:2 467) at com.cboe.businessServices.brokerService.BrokerProcessorHybridImpl.processUpdate(BrokerProcessorHybri dImpl.java:2388) at com.cboe.businessServices.brokerService.AcceptQuoteUpdateCommand.doExecute(AcceptQuoteUpdateCommand. java:109) at com.cboe.businessServices.brokerService.BrokerCommand.execute(BrokerCommand.java:111) at com.cboe.server.commandProcessing.TradingClassBlockCommandSingleThreadImpl.acceptCommands(TradingCla ssBlockCommandSingleThreadImpl.java:27) at com.cboe.server.commandProcessing.TradingClassBlockCommand.processBlock(TradingClassBlockCommand.jav a:203) at com.cboe.server.commandProcessing.TradingClassBlockCommand.execute(TradingClassBlockCommand.java:146 ) at com.cboe.server.commandProcessing.TradingClassCommandQueueProcessor.run(TradingClassCommandQueueProc essor.java:51) at java.lang.Thread.run(Thread.java:619),^AProdBC04x1HybridTradeServer1prdbc04a^AHybridTradeServer1^A"
[/code]
but because they are different lines, the egrep doesnt select them. What can I use that will egrep between multiple lines from the beginning to the end of the quotation marks.
This data below works below it searches between the quotation marks and this is all on one line:
[code=data]
low debug 2009/3/9 8:30:19.53 ICSNotificationAlarm Prodics01ics0003 IC "1.0^AB^A4592^A1236605419530^A23906^A23904^A2^Am[0]=23902^A<FINE> <org.apache.activemq.broker.region.TopicSubscription> < Mon 2009/03/09 08:30:18:84 > <org.apache.activemq.broker.region.TopicSubscription.add> <Thread[ActiveMQ Transport: tcp:///127.0.0.1:64770,4,main]> Discarding state cleared, delta-discarded(782). TopicSubscription: consumer=ID:mdgc01a-47174-1236574999518-0:126:1:2, destination=topic:///ProdRecap/IDL:consumers/RecapConsumer:1.0---RecapLocalMD01---local, destinations=1, dispatchedQueue=890, delivered=595531, matched=0, discarded=1542^AProdAMQBrokermdgc01a.out^AProdLogWatchermdgc01a^A" 0
[/code]
Is there another way that I could do this instead of egrep, which i believe does not let me search more then one line.
Maybe I would be able to use SED or AWK
thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am fairly new to scripting. But I have been able to extract and format all of my information required into one file. My issue is that one character is on a separate line. I need to be able to add the character to the previous line.
ex.
abcdefghi
1
bcdefghij
3
cdefghijk
4
need to... (4 Replies)
Discussion started by: DUST
4 Replies
2. Shell Programming and Scripting
Is there a way to combine two lines onto a single line...append the following line onto the previous line?
I have the following file that contains some blank lines and some lines I would like to append to the previous line...
current file:
checking dsk c19t2d6
checking dsk c19t2d7
... (2 Replies)
Discussion started by: mr_manny
2 Replies
3. Shell Programming and Scripting
Before I ask my actual question, is it going to be a problem that I want to run this process on a 15 Gig file that is ~140 million rows?
What I'm trying to do:
I have a file that looks like
Color,Type,Count,Day
Yellow,Full
5
Tuesday
Green,Half
6
Wednesday
Purple,Half
8
Tuesday
...... (3 Replies)
Discussion started by: goldfish
3 Replies
4. Shell Programming and Scripting
Combining many lines to one using awk or any unix cmd
Inputfile:
Output :
Appreciate help on this. (14 Replies)
Discussion started by: pinnacle
14 Replies
5. Shell Programming and Scripting
Hi,
I have a file with below contents,
ssenthil = rw
anilkg = rw
I want to search for "ssenthil" and need to delete line 1 and 2 , if the third line starts with "" respectively and blank line immediately and third line starts with "
anilkg = rw
Please help me .
Great day... (5 Replies)
Discussion started by: anil8103
5 Replies
6. Shell Programming and Scripting
I use this command to find a search (Nr of active alarms are) and print one line before and 10 lines after the search keywords.
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=1 a=10 s="Nr of active alarms are:" *.log
However, I would like to know how to tell it to print... (3 Replies)
Discussion started by: tthach830
3 Replies
7. Programming
Hi All
I need a small help for the below format in making a small script in Perl or Shell.
I have a file in which a single line entries are broken into three line entries.
Eg:
I have a
pen and
notebook.
All i want is to capture in a single line in a separate file.
eg: I have a pen and... (4 Replies)
Discussion started by: Kalaiela
4 Replies
8. UNIX for Dummies Questions & Answers
:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux.
I am working in Linux terminal.
I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies
9. Shell Programming and Scripting
Hi Everyone,
On my Linux box I have a text file having block of few lines and this block lines separated by one blank line. I would like to format and print these lines in such a way that this entire block of lines will come as single comma separated line & again next block of lines in next... (7 Replies)
Discussion started by: gr8_usk
7 Replies
10. Shell Programming and Scripting
Hi All,
I have a file which has the following sample lines
--
<Member name="Canada"
Currency="CAD"
--
<Member name="UK"
Currency="GBP"
--
<Member name="Switzerland"
Currency="CHF"
--
<Member name="Germany"
Currency="EUR"
-- (11 Replies)
Discussion started by: dev.devil.1983
11 Replies