Trying to write a script that can search for a log file which pass the two requirement and generate number of count of specific error
2 requirement - each line must be certain date, and either error1 or error2 or error3 or error4 Tried something below
And i am struck here. not sure if the split that i use really work and mymy $time = localtime(); my ($wd,$mon,$mond,$times,$year) = split /\s+/, $time; my $pattern_date = "$mon $mond"; my @array = ("error4", "error3", "error2", "error1"); my $count; my @word_search; my $line; my $w; my $wordcount; open (OUTFILE, "/home/me/textfile.txt") || die ("can not open file for + writing"); while ($line = <OUTFILE>) { chop $line; @word_search = split(/ /,$line); $w = 1; while ($w <= @word_search) { if ($word_search[$w-1] eq $pattern_date && $word_search[$w-1] eq $arra +y[$count]) { $wordcount++; } $w++; } } #print ("$array[$count] occurs $wordcount\n"); #print "$pattern_date found $wordcount\n"; #} close (OUTFILE);
is correct. Anyone help?"if ($word_search[$w-1] eq $pattern_date && $word_search[$w-1] eq $arr +ay[$count]) { "
In reply to Re^2: search log file with multiple word and count number of success
by steadybompipi
in thread search log file with multiple word and count number of success
by steadybompipi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |