use strict; use warnings; my $file_count=@ARGV; my %seen; while(<>) { # File $ARGV saw line $_ at least once by file $ARGV $seen{$_}{$ARGV}++; } while( my ($line, $by_whom) = each %seen) { if ( $file_count == keys %$by_whom) { # Every file saw this line at least once print $line } } #### perl -ne 'BEGIN{$count = @ARGV}; $seen{$_}{$ARGV}=1; END{while( ($line, $by_whom) = each %seen){ print $line if $count == keys %$by_whom}} '