GNU bug report logs - #70532
sort: Mention counting fields from the end

Previous Next

Package: coreutils;

Reported by: Dan Jacobson <jidanni <at> jidanni.org>

Date: Tue, 23 Apr 2024 10:15:04 UTC

Severity: normal

To reply to this bug, email your comments to 70532 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#70532; Package coreutils. (Tue, 23 Apr 2024 10:15:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 23 Apr 2024 10:15:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dan Jacobson <jidanni <at> jidanni.org>
To: bug-coreutils <at> gnu.org
Subject: sort: Mention counting fields from the end
Date: Tue, 23 Apr 2024 18:14:02 +0800
In (info "(coreutils) sort invocation") be sure to add an example of a
way or workaround for counting fields from the end of the line. E.g., we
want to sort on the last field, but don't know for sure how many fields
a line might contain. E.g., sort by surname, when lines consist of First
[Middle...] Surname. perl -a uses $F[-1]. so maybe sort(1) could also
use a negative field number. Same for character number.

sort (GNU coreutils) 9.4




Information forwarded to bug-coreutils <at> gnu.org:
bug#70532; Package coreutils. (Tue, 23 Apr 2024 10:48:05 GMT) Full text and rfc822 format available.

Message #8 received at 70532 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Dan Jacobson <jidanni <at> jidanni.org>, 70532 <at> debbugs.gnu.org
Subject: Re: bug#70532: sort: Mention counting fields from the end
Date: Tue, 23 Apr 2024 11:47:28 +0100
On 23/04/2024 11:14, Dan Jacobson wrote:
> In (info "(coreutils) sort invocation") be sure to add an example of a
> way or workaround for counting fields from the end of the line. E.g., we
> want to sort on the last field, but don't know for sure how many fields
> a line might contain. E.g., sort by surname, when lines consist of First
> [Middle...] Surname. perl -a uses $F[-1]. so maybe sort(1) could also
> use a negative field number. Same for character number.

All good suggestions. I'll at least add an example along the lines of:

  awk '{print $NF, $0}' | sort -k1,1 | cut -f2- -d' '

cheers,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#70532; Package coreutils. (Sat, 27 Apr 2024 05:47:06 GMT) Full text and rfc822 format available.

Message #11 received at 70532 <at> debbugs.gnu.org (full text, mbox):

From: Dan Jacobson <jidanni <at> jidanni.org>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 70532 <at> debbugs.gnu.org
Subject: Re: bug#70532: sort: Mention counting fields from the end
Date: Sat, 27 Apr 2024 13:46:25 +0800
>>>>> "PB" == Pádraig Brady <P <at> draigBrady.com> writes:
PB> All good suggestions. I'll at least add an example along the lines of:

PB>   awk '{print $NF, $0}' | sort -k1,1 | cut -f2- -d' '

OK, also say what it's doing. Not everybody knows awk.

Also join(1) needs a tip added. Users might want to join on
e.g., the second to last field on a variable-number-of-fields file.




This bug report was last modified 214 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.