[Top][All Lists]
[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
- RE: New sort(1) feature -- sort by length, (continued)
- Re: New sort(1) feature -- sort by length, Pádraig Brady, 2009/07/17
- RE: New sort(1) feature -- sort by length, Ethan Baldridge, 2009/07/17
- Re: New sort(1) feature -- sort by length, Pádraig Brady, 2009/07/20
- Re: New sort(1) feature -- sort by length, Erik Auerswald, 2009/07/20
- Re: New sort(1) feature -- sort by length, Ethan Baldridge, 2009/07/23
- Re: New sort(1) feature -- sort by length, Pádraig Brady, 2009/07/23
- Re: New sort(1) feature -- sort by length, Jim Meyering, 2009/07/24
- Re: New sort(1) feature -- sort by length, Pádraig Brady, 2009/07/24
- Re: New sort(1) feature -- sort by length, Ethan Baldridge, 2009/07/24
- [PATCH] doc: add a sort by line length example to sort info,
Pádraig Brady <=
- Re: [PATCH] doc: add a sort by line length example to sort info, Jim Meyering, 2009/07/25