|
| From: | Renaud Pacalet |
| Subject: | Re: [sort] Suggestion: count keys from the end of record |
| Date: | Mon, 14 Aug 2023 08:56:32 +0200 |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 |
On 13/08/2023 17:09, Pádraig Brady wrote:
On 13/08/2023 15:40, Renaud Pacalet wrote:I am a bit surprised that it has never been suggested before but I could not find any trace of it, so here it is: Would it be possible to specify the sorting keys from the end of the record, instead of the beginning. Something like sort -k-1,-1 to sort on the last field of each record, sort -k-2,-2 for the second to last... This would be handy when the format has a variable number of fields per record but the last records are well defined.I vaguely remember this being suggested before ... https://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00008.html
Ah, so it has been suggested before, thanks for the link.
The interface and functionality does make sense.The only question I have is if it is functionality that is needed often enough.
There are some questions on Stackoverflow indicating that this is sometimes needed. Example:
https://stackoverflow.com/questions/76892900/sort-text-page-based-on-5th-column-out-of-6-columns-being-troubled-with-as-the https://stackoverflow.com/questions/16593463/unix-sort-using-unknown-delimiter-last-column https://stackoverflow.com/questions/53000340/shell-sort-command-how-to-sort-by-the-last-column-the-number-of-columns-is-un ... Don't know if it is enough, though. -- Renaud Pacalet Télécom Paris Campus SophiaTech 450 Route des Chappes, CS 50193 06904 Biot Sophia Antipolis cedex, FRANCE Tel : +33 (0) 4 9300 8402 Web : http://www.telecom-paris.fr/
| [Prev in Thread] | Current Thread | [Next in Thread] |