不重复数据字段统计

来源:互联网 发布:linux中vi常用命令 编辑:程序博客网 时间:2024/06/05 08:17


#!/usr/bin/perl -w$direct=$ARGV[0];  //read perl pamameter 1system ("sh /home/fzhao/txt/1.sh $direct");  //perl call shell$count=0;$dup=0;$all=0;$len=0;@b=();open my $fh , '<' ,'1';open my $fh2 , '>>' ,'11';while (my $line=<$fh>) {    @array =split (/\s+/,$line);  //split line into field=pod                                       //perl 成段注释方法    if ($first==0)    {       print "@array";       print "\n";       foreach (@array)       {          print $_;          print ";;";       }       $first=1;       exit;    }=cut    if ( $direct==0 )     {          $hsRas=$array[14];     }    else    {          $hsRas=$array[15];    }    $all++;    $flag=0;    foreach (@b)   //遍历数组    {         if ( $_ eq  $hsRas )         {            $dup++;            $flag=1;            last;         }    }    push @b , $hsRas;    $len =@b;    if ( $flag == 0)    {        print $fh2 "$hsRas\n";        $count++;    }#   print "hsRas=$hsRas\n";}close ($fh);close ($fh2);print "all=$all;dup=$dup;count=$count \n";

====================

1.sh

#!/bin/bashfile=Log1.logdirect=$1rm 1 2 11rm $filescp root@1.2.3.4:/var/log/trace/$file ./grep hsRas $file >2if [ "$direct" -eq 0 ]then        grep send 2 >1else        grep Receive 2 >1fi



0 0