|
From: | Philip Rowlands |
Subject: | Re: Problem with uniq command |
Date: | Thu, 22 Feb 2007 17:57:15 +0000 (GMT) |
On Wed, 21 Feb 2007, Miroslaw Kozielski wrote:
I think I found a bug in 'uniq' command. I have a text file: bla.txt / address@hidden:~/tmp$ cat bla2 ba111. ba112. bs112. bm123. ba123. ba111./After use option - c ( recede each output line with a count of the number of times the line occurred in the input) I receive wrong output:/address@hidden:~/tmp$ uniq -c bla2 * 1 ba111.* 1 ba112. 1 bs112. 1 bm123. 1 ba123. *1 ba111.* /I think that output should be: / *2 ba111*. 1 ba112. 1 bs112. 1 bm123. 1 ba123. / How can I resolve this problem?
Thanks for the "expected output" part - it's rare to see a complete bug report, but in this case the problem is the assumption that uniq will sort its input.
Looking at the manpage, we see "Discard all but one of successive identical lines"; only adjacent lines will be grouped together for counting or dupe-suppression. In practise, this means that input to uniq should be sorted (in the same locale).
Cheers, Phil
[Prev in Thread] | Current Thread | [Next in Thread] |