How to grep multi line with keyword ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep multi line with keyword ?
# 1  
Old 07-24-2012
How to grep multi line with keyword ?

Hi All.
how to grep with same keyword.
Code:
23-07-2012 15:15:30,117 [23891659][DEBUG][SendMADOService]::: Recieve Message From Commadu :::
..
...
....
23-07-2012 16:15:28,481 [23891659][DEBUG][SendMADOService]::: Recieve Message From Commadu :::
23-07-2012 16:15:28,481 [23891659][DEBUG][SendMADOService]IP : 127.0.0.1 | msg = E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E | sno = null | refNo = 1122334455667788 | encoding = 25 | msgType = H | userHeader = null | validPeriod = null | u
ser = xxxxxxxxxx | password = xxxxxxxxxx | sender = xxxxxxxxxx | timeStamp = 120723161528 | isconcat = 1 | msnList = null | msn = 4920556348
23-07-2012 16:15:28,481 [23891659][DEBUG][ValidateSammba]::: Validate MsnList :::
23-07-2012 16:15:28,481 [23891659][DEBUG][ValidateSammba]::: ValidateSammba :::
23-07-2012 16:15:28,481 [23891659][DEBUG][ValidateSammba]Thai Message : false
23-07-2012 16:15:28,482 [23891659][DEBUG][ValidateSammba]No UserHeader
23-07-2012 16:15:28,482 [23891659][DEBUG][ValidateSammba]Message length : 276
23-07-2012 16:15:28,482 [23891659][DEBUG][SendMADOService][ API ValidateSammba Error Code ] 0
23-07-2012 16:15:28,486 [23891659][DEBUG][HTTPAdroidHelper]Action Type = Send
23-07-2012 16:15:28,486 [23891659][DEBUG][HTTPAdroidHelper]Action message = <evc:EvCorpSMSSendMessage xmlns:evc="th/co/tac/corpsms/sendmessage/EvCorpSMSSendMessage"><evc:RefNo>1122334455667788</evc:RefNo><evc:MsnList><evc:Msn>4920556348</evc:Msn></evc:MsnList>
<evc:Message>E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E</evc:Message><evc:Encoding>25</evc:Encoding><evc:MsgType>H</evc:MsgType><evc:ValidPeriod>43200</evc:ValidPeriod><evc:User>xxxxxxxxxx</evc:User><evc:Password
>xxxxxxxxxxx/evc:Password><evc:Sender>xxxxxxxxxx</evc:Sender><evc:IsConcat>1</evc:IsConcat><evc:TimeStamp>120723161528</evc:TimeStamp><evc:ChannelType>A</evc:ChannelType></evc:EvCorpSMSSendMessage>
23-07-2012 16:15:28,486 [23891659][DEBUG][HTTPAdroidHelper]Call Platform : Request identifier = 28434@andoid3:23891659:null
23-07-2012 16:15:28,486 [23891659][DEBUG][HttpConnectionPool] borrowing object..
23-07-2012 16:15:28,756 [23891659][DEBUG][HTTPAdroidHelper]Return Status Code : 200
23-07-2012 16:15:28,757 [23891659][DEBUG][HTTPAdroidHelper]Response Message : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult"><evc:ObjId>12072300000648945354</evc:ObjId><evc:ActionStatus>0</evc:ActionStatus><
evc:ActionErrorMessage>Success</evc:ActionErrorMessage></evc:EvCommonResult>
23-07-2012 16:15:28,757 [23891659][DEBUG][HttpConnectionPool] returning object..org.apache.commons.httpclient.HttpClient@381f9e
23-07-2012 16:15:28,775 [23891659][DEBUG][SendMADOService] xmlObject : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult">
23-07-2012 16:15:28,776 [23891659][DEBUG][MessageUtil]Return | Status=0 | TxID=12072300000648945354 | Message=Success
23-07-2012 16:15:28,776 [23891659][INFO][SendMADOService]UNIQ_TXN_ID=2389165928434@andoid3161528481|IP=andoid3|REF_ID=134303492846387|USERNAME=xxxxxxxxx:PASSWORD=xxxxxxxxx|MSISDN_LIST_SIZE=1|REPLY_STATUS_CODE=0:REPLY_MESSAGE=Su
ccess|TXN_ID=648945354|ELAPSED_TIME=295ms|MSISDN_LIST=4920556348
23-07-2012 16:15:30,117 [23891659][DEBUG][SendMADOService]::: Recieve Message From Commadu :::
23-07-2012 16:15:30,117 [23891659][DEBUG][SendMADOService]IP : 127.0.0.1 | msg = 0E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E | sno = null | refNo = 134303493009694 | encoding = 25 | msgType = H | userHeader = null | validPeriod = null | u
ser = xxxxxxxxxx | password = xxxxxxxxxx | sender = xxxxxxxxxx | timeStamp = 120723161530 | isconcat = 1 | msnList = null | msn = 831107533
23-07-2012 16:15:30,117 [23891659][DEBUG][ValidateSammba]::: Validate MsnList :::
23-07-2012 16:15:30,117 [23891659][DEBUG][ValidateSammba]::: ValidateSammba :::
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]Thai Message : false
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]No UserHeader
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]Message length : 276
23-07-2012 16:15:30,118 [23891659][DEBUG][SendMADOService][ API ValidateSammba Error Code ] 0
23-07-2012 16:15:30,122 [23891659][DEBUG][HTTPAdroidHelper]Action Type = Send
23-07-2012 16:15:30,122 [23891659][DEBUG][HTTPAdroidHelper]Action message = <evc:EvCorpSMSSendMessage xmlns:evc="th/co/tac/corpsms/sendmessage/EvCorpSMSSendMessage"><evc:RefNo>134303493009694</evc:RefNo><evc:MsnList><evc:Msn>83110
7533</evc:Msn></evc:MsnList><evc:Message>00E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E</evc:Message><evc:Encoding>25</evc:Encoding><evc:MsgType>H</evc:MsgType><evc:ValidPeriod>43200</evc:ValidPeriod><evc:User>xxxxxxxxxx</evc:User><evc:Password
>xxxxxxxxxx</evc:Password><evc:Sender>xxxxxxxxxx</evc:Sender><evc:IsConcat>1</evc:IsConcat><evc:TimeStamp>120723161530</evc:TimeStamp><evc:ChannelType>A</evc:ChannelType></evc:EvCorpSMSSendMessage>
23-07-2012 16:15:30,132 [23891659][DEBUG][HTTPAdroidHelper]Call Platform : Request identifier = 28434@andoid3:23891659:null
23-07-2012 16:15:30,132 [23891659][DEBUG][HttpConnectionPool] borrowing object..
23-07-2012 16:15:30,366 [23891659][DEBUG][HTTPAdroidHelper]Return Status Code : 200
23-07-2012 16:15:30,367 [23891659][DEBUG][HTTPAdroidHelper]Response Message : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult"><evc:ObjId>12072300000648945365</evc:ObjId><evc:ActionStatus>0</evc:ActionStatus><
evc:ActionErrorMessage>Success</evc:ActionErrorMessage></evc:EvCommonResult>
23-07-2012 16:15:30,367 [23891659][DEBUG][HttpConnectionPool] returning object..org.apache.commons.httpclient.HttpClient@bf5204
23-07-2012 16:15:30,368 [23891659][DEBUG][SendMADOService] xmlObject : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult">
23-07-2012 16:15:30,368 [23891659][DEBUG][MessageUtil]Return | Status=0 | TxID=12072300000648945365 | Message=Success
23-07-2012 16:15:30,368 [23891659][INFO][SendMADOService]UNIQ_TXN_ID=2389165928434@andoid3161530117|IP=andoid3|REF_ID=134303493009694|USERNAME=xxxxxxxxxx:PASSWORD=xxxxxxxxxx|MSISDN_LIST_SIZE=1|REPLY_STATUS_CODE=0:REPLY_MESSAGE=Su
ccess|TXN_ID=648945365|ELAPSED_TIME=251ms|MSISDN_LIST=831107533
.....
........
.........
...........
23-07-2012 18:15:30,117 [23891659][DEBUG][SendMADOService]::: Recieve Message From Commadu :::

