On 03/17/2014 10:41 AM, Pádraig Brady wrote: > On 03/17/2014 05:06 AM, Александр Ботов wrote: >> Good day! >> >> I've tried to use option -uD to discard the first repeated line as it >> written in info, but it discards the last one. >> >> In the info said that for this purpose I should use option -u not by itself, >> but doesn't said what dose it mean. Could you said (and may be add to the >> man/info) how to use option -u to discard _the first_ repeated line, please? >> >> I use Scientific Linux SL release 5.4 (Boron), Linux version >> 2.6.18-92.1.10.el5.mk8 (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)), uniq >> (GNU coreutils) vesion 5.97. >> >> Best regards, Alexander. > > So the description in question is: > > `-u' > `--unique' > Discard the first repeated line. When used by itself, this option > causes `uniq' to print unique lines, and nothing else. > > Showing all combinations of options with the particular > one in question at the end shows that we always discard > later lines in a group. > > $ cat in
1 a 2 a 3 a 1 b 2 b 1 c > > $ for o in '' '-d' '-D' '-u' '-ud' '-dD' '-uD'; do echo "$=== $o ===="; > src/uniq $o -f1 in; done > 1 a > 2 a > 3 a > 1 b > 2 b > 1 c > $=== ==== > 1 a > 1 b > 1 c > $=== -d ==== > 1 a > 1 b > $=== -D ==== > 1 a > 2 a > 3 a > 1 b > 2 b > $=== -u ==== > 1 c > $=== -ud ==== > $=== -dD ==== > 1 a > 2 a > 3 a > 1 b > 2 b > $=== -uD ==== > 1 a > 2 a > 1 b > > > Now discarding a single item from a repeated group is unusual, > whether one is discarding the first or the last. > We should at least clarify the documentation, but please > consider adjusting the sort(1) to select between these. > I.E. for the above example: sort -r in -k2,2 Pushing the attached. thanks, Pádraig.
>From 296a47b99fde01b29444be99469ae2045b5cd3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]> Date: Wed, 19 Mar 2014 17:01:28 +0000 Subject: [PATCH] doc: clarify the operation of uniq -uD The description of -u was inaccurate when combined with -D: $ printf '%s\n' '1 a' '2 a' | uniq -uD -f1 1 a * doc/coreutils.texi (uniq invocation): Clarify that it's the last repeated line that is suppressed from the output. Fixes http://bugs.gnu.org/17022 --- doc/coreutils.texi | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index e5e27eb..75875d8 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -5210,8 +5210,9 @@ This is a GNU extension. @opindex -u @opindex --unique @cindex unique lines, outputting -Discard the first repeated line. When used by itself, this option -causes @command{uniq} to print unique lines, and nothing else. +Discard the last line that would be output for a repeated input group. +When used by itself, this option causes @command{uniq} to print unique +lines, and nothing else. @item -w @var{n} @itemx --check-chars=@var{n} -- 1.7.7.6
