From: Ryan Leavengood Date: 2005-10-06T05:34:18+09:00 Subject: Re: One-liner removing duplicate lines On 10/5/05, Ryan Leavengood wrote: > > I tried creating a version that mimics the Perl one (because Ruby also > has the -n option), but in the end this seemed easier (and much more > readable): > > ruby -e "puts IO.readlines(ARGV[0]).uniq" infile > outfile > > So you are right about using uniq. Just for sake of comparison, here is the more "Perl-like" version: ruby -ne "s||={};s[$_]||print;s[$_]=1" infile > outfile Maybe some Ruby golfers can shorten it some more, but since Ruby lacks some of the more terse (and obfuscating) features of Perl, it may not be possible. Ryan