For example. I want to keyword = '831107533'
Code:
23-07-2012 16:15:30,117 [23891659][DEBUG][SendMADOService]::: Recieve Message From Commadu :::
23-07-2012 16:15:30,117 [23891659][DEBUG][SendMADOService]IP : 127.0.0.1 | msg = 0E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E | sno = null | refNo = 134303493009694 | encoding = 25 | msgType = H | userHeader = null | validPeriod = null | u
ser = xxxxxxxxxx | password = xxxxxxxxxx | sender = xxxxxxxxxx | timeStamp = 120723161530 | isconcat = 1 | msnList = null | msn = 831107533
23-07-2012 16:15:30,117 [23891659][DEBUG][ValidateSammba]::: Validate MsnList :::
23-07-2012 16:15:30,117 [23891659][DEBUG][ValidateSammba]::: ValidateSammba :::
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]Thai Message : false
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]No UserHeader
23-07-2012 16:15:30,118 [23891659][DEBUG][ValidateSammba]Message length : 276
23-07-2012 16:15:30,118 [23891659][DEBUG][SendMADOService][ API ValidateSammba Error Code ] 0
23-07-2012 16:15:30,122 [23891659][DEBUG][HTTPAdroidHelper]Action Type = Send
23-07-2012 16:15:30,122 [23891659][DEBUG][HTTPAdroidHelper]Action message = <evc:EvCorpSMSSendMessage xmlns:evc="th/co/tac/corpsms/sendmessage/EvCorpSMSSendMessage"><evc:RefNo>134303493009694</evc:RefNo><evc:MsnList><evc:Msn>83110
7533</evc:Msn></evc:MsnList><evc:Message>00E390E40E350E420E2D0E2A0E320E270E2A0E270E22003100300E040E250E340E1B00200E2A0E210E310E040E230E42050E1A002F0E270E310E191B002B0E040E250E340E1B0E270E350E10E1F0E230E35002100200E230
E170E230020002A00340036003900340030003000350030150E480E2D0E440E1B0020003003000200E040E230E310E490E070E</evc:Message><evc:Encoding>25</evc:Encoding><evc:MsgType>H</evc:MsgType><evc:ValidPeriod>43200</evc:ValidPeriod><evc:User>xxxxxxxxxx</evc:User><evc:Password
>xxxxxxxxxx</evc:Password><evc:Sender>xxxxxxxxxx</evc:Sender><evc:IsConcat>1</evc:IsConcat><evc:TimeStamp>120723161530</evc:TimeStamp><evc:ChannelType>A</evc:ChannelType></evc:EvCorpSMSSendMessage>
23-07-2012 16:15:30,132 [23891659][DEBUG][HTTPAdroidHelper]Call Platform : Request identifier = 28434@andoid3:23891659:null
23-07-2012 16:15:30,132 [23891659][DEBUG][HttpConnectionPool] borrowing object..
23-07-2012 16:15:30,366 [23891659][DEBUG][HTTPAdroidHelper]Return Status Code : 200
23-07-2012 16:15:30,367 [23891659][DEBUG][HTTPAdroidHelper]Response Message : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult"><evc:ObjId>12072300000648945365</evc:ObjId><evc:ActionStatus>0</evc:ActionStatus><
evc:ActionErrorMessage>Success</evc:ActionErrorMessage></evc:EvCommonResult>
23-07-2012 16:15:30,367 [23891659][DEBUG][HttpConnectionPool] returning object..org.apache.commons.httpclient.HttpClient@bf5204
23-07-2012 16:15:30,368 [23891659][DEBUG][SendMADOService] xmlObject : <evc:EvCommonResult xmlns:evc="th/co/tac/corpsms/common/EvCommonResult">
23-07-2012 16:15:30,368 [23891659][DEBUG][MessageUtil]Return | Status=0 | TxID=12072300000648945365 | Message=Success
23-07-2012 16:15:30,368 [23891659][INFO][SendMADOService]UNIQ_TXN_ID=2389165928434@andoid3161530117|IP=andoid3|REF_ID=134303493009694|USERNAME=xxxxxxxxxx:PASSWORD=xxxxxxxxxx|MSISDN_LIST_SIZE=1|REPLY_STATUS_CODE=0:REPLY_MESSAGE=Su
ccess|TXN_ID=648945365|ELAPSED_TIME=251ms|MSISDN_LIST=831107533


