bug-coreutils
[Top][All Lists]
Advanced

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

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


From: Jim Meyering
Subject: Re: [PATCH] doc: add a sort by line length example to sort info
Date: Sat, 25 Jul 2009 10:18:48 +0200

Pádraig Brady wrote:
> 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

s/ to sort info//

> * doc/coreutils.texi (sort invocation): Add an example showing how
> to sort data not directly supported by the sort command.

Nice.  Thanks!

> ---
>  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

It's ok to remove the '<'.

> +In general this technique can be used to sort data that the @command{sort}
> +command does not support directly.




reply via email to

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