unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michele Dondi <bik.mido@tiscalinet.it>
To: help-gnu-emacs@gnu.org
Subject: Re: uniq without sort  <-------------- GURU NEEDED
Date: Tue, 29 Jan 2008 14:16:28 +0100	[thread overview]
Message-ID: <6j9up39qkqe5oolbeoammmiq6hp0vqa5de@4ax.com> (raw)
In-Reply-To: 08698dfa-d5dc-484d-a5fb-fe84bb0d2893@s13g2000prd.googlegroups.com

On Thu, 24 Jan 2008 18:45:24 -0800 (PST), gnuist006@gmail.com wrote:

>I want uniq without sorting the initial order.
>
>The algorithm is this. For every line, look above if there is another
>line like it. If so, then ignore it. If not, then output it. I am
>sure, I can spend some time to write this in C. But what is the
>solution using shell ? This way I can get an output that preserves the
>order of first occurrence. It is needed in many problems.

In shell I don't know. In Perl it's well known to be as trivial as

  perl -ne 'print unless $saw{$_}++' file

(And it's not even the most golfed down solution!)


Michele
-- 
Se, nella notte in cui concepi' il duce,
Donna Rosa, toccata da divina luce,
avesse dato al fabbro predappiano
invece della fica il deretano,
l'avrebbe presa in culo quella sera
Rosa sola e non l'Italia intera.
- Poesia antifascista

      parent reply	other threads:[~2008-01-29 13:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25  2:45 uniq without sort <-------------- GURU NEEDED gnuist006
2008-01-25  7:56 ` Thierry Volpiatto
2008-01-25  9:11 ` Peter Dyballa
     [not found] ` <slrnfpki57.7nj.andrews@sdf.lonestar.org>
     [not found]   ` <slrnfpkj9c.18qn.read_the_sig@mantell0.local>
     [not found]     ` <7d849d0c-9d8e-44e9-b461-38657fae0a7d@b2g2000hsg.googlegroups.com>
     [not found]       ` <5462c3ef-cb53-40d8-8a96-bbf624408300@v4g2000hsf.googlegroups.com>
2008-01-28 16:51         ` thermate
2008-01-29 13:16 ` Michele Dondi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6j9up39qkqe5oolbeoammmiq6hp0vqa5de@4ax.com \
    --to=bik.mido@tiscalinet.it \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).