Advertisement

07.10.2008 at 07:09AM PDT, ID: 23553798
[x]
Attachment Details

Matching across lines

Asked by sunnycoder in Perl Programming Language, Scripting Languages, Shell Scripting

Tags: Perl

I have a log file with 3 kinds of entries: memory allocation, freeing and realloc'ing

Each of them looks like this:

memory allocation
0x12e8eb00  200 bytes allocated as request from filename.c function_name 122 1215683985
   |                   |                                                                                                
   |                   |--- amount of memory allocated                                              
   |                                                                                                                      
   |----- starting address of allocated memory                                                    


memory reallocation
0x9420be0 realloc 0x94214c0  4448 bytes   allocated as request from filename.c function_name 213 1215683975
    |                              |               |-- amount of memory requested                                                  
    |                              |                                                                                                                      
    |                              |---- address after realloc                                                                              
    |
    |------- address before realloc


0x9420c60 freed from filename.c function_name 430 1448619662727
    |
    |
    |----- address being freed

the file has been sorted on first field - i.e. memory addresses.

I want a script that can delete consecutive lines that correspond to allocation and free requests of the same address.

address1   100 bytes allocated ....
address1    freed from ...
address2    100 bytes allocated ....
address2    freed from ...
address3    100 bytes allocated ....
address4    100 bytes allocated ....
address4    freed from ...
address5    100 bytes allocated ....

Output from the above file should be
address3    100 bytes allocated ....
address5    100 bytes allocated ....

Note that there may be more than one space character separating any two words, but all words are space separated - no tabs.

A perl or a bash script would do.Start Free Trial
[+][-]07.10.2008 at 07:11AM PDT, ID: 21973571

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 07:45AM PDT, ID: 21973898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 07:47AM PDT, ID: 21973919

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 07:48AM PDT, ID: 21973941

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 07:55AM PDT, ID: 21974016

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Perl Programming Language, Scripting Languages, Shell Scripting
Tags: Perl
Sign Up Now!
Solution Provided By: nedfine
Participating Experts: 4
Solution Grade: A
 
 
[+][-]07.10.2008 at 07:56AM PDT, ID: 21974028

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 08:01AM PDT, ID: 21974090

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 08:05AM PDT, ID: 21974137

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 08:19AM PDT, ID: 21974261

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 08:22AM PDT, ID: 21974300

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 12:31AM PDT, ID: 22066767

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628