Search first file line after Error and display


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search first file line after Error and display
# 1  
Old 04-24-2017
CPU & Memory Search first file line after Error and display

I have a log file which contains information like below (more than 200 ERROR sets).
Here I want to find first .c file and function after "ERROR: AddressSanitizer" line.

If you see here after "ERROR:" line first

file - asfrecohandling.c
function - ASFPotRecoHandling_Create_RecPaxSrvcComp


Code:
=================================================================
==10073==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f5941fe08c0 at pc 0x7f5ed5d37de8 bp 0x7fffe6927310 sp 0x7fffe6927308
READ of size 4 at 0x7f5941fe08c0 thread T0
    #0 0x7f5ed5d37de7 in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
    #1 0x7f5ed5d2ef50 in ASFPotRecoHandling ../Sources/ASFServices_Process/C/asfrecohandling.c:399



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 04-24-2017 at 01:22 PM.. Reason: Added CODE tags.
# 2  
Old 04-24-2017
Any attempts / ideas / thoughts from your side?

Indeed, the .c file name is in the second line after your ERROR string.
# 3  
Old 04-24-2017
Sometimes .c file will be in 3 or 4 th lines also so we need to take first .c file after ERROR line.
# 4  
Old 04-24-2017
Any attempts / ideas / thoughts from your side?

Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, and adequate (representative) sample input and desired output data and the logics connecting the two, to avoid ambiguities and keep people from guessing.
# 5  
Old 04-24-2017
Code:
cat console.log | grep "ERROR" -A3 | tail -n 17

it is displaying but I would require first .c file and function of the file after ERROR line.

hope you got my point.

output :--


Code:
==10073==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f5941fe08c0 at pc 0x7f5ed5d37de8 bp 0x7fffe6927310 sp 0x7fffe6927308
READ of size 4 at 0x7f5941fe08c0 thread T0
    #0 0x7f5ed5d37de7 in _________trptc ../Sources/TRPTC_Process/--
==13400==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f10e193fad0 at pc 0x7f16758ccde8 bp 0x7fff2d2b60e0 sp 0x7fff2d2b60d8
READ of size 4 at 0x7f10e193fad0 thread T0
    #0 0x7f16758ccde7 in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
--
==12454==ERROR: AddressSanitizer: SEGV on unknown address 0x632000156500 (pc 0x7f1e67a38def bp 0x7fff2270e330 sp 0x7fff2270db50 T0)
    #0 0x7f1e67a38dee in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
    #1 0x7f1e67a2ff50 in ASFPotRecoHandling ../Sources/ASFServices_Process/C/asfrecohandling.c:399
--
==9443==ERROR: AddressSanitizer: heap-use-after-free on address 0x62d000038452 at pc 0x7fd37561c5cf bp 0x7fffddd55ba0 sp 0x7fffddd55b98
READ of size 1 at 0x62d000038452 thread T0
    #0 0x7fd37561c5ce in ASFProcessSC_CheckSrvcComp ../Sources/ASFServices_Common/C/asfprocesssc.c:2119
ppolakala@ncefqdev12:~/ASAN> cat console | grep "ERROR" -A3 | tail -n 17
    #0 0x7f5ed5d37de7 in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
    #1 0x7f5ed5d2ef50 in ASFPotRecoHandling ../Sources/ASFServices_Process/C/asfrecohandling.c:399
--
==13400==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f10e193fad0 at pc 0x7f16758ccde8 bp 0x7fff2d2b60e0 sp 0x7fff2d2b60d8
READ of size 4 at 0x7f10e193fad0 thread T0
    #0 0x7f16758ccde7 in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
    #1 0x7f16758c3f50 in ASFPotRecoHandling ../Sources/ASFServices_Process/C/asfrecohandling.c:399
--
==12454==ERROR: AddressSanitizer: SEGV on unknown address 0x632000156500 (pc 0x7f1e67a38def bp 0x7fff2270e330 sp 0x7fff2270db50 T0)
    #0 0x7f1e67a38dee in ASFPotRecoHandling_Create_RecPaxSrvcComp ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
    #1 0x7f1e67a2ff50 in ASFPotRecoHandling ../Sources/ASFServices_Process/C/asfrecohandling.c:399
    #2 0x7f1e67a0ba00 in ASFOutputMapping ../Sources/ASFServices_Process/C/asfoutputmapping.c:312
