in reply to Re^2: Logfile parsing across redundant files
in thread Logfile parsing across redundant files
On the basis of what you've said about the data, it could be as simple as this:
#! perl -slw use strict; my $dir = $ARGV[ 0 ] || die 'Need a directory'; my %hash; while( my $file = <"$dir/*.log"> ) { open my $fh, '<', $file or die "$file : $!"; while( <$fh> ) { $hash{ $_ } = 1; } close $fh; } open my $fh, '>', "$dir/composite.log" or die $!; print $fh $_ for sort keys %hash; close $fh;
This assumes that all 31 log files from a particular server are located in a single directory, no other files are in that directory, and that the lines can be sorted using an alphanumeric sort. Eg. Each line carries a date/time stamp at the beginning of the line, and it is ordered in some sensible form (YYYYMMDD HH:MM:SS) that will sort correctly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Logfile parsing across redundant files
by thezip (Vicar) on Feb 02, 2007 at 07:20 UTC | |
by BrowserUk (Patriarch) on Feb 02, 2007 at 07:40 UTC |