Hi there! I have a log file which needs to be properly formatted into a readable format. However the text file has no static number of lines or fixed primary values and has random number of spaces but has only a log file header which can be used to pin point the start and end of each time the application logs.
An Example of the log file:
Log File header
<text>
<text>
Log File header
<text>
After the script has been formatted it should look something like this:
Log File header
<text>
<text>
<space>
Log File header
<text>
<text>
Therefore I need some advice on greping out an entire paragraph everytime the Perl Script detects a "Log File header".
Here is the grep perl script:
#!/usr/bin/perl
#use 5.010; # must be present to import the new 5.10 functions, notice
#that it is 5.010 not 5.10
my $file = "/root/Desktop/Logfiles.log";
open LOG, $file or die "The file $file has the error of:\n => $!";
@lines = <LOG>;
close (LOG);
@array = grep(/Log File header/, @lines);
print @array;
Can someone please give some advice on the codes? Thanks.