GNU bug report logs -
#41563
Possible bug with 'sort -Vr' version sorting
Previous Next
Full log
View this message in rfc822 format
Hi,
On Wed, May 27, 2020 at 02:07:32PM +0200, Danie de Jager via GNU coreutils Bug Reports wrote:
> I use sort -Vr to sort version numbers. I noticed this discrepancy on
> the latest kernel version from Centos 7.8.
>
> command to get output:
> # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue
> | sort -Vr
> 3.10.0-1127.el7.x86_64
> 3.10.0-1127.8.2.el7.x86_64
> 3.10.0-1062.18.1.el7.x86_64
>
> I'd expect the middle value to be the highest version number. Is this
> by design or a bug? If it is a bug please let me know if I must log it
> somewhere.
I'd say this is by design:
Sorting compares runs of non-digits, then runs of digits. Thus each
"dot" (.) terminates a run of digits. The "problem" is an unbalanced
number of digit and non-digit runs in the version numbers.
See the following two manual sections:
http://www.gnu.org/software/coreutils/manual/coreutils.html#Version_002dsort-ordering-rules
http://www.gnu.org/software/coreutils/manual/coreutils.html#Punctuation-Characters
The "version sort" is based on Debian's version sort (but different).
It seems as if Red Hat version numbers follow different rules.
HTH,
Erik
--
Be water, my friend.
-- Bruce Lee
This bug report was last modified 5 years and 25 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.