This is perl, v5.6.1 built for sun4-solaris
I have listed the platform/OS information for your reference.
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:
Expand|Select|Wrap|Line Numbers
- #!/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;
- }