Re: uniq without sort <-------------- GURU NEEDED
On Jan 25, 4:50 am, Stephane Chazelas <stephane_chaze... [at] yahoo.fr>
wrote:
> On Fri, 25 Jan 2008 02:39:23 -0800 (PST), William James wrote:
>
> [...]> ruby -e 'puts ARGF.to_a.uniq' the_file
>
> [...]
>
> zsh:
>
> print -rl -- ${(uf)"$(<the_file)"}
>
> (will remove empty lines, and will output an empty line if the
> file is empty).
The Ruby program is devoid of those defects.
In addition, it is more pleasing to the eye and
to the mind.
Re: uniq without sort <-------------- GURU NEEDED
On Fri, 25 Jan 2008 04:22:47 -0800 (PST), William James wrote:
[...]
>> [...]> ruby -e 'puts ARGF.to_a.uniq' the_file
[...]
>> zsh:
>>
>> print -rl -- ${(uf)"$(<the_file)"}
>>
>> (will remove empty lines, and will output an empty line if the
>> file is empty).
>
> The Ruby program is devoid of those defects.
> In addition, it is more pleasing to the eye and
> to the mind.
[...]
Indeed and probably faster as well for big files. Note that the
above ruby and zsh versions share the same drawback when
compared to the awk version in that they store the whole
original file in memory instead of just the uniq values.
--
Stephane