[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New sort(1) feature -- sort by length
From: |
Pádraig Brady |
Subject: |
Re: New sort(1) feature -- sort by length |
Date: |
Fri, 17 Jul 2009 10:31:30 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Ethan Baldridge wrote:
> I had a list to sort at work today that needed to be in the format "A B
> C D E... AA BB CC DD" but sort(1) only returns results as "A AA B BB C
> CC".
>
>
>
> So I wrote a patch to add -length-sort as an option. (-l was not taken
> as a short option so I added that too).
>
>
>
> Here it is attached as a unified diff. I tested it and it seems to work
> naturally in conjunction with other operands, so I don't believe there
> are likely to be problems.
Thanks for doing that!
I'm not sure that it belongs in sort though as it's quite specialized.
Also there is ambiguity in the length of a line.
I.E. is it bytes, characters or screen cells.
Also it's quite easy to achieve with existing tools:
awk '{print length, $0}' <file | sort -n | cut -f2- -d' '
What might be better would be to add an option
to `wc` to get it to prepend various counts to a line
(words, chars, bytes, cells), which then could be
sorted and stripped as above.
cheers,
Pádraig.
- RE: New sort(1) feature -- sort by length, Ethan Baldridge, 2009/07/16
- New sort(1) feature -- sort by length, Ethan Baldridge, 2009/07/16
- Re: New sort(1) feature -- sort by length,
Pádraig Brady <=
- 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, 2009/07/24
- Re: [PATCH] doc: add a sort by line length example to sort info, Jim Meyering, 2009/07/25