加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl 打印特定行日志

发布时间:2020-12-15 23:46:42 所属栏目:大数据 来源:网络整理
导读:#!/usr/bin/perl $dir='/home/websphere/WebSphere/AppServer/profiles/AppSrv01/logs/server1';$file = 'SystemErr.log';$mon_file="$dir/$file";print "$mon_file is $mon_filen";@warn_arr = qw/连接已关闭 NullPointException IndexOutOfBound/;foreac
#!/usr/bin/perl 
$dir='/home/websphere/WebSphere/AppServer/profiles/AppSrv01/logs/server1';
$file = 'SystemErr.log';
$mon_file="$dir/$file";
print "$mon_file is $mon_filen";
@warn_arr = qw/连接已关闭 NullPointException IndexOutOfBound/;
foreach $a  (@warn_arr){
   open (C,"<","$a.tmp")  ;
         while (<C>){   
                       $count  = $_;   
                                             }   
         print "$count is $countn";   
                                                                                      
         $info =`tac $mon_file  |  grep "$a" | head -1`;   
                                                                                                                      
         open (A,"$mon_file") || die "$!n";   
$i=0;
while (<A>) {  
        $num++; 
       if ($_ =~ /$a/i){$i++;$b=$num};
       };   

      if ( $i !=0 && $i != $count && defined($count)) {
    open (B,"$mon_file") || die "$!n";
   while  (<B>) {
  print $_  if ($.>=$b and $.<=$b + 10) }};
                                                                                                                                                                                            open (C,">","$a.tmp");
                                                                                                                                                                                             print C ("$in"); 

                                                                                                                                                                                             }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读