in reply to Remove duplicate lines maintaining last-in order
Cool. Here is a somewhat more memory-efficient alternative:
perl -ne '$a[$h{$_}]= ""; push @a, $_; $h{$_}= $#a; END{print for @a}' + file
Or, if you want to cut even that memory foot-print (or does it?) roughly in half (at the cost of more CPU):
- tyeperl -ne '$h{$_}= $.; END{print for sort {$h{$a} <=> $h{$b}} keys %h}' + test.txt
|
|---|