How to grep multi line.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep multi line.
# 1  
Old 04-23-2010
Question How to grep multi line.

How to grep multi line.



My LOg.
Code:
.
.
.
.
2010-04-23 02:17:02,419 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default']  INFO - [123456789]-MsgCode = 00903
2010-04-23 02:17:02,420 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default']  INFO - [123456789]- end processABCD126
2010-04-23 02:17:02,420 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default'] DEBUG - try to get message=ERROR_NOT_AUTHORIZED_TO_USE_SERVICE
2010-04-23 02:17:02,420 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Test 1234
2010-04-23 02:17:02,420 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default'] DEBUG - ASCII2Unicode
2010-04-23 02:17:02,421 [ExecuteThread: '164' for queue: 'weblogic.kernel.Default'] DEBUG - write USSDLog path=/usr/home/log/ABCDLog/ABCD126
.
.
.
.
.
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default']  INFO - [012345678950]- end processUSSD126
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - try to get message=ERROR_CANNOT_CHECK_BLACKLIST
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Sorry Test 1234
2010-04-23 07:17:30,755 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - ASCII2Unicode
2010-04-23 07:17:30,756 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - write USSDLog path=/usr/home/log/ABCDLog/ABCD/126
.
.
.
.
2010-04-23 08:25:16,014 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default']  INFO - [55877896452]-MsgCode = 00903
2010-04-23 08:25:16,014 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default']  INFO - [55877896452]-End Function = 1, excute time = 153 millisec.
2010-04-23 08:25:16,014 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default']  INFO - [55877896452]- end processUSSD126
2010-04-23 08:25:16,015 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default'] DEBUG - try to get message=ERROR_CANNOT_CHECK_BLACKLIST
2010-04-23 08:25:16,015 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Sorry Test 123456789
2010-04-23 08:25:16,015 [ExecuteThread: '246' for queue: 'weblogic.kernel.Default'] DEBUG - ASCII2Unicode
.
.
.

I want to grep from something.

Ex. such as "012345678950"
I want to out put like this.
Code:
2010-04-23 07:17:30 [012345678950] - got message=Sorry Test 1234

or
Code:
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default']  INFO - [012345678950]- end processUSSD126
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Sorry Test 1234

can do it?.


Thank You.

Last edited by zaxxon; 04-23-2010 at 06:10 AM.. Reason: use code tags!
# 2  
Old 04-23-2010
What have you tried so far?
# 3  
Old 04-23-2010
I want to study seek new knowledge
# 4  
Old 04-23-2010
Don't want to share the old knowledge? Smilie

One of many ways:
Code:
$> awk -F"[ \t]+|," '/\[012345678950\]/ {print; f=1; next} f==1 && /got message/ {print; f=0}' f=0 infile
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default']  INFO - [012345678950]- end processUSSD126
2010-04-23 07:17:30,754 [ExecuteThread: '359' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Sorry Test 1234

# 5  
Old 04-23-2010
^ ^ Smilie Thank YOU Smilie ^ ^
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

Multi line log files to single line format

I want to read the log file which was generate from other command . And the output was having multi line in log files for job name and server name. But i need to make all the logs on one line Source file 07/15/2018 17:02:00 TRANSLOG_1700 Server0005_SQL ... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

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

4. UNIX for Dummies Questions & Answers

Remove multi line and single line comments

Hi, I am trying to remove multi line and single line comments like examples below I have tried this pattern. it works fine for single line comments and multi line comments in a single line only. but this fails when the comments are extended in multiple lines as shown in the comment 2 of... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

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

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

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

8. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

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

10. Shell Programming and Scripting

How to use Perl to merge multi-line into single line

Hi, Can anyone know how to use perl to merge the following multi-line information which beginning with "BAM" into one line. For each line need to delete the return and add a space. Please see the red color line. ******Org. Multi-line) BAM admin 101.203.57.22 ... (3 Replies)
Discussion started by: happyday
3 Replies
Login or Register to Ask a Question