bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] doc: add a sort by line length example to sort info


From: Pádraig Brady
Subject: [PATCH] doc: add a sort by line length example to sort info
Date: Sat, 25 Jul 2009 01:12:04 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Pádraig Brady wrote:
> Jim Meyering wrote:
>> Pádraig Brady wrote:
>>> Also it's quite easy to achieve with existing tools:
>>> awk '{print length, $0}' <file | sort -n | cut -f2- -d' '
>> IMHO, this is a decisive argument for not adding the option.
>> However, I would welcome a paragraph documenting the technique as
>> an example of how to extend sort.
> 
> I'll mention the DSU idiom in the info docs,
> with this as an example.

attached
>From 48d9b15477de1b6b53857642bc7c4aba0ccf9d67 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Sat, 25 Jul 2009 00:46:12 +0100
Subject: [PATCH] doc: add a sort by line length example to sort info

* doc/coreutils.texi (sort invocation): Add an example showing how
to sort data not directly supported by the sort command.
---
 doc/coreutils.texi |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 4599a27..f1072a9 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -4258,6 +4258,17 @@ by the sort operation.
 @c @end example
 
 @item
+Use the common @acronym{DSU, Decorate Sort Undecorate} idiom to
+sort lines according to their length.
+
address@hidden
+awk '@{print length, address@hidden' </etc/passwd | sort -n | cut -f2- -d' '
address@hidden example
+
+In general this technique can be used to sort data that the @command{sort}
+command does not support directly.
+
address@hidden
 Shuffle a list of directories, but preserve the order of files within
 each directory.  For instance, one could use this to generate a music
 playlist in which albums are shuffled but the songs of each album are
-- 
1.6.2.5


reply via email to

[Prev in Thread] Current Thread [Next in Thread]