in reply to find common lines in many files
So something must have gone wrong here...
If one file contains more than one instance of any given line, then your count will reach ten even if it is only seen in 9 files. (BTW: Why test for numeric equality with a regex?)
For upto 32 files (Or 64 if you have 64-bit ints) then you could use something like this (untested):
#! perl -slw use strict; my $n = 2 ** @ARGV - 1; my %hash; for my $i ( 0 .. $#ARGV ) [ open my $in, '<', $ARGV[ $i ] or die "$ARGV[ $i ] : $!"; while( <$in> ) { chomp; ( vec( $hash{ $_ }, 1, $i ) |= 1 ) == $n and print; } }
It's not easy to cast that as a one-liner because of the need to know which input file you are dealing with.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find common lines in many files
by BrowserUk (Patriarch) on Jul 11, 2011 at 09:45 UTC | |
by jethro (Monsignor) on Jul 11, 2011 at 09:56 UTC | |
by BrowserUk (Patriarch) on Jul 11, 2011 at 10:13 UTC |