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/