I need to extract records from a log file with the following format:
|O%:CCLN-1-CBS1:CELLS-1-CELLS1:MCBTS-1-MC1900BTS1183
line 1
line 2
line 3
. . .
#End
There are several of these logs within the log file and I need them all. There is a distinct header and footer for each log as outlined above.
I created the following script, but it only prints one record:
#!/usr/bin/perl -w
foreach $file (@ARGV) {
open(fd1,"<$file");
$mydata = "";
while ($mydata = <fd1>) {
if ($mydata =~ /^.*MCBTS-1-MC1900BTS1183.*BTSCALLPROCESSING-1-BTSCALLPROCESSING1$/) {
print "$mydata";
$mydata = <fd1>;
until ($mydata =~ /^#END$/) {
print "$mydata";
$mydata = <fd1>;
}
print "$mydata";
}
}
close fd1;
}
Any help is appreciated.
|O%:CCLN-1-CBS1:CELLS-1-CELLS1:MCBTS-1-MC1900BTS1183
line 1
line 2
line 3
. . .
#End
There are several of these logs within the log file and I need them all. There is a distinct header and footer for each log as outlined above.
I created the following script, but it only prints one record:
#!/usr/bin/perl -w
foreach $file (@ARGV) {
open(fd1,"<$file");
$mydata = "";
while ($mydata = <fd1>) {
if ($mydata =~ /^.*MCBTS-1-MC1900BTS1183.*BTSCALLPROCESSING-1-BTSCALLPROCESSING1$/) {
print "$mydata";
$mydata = <fd1>;
until ($mydata =~ /^#END$/) {
print "$mydata";
$mydata = <fd1>;
}
print "$mydata";
}
}
close fd1;
}
Any help is appreciated.