--
==9443==ERROR: AddressSanitizer: heap-use-after-free on address 0x62d000038452 at pc 0x7fd37561c5cf bp 0x7fffddd55ba0 sp 0x7fffddd55b98
READ of size 1 at 0x62d000038452 thread T0
    #0 0x7fd37561c5ce in ASFProcessSC_CheckSrvcComp ../Sources/ASFServices_Common/C/asfprocesssc.c:2119
    #1 0x7fd37560a062 in ASFProcessSPU_CheckAllSrvcComp ../Sources/ASFServices_Common/C/asfprocessspu.c:1621

Moderator's Comments:
Mod Comment Seriously! Please use CODE tags as required by forum rules!

Last edited by RudiC; 04-24-2017 at 03:27 PM.. Reason: Added CODE tags.
# 6  
Old 04-24-2017
Like so?
Code:
awk '/ERROR: AddressSanitizer/ {L = 1} L && /\.c/ {print "file:", $5; print "function:", $4; L = 0}' file
file: ../Sources/ASFServices_Process/C/asfrecohandling.c:1431
function: ASFPotRecoHandling_Create_RecPaxSrvcComp

# 7  
Old 04-25-2017
Thanks Sir (y). i will check from here
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search words in multiple file line by line

Hi All I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name. (4 Replies)
Discussion started by: netdbaind
4 Replies

2. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

3. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

4. Shell Programming and Scripting

search a string in a particular column of file and return the line number of the line

Hi All, Can you please guide me to search a string in a particular column of file and return the line number of the line where it was found using awk. As an example : abc.txt 7000,john,2,1,0,1,6 7001,elen,2,2,0,1,7 7002,sami,2,3,0,1,6 7003,mike,1,4,0,2,1 8001,nike,1,5,0,1,8... (3 Replies)
Discussion started by: arunshankar.c
3 Replies

5. Shell Programming and Scripting

How to search for file and display by date

I like "ls -ltr". I would like to search for a file in a large directory recursively and and display all the candidates in reverse order. /usr/bin/find . -name \*.txt This works. How do I display the date and sort the file names by the date in reverse order for the entire directory... (1 Reply)
Discussion started by: siegfried
1 Replies

6. Shell Programming and Scripting

Search name and display column from a file

Hi I have search everywhere for this but I haven't got any result. so here is my question? I am trying to ask user to enter a name and then searching that name from a file and from a specific column. If user enter something, it should only displaying that name from that specific column and If the... (3 Replies)
Discussion started by: sillyha
3 Replies

7. Shell Programming and Scripting

Search in file and display

Dear All I had below mention requirement. Kindly sugguest me possible ways. Thanks Regards Jaydeep IN PUT FILE: CELL BROADCAST SHORT MESSAGE SERVICE MESSAGE DATA ID CODE GS UPDATE MODE LANG MCO MCL NUMPAGES 50 1000 0 13 MML 1 1 TEXT PAGE *999*1# SONGS4U@30/M- 1 (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

8. Shell Programming and Scripting

Search from file and display

Dear all I had input file as mention below. From that i want op as given below. Kindly let me knw possible ways. Regards Jaydeep CONNECTED bscaaa <rxmfp:mo=RXOTX-46-5 ; RADIO X-CEIVER ADMINISTRATION MANAGED OBJECT FAULT INFORMATION MO BTSSWVER RXOTX-46-5 ERA-G04-R11-V01 ... (5 Replies)
Discussion started by: jaydeep_sadaria
5 Replies

9. Shell Programming and Scripting

Search from file and display

Dear All I had input file as mention below. Now from that file i want to search string "FAULT CODES CLASS" and want to display contain again its. ( ie. 1B4 --4 is in next line. ). Kindly let me know the possible ways. <rxmfp:mo=RXOTX-46-5 ; ... (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

10. Shell Programming and Scripting

Display a particular line from a file

Hi, What is the command i can use iof i want to display a particular line from a file, i have the line number with me. (5 Replies)
Discussion started by: Rohini Vijay
5 Replies
Login or Register to Ask a Question