Hi,

I want to search the log file for a string and extract all data until the end of that line where the search string is found.
For example:

A line in the file reads like below:
[28/04/2010 11:17:53 GMT]PositionPoolCalculation.java(339):getPosCalculation[INFO]BUNP: B123456:1234567:ABCD ANP: B123456:1234567:ABCD:2 post LCN: DESabcdefgh

I want to search for string BUNP and then extract "B123456:1234567:ABCD ANP: B123456:1234567:ABCD:2 post LCN: DESabcdefgh"

while ($record = <INPUT>){

# the below condition reads until the work LCN, but I need it until the end of the line

       if ($record =~ m/BU_NP: (.*?) LCN/) { 
              print "$1\n";
          }
         else{
            print "No Match\n";
         }
};

Any help would be appreciated!

Thanks

if ($record =~ m/BUNP:\s*(.*)$/) { #Allow optional space, then capture to end of line

Hi d5e5,

Thanks for the solution!!! it worked well for me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.