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.
William James [ Fr, 25 Januar 2008 13:22 ] [ ID #1915908 ]

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
Stephane CHAZELAS [ Fr, 25 Januar 2008 13:52 ] [ ID #1915911 ]
Linux » comp.unix.shell » Re: uniq without sort <-------------- GURU NEEDED

Vorheriges Thema: Re: uniq without sort <-------------- GURU NEEDED
Nächstes Thema: $1 issue with prstat