perl one liner to remove duplicates from a file

Posted: April 4, 2013 in Uncategorized

Say we have a file input.txt which contains

File : input.txt
11
22
33
11
22
33
11
22

and now, we want to remove duplicate entries from the file . Its easy ! Just a single line in perl

 cat input.txt | perl -ne '{$H{$_}++ or print $_'

This will give you the output

File : input.txt
11
22
33
Advertisements

Comments are closed.