Grep multi line with keyword ?


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Grep multi line with keyword ?

Hello Everyone,
i need to grep specific keyword in a file.
i want need solution to output.
example

Code:
file.txt

03-08-2019 21:02:20,938 [Docker][SendAWZService]::: Recieve Data From Amazon :::
03-08-2019 21:02:20,938 [Docker][SendAWZService]IP : 192.168.1.1 | msg = Your confirmation code for 'Verify phone number' is xxxxx | sno = null | refNo = 21936651171 | encoding
 = 25 | msgType = H | userHeader = null | validPeriod = null | user = amazonapi | password = amazonapi | sender = AMA | timeStamp = null | isconcat = 1 | msnList = null | msn = 994425363154 | buffe
rTxnID = null | remoteAddr = null
03-08-2019 21:02:20,938 [Docker][AWZUtility]ReformatRefno 
03-08-2019 21:02:20,938 [Docker][AWZUtility]ReformatRefno refno:19080307210220938253
03-08-2019 21:02:20,938 [Docker][ValidateDocker]::: ValidateDocker :::
03-08-2019 21:02:20,938 [Docker][ValidateDocker]Eng Message : false
03-08-2019 21:02:20,938 [Docker][ValidateDocker]No UserHeader
03-08-2019 21:02:20,938 [Docker][ValidateDocker]Message length : 280
03-08-2019 21:02:20,938 [Docker][SendAWZService]API ValidateDocker :: Error Code=0, UNIQ_TXN_ID=771382511781@Pokemon22210220938, ElapsedTime=0 ms.
03-08-2019 21:02:20,938 [Docker][SendAWZService]Validate bean success.
03-08-2019 21:02:20,948 [INFO][SendAWZService]UNIQ_TXN_ID=771382511781@Pokemon22210220938 ElapsedTime detail|reserveQuota=10 ms.|classifyNumber=0 ms.|getCache=0 ms.|validateMsgFormat=0 ms.|validateSen
dSMS=0 ms.|processTime=10 ms.|
03-08-2019 21:02:20,948 [Docker][SendAWZService]SendSMS process complete
03-08-2019 21:02:20,948 [Docker][MessageUtil]Return | Status=0 | TxID=19080307210220938253 | Message=Success
03-08-2019 21:02:20,949 [INFO][SendSMSServlet]Process time : 11 ms.
03-08-2019 21:02:35,067 [Docker][SendSMSServlet]UNIQ_TXN_ID= 10910811781@Pokemon22210235067, HTTP headers:Host=10.94.96.136, Accept-Encoding=gzip;q=1.0,deflate;q=0.6,identity;q=0.3, Accept=*/*, User-Ag
ent=Ruby, Content-Type=application/x-www-form-urlencoded, X-Newrelic-Id=VwMHWFVUGwsIUllTBAE=, X-Newrelic-Transaction=PxQCUFdQXQcCAQIHDwkHU10HFB8EBw8RVU4aVwkJB1cHV1wCVFkLUlEPAUNKQVwLAl1TUA4EFTs=, X-For
warded-For=192.168.1.93, X-Forwarded-Host=192.168.1.2, X-Forwarded-Server=amasmsapi.ama.cn, Connection=Keep-Alive, Content-Length=169, , ElapsedTime=0 ms.
03-08-2019 21:02:35,067 [Docker][SendAWZService]::: Recieve Data From Amazon :::
03-08-2019 21:02:35,067 [Docker][SendAWZService]IP : 192.168.1.1 | msg = Your confirmation code for 'Verify phone number' is xxxxx | sno = null | refNo =  | encoding = 0 | msgType = E | userHeader = null | validPeriod = null 
| user = amazonapi | password = amazonapi | sender = AMA | timeStamp = null | isconcat = 1 | msnList = null | msn = 994425363153 | bufferTxnID = null | remoteAddr = null
03-08-2019 21:02:35,067 [Docker][AWZUtility]ReformatRefno 
03-08-2019 21:02:35,067 [Docker][AWZUtility]ReformatRefno refno:19080307210235067254
03-08-2019 21:02:35,067 [Docker][ValidateDocker]::: ValidateDocker :::
03-08-2019 21:02:35,067 [Docker][ValidateDocker]Eng Message : true
03-08-2019 21:02:35,067 [Docker][ValidateDocker]No UserHeader
03-08-2019 21:02:35,067 [Docker][ValidateDocker]Message length : 36
03-08-2019 21:02:35,067 [Docker][SendAWZService]API ValidateDocker :: Error Code=0, UNIQ_TXN_ID=10910811781@Pokemon22210235067, ElapsedTime=0 ms.
03-08-2019 21:02:35,067 [Docker][SendAWZService]Validate bean success.
03-08-2019 21:02:35,068 [INFO][SendAWZService]UNIQ_TXN_ID=10910811781@Pokemon22210235067 ElapsedTime detail|reserveQuota=0 ms.|classifyNumber=0 ms.|getCache=1 ms.|validateMsgFormat=0 ms.|validateSendS
MS=0 ms.|processTime=1 ms.|
03-08-2019 21:02:35,068 [Docker][SendAWZService]SendSMS process complete
03-08-2019 21:02:35,068 [Docker][MessageUtil]Return | Status=0 | TxID=19080307210235067254 | Message=Success
03-08-2019 21:02:35,068 [INFO][SendSMSServlet]Process time : 1 ms.
03-08-2019 21:02:51,409 [Docker][SendSMSServlet]UNIQ_TXN_ID= 771382711781@Pokemon22210251409, HTTP headers:Host=10.94.96.136, Cache-Control=no-cache, Pragma=no-cache, User-Agent=Java/1.8.0_171, Accept=
text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2, Content-type=application/x-www-form-urlencoded, X-Forwarded-For=192.168.1.30, X-Forwarded-Host=amasmsapi.ama.cn, X-Forwarded-Server=dtacsmsa
pi.dtac.co.th, Connection=Keep-Alive, Content-Length=168, , ElapsedTime=0 ms.


out puts after grep kyword = 994425363154
1st line start from Recieve Data From Amazon
end line : [INFO][SendSMSServlet]Process time
Code:
03-08-2019 21:02:20,938 [Docker][SendAWZService]::: Recieve Data From Amazon :::
03-08-2019 21:02:20,938 [Docker][SendAWZService]IP : 192.168.1.1 | msg = Your confirmation code for 'Verify phone number' is xxxxx | sno = null | refNo = 21936651171 | encoding
 = 25 | msgType = H | userHeader = null | validPeriod = null | user = amazonapi | password = amazonapi | sender = AMA | timeStamp = null | isconcat = 1 | msnList = null | msn = 994425363154 | buffe
rTxnID = null | remoteAddr = null
03-08-2019 21:02:20,938 [Docker][AWZUtility]ReformatRefno 
03-08-2019 21:02:20,938 [Docker][AWZUtility]ReformatRefno refno:19080307210220938253
03-08-2019 21:02:20,938 [Docker][ValidateDocker]::: ValidateDocker :::
03-08-2019 21:02:20,938 [Docker][ValidateDocker]Eng Message : false
03-08-2019 21:02:20,938 [Docker][ValidateDocker]No UserHeader
03-08-2019 21:02:20,938 [Docker][ValidateDocker]Message length : 280
03-08-2019 21:02:20,938 [Docker][SendAWZService]API ValidateDocker :: Error Code=0, UNIQ_TXN_ID=771382511781@Pokemon22210220938, ElapsedTime=0 ms.
03-08-2019 21:02:20,938 [Docker][SendAWZService]Validate bean success.
03-08-2019 21:02:20,948 [INFO][SendAWZService]UNIQ_TXN_ID=771382511781@Pokemon22210220938 ElapsedTime detail|reserveQuota=10 ms.|classifyNumber=0 ms.|getCache=0 ms.|validateMsgFormat=0 ms.|validateSen
dSMS=0 ms.|processTime=10 ms.|
03-08-2019 21:02:20,948 [Docker][SendAWZService]SendSMS process complete
03-08-2019 21:02:20,948 [Docker][MessageUtil]Return | Status=0 | TxID=19080307210220938253 | Message=Success
03-08-2019 21:02:20,949 [INFO][SendSMSServlet]Process time : 11 ms.


Please Help me
Thanks in advance,
regards,
Ooil
# 2  
Not clear. Do you want to print the entire paragraph from Recieve Data From Amazon down to [INFO][SendSMSServlet]Process time IF that specific msn number is within? How do you supply the msn number, in a variable?


Not the slightest attempts / ideas / thoughts from your side?
# 3  
Note also that if you are looking for the string Recieve Data From Amazon, you might never find it because you have misspelled Receive. Does your input file also contain that misspelling or is it possible that your code can't find the boundaries of the paragraphs you want to copy because the text you are looking for never appears in your actual input?
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

How to grep multi line with keyword ?

Hi All. how to grep with same keyword. 23-07-2012 15:15:30,117 ::: Recieve Message From Commadu ::: .. ... .... 23-07-2012 16:15:28,481 ::: Recieve Message From Commadu ::: 23-07-2012 16:15:28,481 IP : 127.0.0.1 | msg =... (1 Reply)
Discussion started by: ooilinlove
1 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

Featured Tech Videos