in reply to Deleting duplicate lines from file
If you need to order your code:#!/usr/bin/perl use strict; use Digest::MD5 qw(md5); my (@lines, %line_md5); while (<>) { unless (/^\s*$/) { my $digest = md5($_); unless ( exists $line_md5{$digest} ) { $line_md5{$digest} = 1; push @lines, $_; } } else { push @lines, $_; } } print @lines;
cat file | sort | uniq
Hope that helps :-)
update oops, i forget to say: supersearch is your friend ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Deleting duplicate lines from file
by blazar (Canon) on Feb 17, 2006 at 11:25 UTC | |
by turo (Friar) on Feb 17, 2006 at 18:35 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |