all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* uniq without sort  <-------------- GURU NEEDED
@ 2008-01-25  2:45 gnuist006
  2008-01-25  7:56 ` Thierry Volpiatto
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gnuist006 @ 2008-01-25  2:45 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-29 13:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.