Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: a one-liner for this trivial problem?

by PrakashK (Pilgrim)
on Apr 19, 2013 at 19:11 UTC ( #1029566=note: print w/ replies, xml ) Need Help??


in reply to a one-liner for this trivial problem?

perl -ne 'BEGIN {open my $sh, "<", shift; %h = map {$_ => 1} <$sh>} print unless $h{$_}' small large

Read the small file in the BEGIN block and shift it out of @ARGV.

A minor plus of this approach is that any number of "large" files can be passed, after the "small" file.

If you have File::Slurp available:

perl -MFile::Slurp=slurp -ne 'BEGIN {%h = map {$_ => 1} slurp shift} print unless $h{$_}' small large


Comment on Re: a one-liner for this trivial problem?
Select or Download Code
Re^2: a one-liner for this trivial problem?
by tbone654 (Sexton) on Aug 27, 2013 at 14:38 UTC
    exclude smallfile from largefile
    grep -i -v -f smallfile largefile
    include only smallfile from largefile
    grep -i -f smallfile largefile
    include only smallfile from largefile in reverse order numberic by kolumn 2
    grep -i -f smallfile largefile | sort -r -b -g -k 2

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-07-25 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls