Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: a one-liner for this trivial problem?

by PrakashK (Pilgrim)
on Apr 19, 2013 at 19:11 UTC ( [id://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

Replies are listed 'Best First'.
Re^2: a one-liner for this trivial problem?
by tbone654 (Beadle) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1029566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found