[Malvern] OT - Perl Query

Chris Eilbeck chris at hyperspace.org.uk
Sun Sep 16 09:34:44 BST 2007


On Sun, Sep 16, 2007 at 09:08:53AM +0100, Stuart Bird wrote:
> Hi All
> 
> Can anyone help me amend this perl one liner to write the duplicates to
> "combined.txt" rather than strip out the duplicates and print whats left
> (I think that makes sense :)
> 
> '$count=0; while (<>) {if (! ($var{$_}++)) {print $_; $count++;}} warn
> "\n\nRead $. lines.\nTook union and removed duplicates, yielding $count
> lines.\n"'>./data.>/data1.txt > ./combined.txt

Don't reinvent the wheel, just pipe your file through uniq.

Chris
-- 
Chris Eilbeck
MARS Flight Crew                              http://www.mars.org.uk/
UKRA #1108 Level 2                                                UYB
Tripoli UK Member #9527                                          LSMR



More information about the Malvern mailing list