in reply to Comparing files
(untested)use strict; my @all_files = </export/home/*_01day>; # angle brackets around a bareword path pattern returns all matchi +ng file names my %macs_found; for my $path ( @all_files ) { my $file = $path . ":"; $file =~ s{.*/}{:}; # now it's ":*_01day:" unless ( open( FILE, $path )) { warn "open failed on $path: $!\n"; next; } while (<FILE>) { chomp; $macs_found{$_} .= $file unless $macs_found{$_} =~ /$file/; } close FILE; } # Now for each mac value, see how many files had it: my $nfiles = scalar @all_files; for my $mac ( sort keys %macs_found ) { if ( split( /::/, $macs_found{$mac} ) == $nfiles ) { print "$mac found in all $nfiles input files\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing files
by dannyp (Novice) on Jul 20, 2004 at 23:26 UTC | |
|
Re^2: Comparing files
by dannyp (Novice) on Jul 21, 2004 at 19:45 UTC | |
by graff (Chancellor) on Jul 21, 2004 at 22:56 UTC |