in reply to Find duplicate lines from the file and write it into new file.
Expects to be run as script < inputfile > outputfile#!/usr/bin/perl use strict; use warnings; while (<>) { chomp; $duplicates{$_}++; } foreach my $key (keys %duplicates) { if ($duplicates{$key} > 1) { delete $duplicates{$key}; print "$key\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find duplicate lines from the file and write it into new file.
by roboticus (Chancellor) on Jan 04, 2007 at 13:56 UTC | |
by PerlInMyBlood (Initiate) on Jun 28, 2011 at 08:56 UTC | |
by choroba (Cardinal) on Jun 28, 2011 at 09:17 UTC |