Please Help me
Thanks in advance,
regards,
Ooil
# 2  
Old 07-24-2012
Try:
Code:
perl -e 'foreach (reverse <>){push (@a,$_) if (/831107533/ ../Recieve Message From Commadu/ )};print reverse(@a)' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep multi line with keyword ?

Hello Everyone, i need to grep specific keyword in a file. i want need solution to output. example file.txt 03-08-2019 21:02:20,938 ::: Recieve Data From Amazon ::: 03-08-2019 21:02:20,938 IP : 192.168.1.1 | msg = Your confirmation code for 'Verify phone number' is xxxxx | sno =... (2 Replies)
Discussion started by: ooilinlove
2 Replies

2. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies

3. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

4. Shell Programming and Scripting

Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below. ========== RECORD 1 ========== RECORD 2 DATA LINE ========== RECORD 3 ========== RECORD 4 DATA LINE ========== RECORD 5 DATA LINE ========== I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies

5. UNIX for Dummies Questions & Answers

find/xargs/*grep: find multi-line empty "try-catch" blocks - eg, missing ; not in a commented block

How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases? This would seem to involve find, xargs, *grep, regex, etc. In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Discussion started by: lifechamp
0 Replies

6. Shell Programming and Scripting

How to grep the line with error where keyword in next line is known.

If a file consists of a thousands of line. There is a error line in the file which exists just before the line with word "Manish". How could I write a script to grep the line with error. Ex:- If I have a UNIX file which contains the following: bash-3.2$ cat unix.txt Unix (officially... (4 Replies)
Discussion started by: manishdivs
4 Replies

7. Shell Programming and Scripting

Conditional Multi-Line Grep Problem

Hi, I have a very large file I want to extract lines from. I'm hoping Grep can do the job, but I'm running into problems. I want to return all lines that match a pattern. However, if the following line of a matched line contains the word "Raw" I want to return that line as well. Is this... (3 Replies)
Discussion started by: redbluefish
3 Replies

8. Shell Programming and Scripting

read the first 10 lines below a keyword found by grep

Hello Everyone, i need to read specific number of lines ( always serialized ; i.e from 10 to 20 or from 34 to 44 ) in a file , where the first line is found by grep 'ing a keyword. example file.txt ------------------------------------------------------------------ --header this is the... (7 Replies)
Discussion started by: alain.kazan
7 Replies

9. Shell Programming and Scripting

How to grep multi line.

How to grep multi line. My LOg. . . . . 2010-04-23 02:17:02,419 INFO - -MsgCode = 00903 2010-04-23 02:17:02,420 INFO - - end processABCD126 2010-04-23 02:17:02,420 DEBUG - try to get message=ERROR_NOT_AUTHORIZED_TO_USE_SERVICE 2010-04-23 02:17:02,420 DEBUG - got message=Test... (4 Replies)
Discussion started by: ooilinlove
4 Replies

10. Shell Programming and Scripting

multiple search keyword in grep

Dear All, I have a file containing info like TID:0903 asdfasldjflsdjf TID:0945 hjhjhkhkhkh TID:2045 hjhjhkhkhkh TID:1945 hjhjhkhkhkh TID:2045 hjhjhkhkhkh I need to show only lines containing TID:0903 asdfasldjflsdjf TID:0945 hjhjhkhkhkh TID:2045 hjhjhkhkhkh TID:2045 hjhjhkhkhkh ... (11 Replies)
Discussion started by: saifurshaon
11 Replies
Login or Register to Ask a Question