in reply to Re: search log file with multiple word and count number of success
in thread search log file with multiple word and count number of success
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]) { "
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: search log file with multiple word and count number of success
by jdporter (Paladin) on Feb 23, 2008 at 13:45 UTC | |
|
Re^3: search log file with multiple word and count number of success
by hipowls (Curate) on Feb 24, 2008 at 04:21 UTC | |
by steadybompipi (Novice) on Feb 24, 2008 at 13:59 UTC | |
|
Re^3: search log file with multiple word and count number of success
by steadybompipi (Novice) on Mar 02, 2008 at 13:49 UTC |