all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: gnuist006@gmail.com
To: help-gnu-emacs@gnu.org
Subject: uniq without sort  <-------------- GURU NEEDED
Date: Thu, 24 Jan 2008 18:45:24 -0800 (PST)	[thread overview]
Message-ID: <08698dfa-d5dc-484d-a5fb-fe84bb0d2893@s13g2000prd.googlegroups.com> (raw)

This is a tough problem, and needs a guru.

I know it is very easy to find uniq or non-uniq lines if you scramble
all of them and sort them. Its trivially

echo -e "a\nc\nd\nb\nc\nd" | sort | uniq

$ echo -e "a\nc\nd\nb\nc\nd"
a
c
d
b
c
d

$ echo -e "a\nc\nd\nb\nc\nd"|sort|uniq
a
b
c
d


So it is TRIVIAL with sort.

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.

Thanks to the star who can help
gnuist

             reply	other threads:[~2008-01-25  2:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25  2:45 gnuist006 [this message]
2008-01-25  7:56 ` uniq without sort <-------------- GURU NEEDED 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

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

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

  git send-email \
    --in-reply-to=08698dfa-d5dc-484d-a5fb-fe84bb0d2893@s13g2000prd.googlegroups.com \
    --to=gnuist006@gmail.com \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.