Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: (thoughts on) Detect common lines between two files, one liner from shell

by Anonymous Monk
on Dec 23, 2004 at 18:31 UTC ( #417182=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: (thoughts on) Detect common lines between two files, one liner from shell
in thread Detect common lines between two files, one liner from shell

This should also work for an arbitrary number of files, which AFAIK has no equivalent UNIX command. To show common lines in 4 files: perl -ne 'print if ($seen{$_} .= @ARGV) =~ /32+1+0$/' fileA fileB fileC fileD
Comment on Re^3: (thoughts on) Detect common lines between two files, one liner from shell
Replies are listed 'Best First'.
Re^4: (thoughts on) Detect common lines between two files, one liner from shell
by shmem (Canon) on Jun 22, 2007 at 23:55 UTC
    The generalized form would be (golfed down a bit) for any number of files
    perl -ne'BEGIN{$p.=-$_."+"for-@ARGV+1..-1;$p.=0}print if($s{$_}.=@ARGV +)=~/$p$/'

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417182]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2016-04-30 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW







    Results (441 votes). Check out past polls.