From: Christian Neukirchen Date: 2005-10-07T21:21:25+09:00 Subject: Re: One-liner removing duplicate lines "Robert Klemme" writes: > Damien Wyart wrote: >> Many thanks to everyone who responded, the answers are very >> interesting and enlightening ! > > As far as I can see noone used the Hash with block feature. So here it > is: > > ruby -e 'h=Hash.new(){|ha,l| puts l;ha[l.freeze]=1};ARGF.each {|l| h[l]}' Or, using my favorite unknown Hash method, fetch with a block: ruby -ne '($h||={}).fetch($_){puts $h[$_]=$_}' > robert -- Christian Neukirchen http://chneukirchen.org