Re: uniq without sort <-------------- GURU NEEDED
- From: Jürgen Exner <jurgenex@xxxxxxxxxxx>
- Date: Tue, 29 Jan 2008 23:38:37 GMT
Michael Tosch <eedmit@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Michele Dondi wrote:
On Thu, 24 Jan 2008 18:45:24 -0800 (PST), gnuist006@xxxxxxxxx wrote:
I want uniq without sorting the initial order.
[...]In shell I don't know. In Perl it's well known to be as trivial as
perl -ne 'print unless $saw{$_}++' file
This is "print first unique".
For "print last unique" you really need perl:
perl -ne '$s{$_}=++$i; END {print sort {$s{$a}<=>$s{$b}} keys %s}'
Or just read slurp the whole file into an array, reverse(), and then use
Michele's suggestion.
jue
.
- References:
- Re: uniq without sort <-------------- GURU NEEDED
- From: Michael Tosch
- Re: uniq without sort <-------------- GURU NEEDED
- Prev by Date: Re: domains, top level, collecting a list of
- Next by Date: "negative" regexp
- Previous by thread: Re: uniq without sort <-------------- GURU NEEDED
- Next by thread: scalar to array?
- Index(es):
Relevant Pages
|